├── .gitignore ├── Countdown.h ├── LICENSE ├── README.md ├── TYPE1SC.cpp ├── TYPE1SC.h ├── examples ├── Arduino_New_Nano │ ├── TYPE1SC_AWSIOT_SiteWise_demo │ │ └── TYPE1SC_AWSIOT_SiteWise_demo.ino │ ├── TYPE1SC_AWSIOT_demo │ │ └── TYPE1SC_AWSIOT_demo.ino │ ├── TYPE1SC_AWSIOT_test │ │ └── TYPE1SC_AWSIOT_test.ino │ ├── TYPE1SC_Basic_test │ │ └── TYPE1SC_Basic_test.ino │ ├── TYPE1SC_GET_UnixTime │ │ └── TYPE1SC_GET_UnixTime.ino │ ├── TYPE1SC_HTTP_test │ │ └── TYPE1SC_HTTP_test.ino │ ├── TYPE1SC_MQTT_demo │ │ └── TYPE1SC_MQTT_demo.ino │ ├── TYPE1SC_MQTT_test │ │ └── TYPE1SC_MQTT_test.ino │ ├── TYPE1SC_SET_APN │ │ └── TYPE1SC_SET_APN.ino │ ├── TYPE1SC_TCP_test │ │ └── TYPE1SC_TCP_test.ino │ ├── TYPE1SC_TLS_Socket_HTTPS_GET │ │ └── TYPE1SC_TLS_Socket_HTTPS_GET.ino │ ├── TYPE1SC_TLS_Socket_HTTPS_POST │ │ └── TYPE1SC_TLS_Socket_HTTPS_POST.ino │ ├── TYPE1SC_UDP_test │ │ └── TYPE1SC_UDP_test.ino │ ├── TYPE1SC_WRITE_HTTPS_CERT │ │ ├── TYPE1SC_WRITE_HTTPS_CERT.ino │ │ └── http_credentials.h │ └── TYPE1SC_WRITE_KEY │ │ ├── TYPE1SC_WRITE_KEY.ino │ │ └── aws_credentials.h ├── ESP32 │ ├── TYPE1SC_AWSIOT_SiteWise_demo │ │ └── TYPE1SC_AWSIOT_SiteWise_demo.ino │ ├── TYPE1SC_AWSIOT_test │ │ └── TYPE1SC_AWSIOT_test.ino │ ├── TYPE1SC_Basic_test │ │ └── TYPE1SC_Basic_test.ino │ ├── TYPE1SC_GET_UnixTime │ │ └── TYPE1SC_GET_UnixTime.ino │ ├── TYPE1SC_HTTP_test │ │ └── TYPE1SC_HTTP_test.ino │ ├── TYPE1SC_MQTT_test │ │ └── TYPE1SC_MQTT_test.ino │ ├── TYPE1SC_SET_APN │ │ └── TYPE1SC_SET_APN.ino │ ├── TYPE1SC_TCP_test │ │ └── TYPE1SC_TCP_test.ino │ ├── TYPE1SC_TLS_Socket_HTTPS_GET │ │ └── TYPE1SC_TLS_Socket_HTTPS_GET.ino │ ├── TYPE1SC_TLS_Socket_HTTPS_POST │ │ └── TYPE1SC_TLS_Socket_HTTPS_POST.ino │ ├── TYPE1SC_UDP_test │ │ └── TYPE1SC_UDP_test.ino │ ├── TYPE1SC_WRITE_HTTPS_CERT │ │ ├── TYPE1SC_WRITE_HTTPS_CERT.ino │ │ └── http_credentials.h │ └── TYPE1SC_WRITE_KEY │ │ ├── TYPE1SC_WRITE_KEY.ino │ │ └── aws_credentials.h ├── ESP32_IoT │ ├── TYPE1SC_AWSIOT_SiteWise_demo │ │ └── TYPE1SC_AWSIOT_SiteWise_demo.ino │ ├── TYPE1SC_AWSIOT_test │ │ └── TYPE1SC_AWSIOT_test.ino │ ├── TYPE1SC_Basic_test │ │ └── TYPE1SC_Basic_test.ino │ ├── TYPE1SC_Basic_test_Serial1 │ │ └── TYPE1SC_Basic_test_Serial1.ino │ ├── TYPE1SC_GET_UnixTime │ │ └── TYPE1SC_GET_UnixTime.ino │ ├── TYPE1SC_HTTP_test │ │ └── TYPE1SC_HTTP_test.ino │ ├── TYPE1SC_MQTT_test │ │ └── TYPE1SC_MQTT_test.ino │ ├── TYPE1SC_RS485_XY-MD02 │ │ ├── TYPE1SC_RS485_XY-MD02.ino │ │ └── readme │ ├── TYPE1SC_SET_APN │ │ └── TYPE1SC_SET_APN.ino │ ├── TYPE1SC_TCP_test │ │ └── TYPE1SC_TCP_test.ino │ ├── TYPE1SC_TLS_Socket_HTTPS_GET │ │ └── TYPE1SC_TLS_Socket_HTTPS_GET.ino │ ├── TYPE1SC_TLS_Socket_HTTPS_POST │ │ └── TYPE1SC_TLS_Socket_HTTPS_POST.ino │ ├── TYPE1SC_UDP_test │ │ └── TYPE1SC_UDP_test.ino │ ├── TYPE1SC_WRITE_HTTPS_CERT │ │ ├── TYPE1SC_WRITE_HTTPS_CERT.ino │ │ └── http_credentials.h │ ├── TYPE1SC_WRITE_KEY │ │ ├── TYPE1SC_WRITE_KEY.ino │ │ └── aws_credentials.h │ └── TYPE1SC_button_interrupt │ │ └── TYPE1SC_button_interrupt.ino └── RPI_PICO │ ├── TYPE1SC_AWSIOT_SiteWise_demo │ └── TYPE1SC_AWSIOT_SiteWise_demo.ino │ ├── TYPE1SC_AWSIOT_test │ └── TYPE1SC_AWSIOT_test.ino │ ├── TYPE1SC_Basic_test │ └── TYPE1SC_Basic_test.ino │ ├── TYPE1SC_GET_UnixTime │ └── TYPE1SC_GET_UnixTime.ino │ ├── TYPE1SC_HTTP_test │ └── TYPE1SC_HTTP_test.ino │ ├── TYPE1SC_MQTT_test │ └── TYPE1SC_MQTT_test.ino │ ├── TYPE1SC_SET_APN │ └── TYPE1SC_SET_APN.ino │ ├── TYPE1SC_TCP_test │ └── TYPE1SC_TCP_test.ino │ ├── TYPE1SC_TLS_Socket_HTTPS_GET │ └── TYPE1SC_TLS_Socket_HTTPS_GET.ino │ ├── TYPE1SC_TLS_Socket_HTTPS_POST │ └── TYPE1SC_TLS_Socket_HTTPS_POST.ino │ ├── TYPE1SC_UDP_test │ └── TYPE1SC_UDP_test.ino │ ├── TYPE1SC_WRITE_HTTPS_CERT │ ├── TYPE1SC_WRITE_HTTPS_CERT.ino │ └── http_credentials.h │ └── TYPE1SC_WRITE_KEY │ ├── TYPE1SC_WRITE_KEY.ino │ └── aws_credentials.h ├── manual ├── CodeZoo_LTE-CATM1_Type1SC_보드사양서v1.1.pdf ├── ESP32 + CATM1 모뎀.pdf ├── LTE-CATM1_ESP32_IoT보드_핸즈온.pdf ├── LTE-CATM1_내장형모뎀_ESP32_핸즈온.pdf ├── LTE-CATM1_내장형모뎀_라즈베리파이피코_핸즈온.pdf ├── LTE-CATM1_내장형모뎀_아두이노_핸즈온.pdf ├── [ENG] LTE-CATM1_ESP32_IoT_Board_HandsOn.pdf └── raspberrypi │ └── Cat.M1_RaspberryPi_PPP.pdf └── schematics_dimension ├── CZ-Type1SC_dimension.png ├── ESP32_IoT_Board_dimension.png ├── ESP32_IoT_Board_sch.pdf ├── Murata_Module_PCB1_Rev1.0_210719 BOT.dxf ├── Murata_Module_PCB1_Rev1.0_210719 TOP.dxf ├── Murata_Module_PCB1_Rev1.0_210719 TOP.pdf ├── Nano_to_Uno.pdf ├── expansion_schematics.pdf └── new_shield_board_schematics.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /Countdown.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | * 13 | * Contributors: 14 | * Ian Craggs - initial API and implementation and/or initial documentation 15 | *******************************************************************************/ 16 | 17 | #if !defined(COUNTDOWN_H) 18 | #define COUNTDOWN_H 19 | 20 | #include "Arduino.h" 21 | 22 | class Countdown 23 | { 24 | public: 25 | Countdown() 26 | { 27 | interval_end_ms = 0L; 28 | } 29 | 30 | Countdown(int ms) 31 | { 32 | countdown_ms(ms); 33 | } 34 | 35 | bool expired() 36 | { 37 | return (interval_end_ms > 0L) && (millis() >= interval_end_ms); 38 | } 39 | 40 | void countdown_ms(unsigned long ms) 41 | { 42 | interval_end_ms = millis() + ms; 43 | } 44 | 45 | void countdown(int seconds) 46 | { 47 | countdown_ms((unsigned long)seconds * 1000L); 48 | } 49 | 50 | int left_ms() 51 | { 52 | return interval_end_ms - millis(); 53 | } 54 | 55 | private: 56 | unsigned long interval_end_ms; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 CodeZoo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TYPE1SC 2 | Murata TYPE1SC Cat.M1 Arduino Library & example 3 | 4 | ![CATM1_embedded_Modem](https://user-images.githubusercontent.com/22319034/154849388-0d8e82a9-f7bd-42d2-b8d9-fb31798dc67e.png) 5 | 6 | # Version 7 | 1.0.2 8 | 9 | # Blog 10 | https://codezoo.tistory.com 11 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_AWSIOT_SiteWise_demo/TYPE1SC_AWSIOT_SiteWise_demo.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include //https://github.com/GyverLibs/UnixTime 3 | 4 | #define DebugSerial Serial 5 | #define M1Serial Serial1 6 | 7 | #define DHTPIN A0 8 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 9 | // Uncomment whatever type you're using! 10 | //#define DHTTYPE DHT11 // DHT 11 11 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 12 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 13 | 14 | DHT dht(DHTPIN, DHTTYPE); 15 | UnixTime stamp(9); // Seoul GMT + 09 16 | 17 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 18 | 19 | void setup() { 20 | pinMode(LED_BUILTIN, OUTPUT); 21 | digitalWrite(LED_BUILTIN, HIGH); 22 | 23 | /* DHT22 Sensor Initialization */ 24 | dht.begin(); 25 | delay(2000); 26 | 27 | #if defined(ARDUINO_NANO_ESP32) 28 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 29 | #else 30 | M1Serial.begin(115200); 31 | #endif 32 | DebugSerial.begin(115200); 33 | DebugSerial.println("TYPE1SC Module Start!!!"); 34 | 35 | /* Board Reset */ 36 | TYPE1SC.reset(); 37 | delay(2000); 38 | 39 | /* TYPE1SC Module Initialization */ 40 | if (TYPE1SC.init()) { 41 | DebugSerial.println("TYPE1SC Module Error!!!"); 42 | } 43 | 44 | /* Network Registration Check */ 45 | while (TYPE1SC.canConnect() != 0) { 46 | DebugSerial.println("Network not Ready !!!"); 47 | delay(2000); 48 | } 49 | 50 | DebugSerial.println("TYPE1SC Module Ready!!!"); 51 | 52 | /* Device Data EndPoint Address AWS IoT > Settings > Device data endpoint > 53 | * Copy&Paste */ 54 | char _IP[] = "*****.amazonaws.com"; 55 | 56 | char _NodeID[] = "MCU_AI_Things"; 57 | char _Topic[] = "iot/topic"; 58 | char _message[512]; 59 | int tlsProfile = 9; 60 | int conn_timeout = 1200; 61 | float t = 0.0; // Stores temperature value 62 | float h = 0.0; // Stores humidity value 63 | char temp[8]; 64 | char humi[8]; 65 | 66 | /* 1 : Configure AWS_IOT parameters (ID, Address, tlsProfile) */ 67 | if (TYPE1SC.setAWSIOT_CONN(_NodeID, _IP, tlsProfile) == 0) 68 | DebugSerial.println( 69 | "1.Configure AWS_IOT parameter:ID, Address, tls Profile"); 70 | 71 | /* 2 : Configure AWS_IOT parameters (Connection Timeout) */ 72 | if (TYPE1SC.setAWSIOT_TIMEOUT(conn_timeout) == 0) 73 | DebugSerial.println("2.Configure AWS_IOT parameter:Timeout"); 74 | 75 | /* 3 : Enable AWS_IOT events */ 76 | if (TYPE1SC.setAWSIOT_EV(1) == 0) 77 | DebugSerial.println("3.Enable AWS_IOT events"); 78 | 79 | /* 4 : Establish connection */ 80 | if (TYPE1SC.AWSIOT_Connect() == 0) { 81 | DebugSerial.println("4.Establish connection"); 82 | } 83 | 84 | /* 5 : Subscribe (register) to the topic on the endpoint */ 85 | if (TYPE1SC.AWSIOT_SUBSCRIBE(_Topic) == 0) 86 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 87 | 88 | /*Get Temperature & Humidity */ 89 | while (1) { 90 | /* Get DHT22 Sensor */ 91 | t = dht.readTemperature(); 92 | h = dht.readHumidity(); 93 | if (String(t) != "nan" && String(h) != "nan") 94 | break; 95 | else { 96 | DebugSerial.println("case nan ..."); 97 | delay(1000); 98 | } 99 | } 100 | 101 | dtostrf(t, 4, 1, temp); 102 | dtostrf(h, 4, 1, humi); 103 | 104 | // Make Unix TimeStamp 105 | char szTime[32]; 106 | uint32_t _year, _month, _day, _hour, _minute, _second, _tmp; 107 | 108 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 109 | sscanf(szTime, "\"%d/%d/%d,%d:%d:%d+%d\"", &_year, &_month, &_day, &_hour, 110 | &_minute, &_second, &_tmp); 111 | } 112 | 113 | // Set Date Time 114 | _year += 2000; 115 | stamp.setDateTime(_year, _month, _day, _hour, _minute, _second); 116 | 117 | // Get Unix Time 118 | uint32_t unix = stamp.getUnix(); 119 | 120 | memset(_message, 0x0, sizeof(_message)); 121 | sprintf(_message, 122 | "{\\\"timeInSeconds\\\":\\\"%lu\\\",\\\"Temperature\\\":\\\"%s\\\"," 123 | "\\\"Humidity\\\":\\\"%s\\\"}", 124 | unix, temp, humi); 125 | 126 | /* 6 : Publish data to broker */ 127 | if (TYPE1SC.AWSIOT_Publish(_Topic, _message) == 0) 128 | DebugSerial.println("6.Publish data to broker"); 129 | 130 | /* 7 : UnSubscribe to the topic on the endpoint */ 131 | if (TYPE1SC.AWSIOT_UnSUBSCRIBE(_Topic) == 0) { 132 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 133 | } 134 | 135 | /* 8 : Disconnect AWS_IOT Service */ 136 | if (TYPE1SC.AWSIOT_DisConnect() == 0) 137 | DebugSerial.println("8.Disconnect AWS_IOT Service"); 138 | 139 | /* 9 : Disable AWS_IOT events */ 140 | if (TYPE1SC.setAWSIOT_EV(0) == 0) 141 | DebugSerial.println("9.Disable AWS_IOT events"); 142 | } 143 | 144 | void loop() { delay(1000); } 145 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_AWSIOT_demo/TYPE1SC_AWSIOT_demo.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define DHTPIN A0 7 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 8 | // Uncomment whatever type you're using! 9 | //#define DHTTYPE DHT11 // DHT 11 10 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 11 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 12 | 13 | DHT dht(DHTPIN, DHTTYPE); 14 | 15 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 16 | 17 | void setup() { 18 | // initialize digital pin LED_BUILTIN as an output. 19 | pinMode(LED_BUILTIN, OUTPUT); 20 | dht.begin(); 21 | delay(2000); 22 | 23 | #if defined(ARDUINO_NANO_ESP32) 24 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 25 | #else 26 | M1Serial.begin(115200); 27 | #endif 28 | DebugSerial.begin(115200); 29 | DebugSerial.println("TYPE1SC Module Start!!!"); 30 | 31 | /* Board Reset */ 32 | TYPE1SC.reset(); 33 | delay(2000); 34 | 35 | /* TYPE1SC Module Initialization */ 36 | if (TYPE1SC.init()) { 37 | DebugSerial.println("TYPE1SC Module Error!!!"); 38 | } 39 | 40 | /* Network Registration Check */ 41 | while (TYPE1SC.canConnect() != 0) { 42 | DebugSerial.println("Network not Ready !!!"); 43 | delay(2000); 44 | } 45 | 46 | DebugSerial.println("TYPE1SC Module Ready!!!"); 47 | } 48 | 49 | void loop() { 50 | 51 | digitalWrite(LED_BUILTIN, 52 | HIGH); // turn the LED on (HIGH is the voltage level) 53 | 54 | /* Device Data EndPoint Address AWS IoT > Settings > Device data endpoint > 55 | * Copy&Paste */ 56 | char _IP[] = "*****.amazonaws.com"; 57 | char _NodeID[] = "Murata_Node01"; 58 | char _Topic[] = "sdkTest/sub"; 59 | char _message[64]; 60 | int tlsProfile = 9; 61 | int conn_timeout = 1200; 62 | float t = 0.0; // Stores temperature value 63 | float h = 0.0; // Stores humidity value 64 | char temp[8]; 65 | char humi[8]; 66 | int cnt = 10; /* Data report Count */ 67 | 68 | /* 1 : Configure AWS_IOT parameters (ID, Address, tlsProfile) */ 69 | if (TYPE1SC.setAWSIOT_CONN(_NodeID, _IP, tlsProfile) == 0) 70 | DebugSerial.println( 71 | "1.Configure AWS_IOT parameter:ID, Address, tls Profile"); 72 | 73 | /* 2 : Configure AWS_IOT parameters (Connection Timeout) */ 74 | if (TYPE1SC.setAWSIOT_TIMEOUT(conn_timeout) == 0) 75 | DebugSerial.println("2.Configure AWS_IOT parameter:Timeout"); 76 | 77 | /* 3 : Enable AWS_IOT events */ 78 | if (TYPE1SC.setAWSIOT_EV(1) == 0) 79 | DebugSerial.println("3.Enable AWS_IOT events"); 80 | 81 | /* 4 : Establish connection */ 82 | if (TYPE1SC.AWSIOT_Connect() == 0) { 83 | DebugSerial.println("4.Establish connection"); 84 | } 85 | 86 | /* 5 : Subscribe (register) to the topic on the endpoint */ 87 | if (TYPE1SC.AWSIOT_SUBSCRIBE(_Topic) == 0) 88 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 89 | 90 | /* 6 : Publish data to broker */ 91 | while (cnt--) { 92 | /*Get Temperature & Humidity */ 93 | while (1) { 94 | /* Get DHT22 Sensor */ 95 | t = dht.readTemperature(); 96 | h = dht.readHumidity(); 97 | if (String(t) != "nan" && String(h) != "nan") 98 | break; 99 | else { 100 | DebugSerial.println("case nan ..."); 101 | delay(1000); 102 | } 103 | } 104 | 105 | dtostrf(t, 4, 1, temp); 106 | dtostrf(h, 4, 1, humi); 107 | 108 | memset(_message, 0x0, sizeof(_message)); 109 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 110 | if (TYPE1SC.AWSIOT_Publish(_Topic, _message) == 0) 111 | DebugSerial.println("6.Publish data to broker"); 112 | } 113 | 114 | /* 7 : UnSubscribe to the topic on the endpoint */ 115 | if (TYPE1SC.AWSIOT_UnSUBSCRIBE(_Topic) == 0) { 116 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 117 | } 118 | 119 | /* 8 : Disconnect AWS_IOT Service */ 120 | if (TYPE1SC.AWSIOT_DisConnect() == 0) 121 | DebugSerial.println("8.Disconnect AWS_IOT Service"); 122 | 123 | /* 9 : Disable AWS_IOT events */ 124 | if (TYPE1SC.setAWSIOT_EV(0) == 0) 125 | DebugSerial.println("9.Disable AWS_IOT events"); 126 | 127 | DebugSerial.println("/=========================================/"); 128 | DebugSerial.println(""); 129 | digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 130 | 131 | delay(600000); /* 10 Minute */ 132 | } 133 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_AWSIOT_test/TYPE1SC_AWSIOT_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define DHTPIN A0 7 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 8 | // Uncomment whatever type you're using! 9 | //#define DHTTYPE DHT11 // DHT 11 10 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 11 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 12 | 13 | DHT dht(DHTPIN, DHTTYPE); 14 | 15 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 16 | 17 | void setup() { 18 | pinMode(LED_BUILTIN, OUTPUT); 19 | digitalWrite(LED_BUILTIN, HIGH); 20 | 21 | /* DHT22 Sensor Initialization */ 22 | dht.begin(); 23 | delay(2000); 24 | 25 | #if defined(ARDUINO_NANO_ESP32) 26 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 27 | #else 28 | M1Serial.begin(115200); 29 | #endif 30 | DebugSerial.begin(115200); 31 | DebugSerial.println("TYPE1SC Module Start!!!"); 32 | 33 | /* Board Reset */ 34 | TYPE1SC.reset(); 35 | delay(2000); 36 | 37 | /* TYPE1SC Module Initialization */ 38 | if (TYPE1SC.init()) { 39 | DebugSerial.println("TYPE1SC Module Error!!!"); 40 | } 41 | 42 | /* Network Registration Check */ 43 | while (TYPE1SC.canConnect() != 0) { 44 | DebugSerial.println("Network not Ready !!!"); 45 | delay(2000); 46 | } 47 | 48 | DebugSerial.println("TYPE1SC Module Ready!!!"); 49 | 50 | /* Device Data EndPoint Address AWS IoT > Settings > Device data endpoint > 51 | * Copy&Paste */ 52 | char _IP[] = "*****.amazonaws.com"; 53 | 54 | char _NodeID[] = "Murata_Node01"; 55 | char _Topic[] = "sdkTest/sub"; 56 | char _message[64]; 57 | int tlsProfile = 9; 58 | int conn_timeout = 1200; 59 | float t = 0.0; // Stores temperature value 60 | float h = 0.0; // Stores humidity value 61 | char temp[8]; 62 | char humi[8]; 63 | 64 | /* 1 : Configure AWS_IOT parameters (ID, Address, tlsProfile) */ 65 | if (TYPE1SC.setAWSIOT_CONN(_NodeID, _IP, tlsProfile) == 0) 66 | DebugSerial.println( 67 | "1.Configure AWS_IOT parameter:ID, Address, tls Profile"); 68 | 69 | /* 2 : Configure AWS_IOT parameters (Connection Timeout) */ 70 | if (TYPE1SC.setAWSIOT_TIMEOUT(conn_timeout) == 0) 71 | DebugSerial.println("2.Configure AWS_IOT parameter:Timeout"); 72 | 73 | /* 3 : Enable AWS_IOT events */ 74 | if (TYPE1SC.setAWSIOT_EV(1) == 0) 75 | DebugSerial.println("3.Enable AWS_IOT events"); 76 | 77 | /* 4 : Establish connection */ 78 | if (TYPE1SC.AWSIOT_Connect() == 0) { 79 | DebugSerial.println("4.Establish connection"); 80 | } 81 | 82 | /* 5 : Subscribe (register) to the topic on the endpoint */ 83 | if (TYPE1SC.AWSIOT_SUBSCRIBE(_Topic) == 0) 84 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 85 | 86 | /*Get Temperature & Humidity */ 87 | while (1) { 88 | /* Get DHT22 Sensor */ 89 | t = dht.readTemperature(); 90 | h = dht.readHumidity(); 91 | if (String(t) != "nan" && String(h) != "nan") 92 | break; 93 | else { 94 | DebugSerial.println("case nan ..."); 95 | delay(1000); 96 | } 97 | } 98 | 99 | dtostrf(t, 4, 1, temp); 100 | dtostrf(h, 4, 1, humi); 101 | 102 | memset(_message, 0x0, sizeof(_message)); 103 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 104 | 105 | /* 6 : Publish data to broker */ 106 | if (TYPE1SC.AWSIOT_Publish(_Topic, _message) == 0) 107 | DebugSerial.println("6.Publish data to broker"); 108 | 109 | /* 7 : UnSubscribe to the topic on the endpoint */ 110 | if (TYPE1SC.AWSIOT_UnSUBSCRIBE(_Topic) == 0) { 111 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 112 | } 113 | 114 | /* 8 : Disconnect AWS_IOT Service */ 115 | if (TYPE1SC.AWSIOT_DisConnect() == 0) 116 | DebugSerial.println("8.Disconnect AWS_IOT Service"); 117 | 118 | /* 9 : Disable AWS_IOT events */ 119 | if (TYPE1SC.setAWSIOT_EV(0) == 0) 120 | DebugSerial.println("9.Disable AWS_IOT events"); 121 | } 122 | 123 | void loop() { delay(1000); } 124 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_Basic_test/TYPE1SC_Basic_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 7 | 8 | void setup() { 9 | pinMode(LED_BUILTIN, OUTPUT); 10 | digitalWrite(LED_BUILTIN, HIGH); 11 | 12 | #if defined(ARDUINO_NANO_ESP32) 13 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 14 | #else 15 | M1Serial.begin(115200); 16 | #endif 17 | DebugSerial.begin(115200); 18 | DebugSerial.println("TYPE1SC Module Start!!!"); 19 | 20 | /* Board Reset */ 21 | TYPE1SC.reset(); 22 | delay(2000); 23 | 24 | /* TYPE1SC Module Initialization */ 25 | if (TYPE1SC.init()) { 26 | DebugSerial.println("TYPE1SC Module Error!!!"); 27 | } 28 | 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | } 37 | 38 | void loop() { 39 | /*** TYPE1SC Basic Test Code ***/ 40 | /* SIM Card Check */ 41 | if (!TYPE1SC.chkSIM()) { 42 | DebugSerial.println("SIM Card OK!!!"); 43 | } 44 | delay(1000); 45 | 46 | /* Get Phone Number */ 47 | char szCIMI[16]; 48 | if (TYPE1SC.getCIMI(szCIMI, sizeof(szCIMI)) == 0) { 49 | DebugSerial.print("CIMI : "); 50 | DebugSerial.println(szCIMI); 51 | } 52 | delay(1000); 53 | 54 | char szIMEI[16]; 55 | if (TYPE1SC.getIMEI(szIMEI, sizeof(szIMEI)) == 0) { 56 | DebugSerial.print("IMEI : "); 57 | DebugSerial.println(szIMEI); 58 | } 59 | delay(1000); 60 | 61 | /* Get Fimrware version */ 62 | char szCGMR[20]; 63 | if (TYPE1SC.getCGMR(szCGMR, sizeof(szCGMR)) == 0) { 64 | DebugSerial.print("CGMR : "); 65 | DebugSerial.println(szCGMR); 66 | } 67 | delay(1000); 68 | 69 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 70 | char szTime[32]; 71 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 72 | DebugSerial.print("Time : "); 73 | DebugSerial.println(szTime); 74 | } 75 | delay(1000); 76 | 77 | /* Get RSSI */ 78 | int rssi; 79 | if (TYPE1SC.getRSSI(&rssi) == 0) { 80 | DebugSerial.print("RSSI : "); 81 | DebugSerial.println(rssi); 82 | } 83 | delay(1000); 84 | 85 | /* Get RSRP */ 86 | int rsrp; 87 | if (TYPE1SC.getRSRP(&rsrp) == 0) { 88 | DebugSerial.print("RSRP : "); 89 | DebugSerial.println(rsrp); 90 | } 91 | delay(1000); 92 | 93 | /* Get RSRQ */ 94 | int rsrq; 95 | if (TYPE1SC.getRSRQ(&rsrq) == 0) { 96 | DebugSerial.print("RSRQ : "); 97 | DebugSerial.println(rsrq); 98 | } 99 | delay(1000); 100 | 101 | /* Get SINR */ 102 | int sinr; 103 | if (TYPE1SC.getSINR(&sinr) == 0) { 104 | DebugSerial.print("SINR : "); 105 | DebugSerial.println(sinr); 106 | } 107 | delay(1000); 108 | 109 | /* Get TX Power */ 110 | char txPower[64]; 111 | if (TYPE1SC.getTxPower(txPower, sizeof(txPower)) == 0) { 112 | DebugSerial.print("TX Power : "); 113 | DebugSerial.println(txPower); 114 | } 115 | delay(1000); 116 | } 117 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_GET_UnixTime/TYPE1SC_GET_UnixTime.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include //https://github.com/GyverLibs/UnixTime 3 | 4 | #define DebugSerial Serial 5 | #define M1Serial Serial1 6 | 7 | UnixTime stamp(9); // Seoul GMT + 09 8 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 9 | 10 | void setup() { 11 | pinMode(LED_BUILTIN, OUTPUT); 12 | digitalWrite(LED_BUILTIN, HIGH); 13 | 14 | #if defined(ARDUINO_NANO_ESP32) 15 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 16 | #else 17 | M1Serial.begin(115200); 18 | #endif 19 | DebugSerial.begin(115200); 20 | DebugSerial.println("TYPE1SC Module Start!!!"); 21 | 22 | /* Board Reset */ 23 | TYPE1SC.reset(); 24 | delay(2000); 25 | 26 | /* TYPE1SC Module Initialization */ 27 | if (TYPE1SC.init()) { 28 | DebugSerial.println("TYPE1SC Module Error!!!"); 29 | } 30 | 31 | /* Network Registration Check */ 32 | while (TYPE1SC.canConnect() != 0) { 33 | DebugSerial.println("Network not Ready !!!"); 34 | delay(2000); 35 | } 36 | 37 | DebugSerial.println("TYPE1SC Module Ready!!!"); 38 | } 39 | 40 | void loop() { 41 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 42 | char szTime[32]; 43 | uint32_t _year, _month, _day, _hour, _minute, _second, _tmp; 44 | 45 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 46 | DebugSerial.print("Time : "); 47 | DebugSerial.println(szTime); 48 | sscanf(szTime, "\"%d/%d/%d,%d:%d:%d+%d\"", &_year, &_month, &_day, &_hour, 49 | &_minute, &_second, &_tmp); 50 | /* Debug */ 51 | DebugSerial.println(_year); 52 | DebugSerial.println(_month); 53 | DebugSerial.println(_day); 54 | DebugSerial.println(_hour); 55 | DebugSerial.println(_minute); 56 | DebugSerial.println(_second); 57 | } 58 | // Set Date Time 59 | _year += 2000; 60 | stamp.setDateTime(_year, _month, _day, _hour, _minute, _second); 61 | 62 | // Get Unix Time 63 | uint32_t unix = stamp.getUnix(); 64 | DebugSerial.println(unix); 65 | 66 | // ========== UNIX to date and time =========== 67 | // convert unix to date and time 68 | // getDateTime(unix stamp) runs ~500 us on AVR 69 | // https://www.unixtimestamp.com/index.php 70 | stamp.getDateTime(unix); 71 | 72 | // pick up like this 73 | DebugSerial.println(stamp.year); 74 | DebugSerial.println(stamp.month); 75 | DebugSerial.println(stamp.day); 76 | DebugSerial.println(stamp.hour); 77 | DebugSerial.println(stamp.minute); 78 | DebugSerial.println(stamp.second); 79 | 80 | delay(1000); 81 | } 82 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_HTTP_test/TYPE1SC_HTTP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define DHTPIN A0 7 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 8 | // Uncomment whatever type you're using! 9 | //#define DHTTYPE DHT11 // DHT 11 10 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 11 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 12 | 13 | DHT dht(DHTPIN, DHTTYPE); 14 | 15 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 16 | 17 | void setup() { 18 | pinMode(LED_BUILTIN, OUTPUT); 19 | digitalWrite(LED_BUILTIN, HIGH); 20 | 21 | /* DHT22 Sensor Initialization */ 22 | dht.begin(); 23 | delay(2000); 24 | 25 | #if defined(ARDUINO_NANO_ESP32) 26 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 27 | #else 28 | M1Serial.begin(115200); 29 | #endif 30 | DebugSerial.begin(115200); 31 | DebugSerial.println("TYPE1SC Module Start!!!"); 32 | 33 | /* Board Reset */ 34 | TYPE1SC.reset(); 35 | delay(2000); 36 | 37 | /* TYPE1SC Module Initialization */ 38 | if (TYPE1SC.init()) { 39 | DebugSerial.println("TYPE1SC Module Error!!!"); 40 | } 41 | 42 | /* Network Registration Check */ 43 | while (TYPE1SC.canConnect() != 0) { 44 | DebugSerial.println("Network not Ready !!!"); 45 | delay(2000); 46 | } 47 | 48 | DebugSerial.println("TYPE1SC Module Ready!!!"); 49 | 50 | /* Enter a DNS address to get an IP address */ 51 | char IPAddr[32]; 52 | 53 | while (1) { 54 | 55 | if (TYPE1SC.getIPAddr("api.thingspeak.com", IPAddr, sizeof(IPAddr)) == 0) { 56 | DebugSerial.print("IP Address : "); 57 | DebugSerial.println(IPAddr); 58 | break; 59 | } else { 60 | DebugSerial.println("IP Address Error!!!"); 61 | } 62 | delay(2000); 63 | } 64 | 65 | int _PORT = 80; 66 | char sckInfo[128]; 67 | char recvBuffer[700]; 68 | int recvSize; 69 | 70 | String WApiKey = "****************"; // Thing Speak Write API Key 16Character 71 | float temp = 0.0; 72 | float humi = 0.0; 73 | String fieldTemp = "field1"; // Air temperature 74 | String fieldHumi = "field2"; // Air humidity 75 | 76 | /*Get Temperature & Humidity */ 77 | while (1) { 78 | /* Get DHT22 Sensor */ 79 | temp = dht.readTemperature(); 80 | humi = dht.readHumidity(); 81 | if (String(temp) != "nan" && String(humi) != "nan") 82 | break; 83 | else { 84 | DebugSerial.println("case nan ..."); 85 | delay(1000); 86 | } 87 | } 88 | 89 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 90 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 91 | DebugSerial.println("TCP Socket Create!!!"); 92 | 93 | INFO: 94 | 95 | /* 2 :TCP Socket Activation */ 96 | if (TYPE1SC.socketActivate() == 0) 97 | DebugSerial.println("TCP Socket Activation!!!"); 98 | 99 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 100 | DebugSerial.print("Socket Info : "); 101 | DebugSerial.println(sckInfo); 102 | 103 | if (strcmp(sckInfo, "ACTIVATED")) { 104 | delay(3000); 105 | goto INFO; 106 | } 107 | } 108 | 109 | /* 3 :TCP Socket Send Data */ 110 | String data = "GET /update"; 111 | data += "?api_key=" + WApiKey + "&" + fieldTemp + "=" + String(temp) + "&" + 112 | fieldHumi + "=" + String(humi); 113 | data += " HTTP/1.1\r\n"; 114 | data += "Host: api.thingspeak.com\r\n"; 115 | data += "Connection: close\r\n\r\n"; 116 | 117 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 118 | DebugSerial.print("[HTTP Send] >> "); 119 | DebugSerial.println(data); 120 | } else 121 | DebugSerial.println("Send Fail!!!"); 122 | 123 | /* 4 :TCP Socket Recv Data */ 124 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 125 | DebugSerial.print("[Recv] >> "); 126 | DebugSerial.println(recvBuffer); 127 | DebugSerial.print("[RecvSize] >> "); 128 | DebugSerial.println(recvSize); 129 | } else { 130 | DebugSerial.println("Recv Fail!!!"); 131 | } 132 | 133 | /* 5 :TCP Socket DeActivation */ 134 | if (TYPE1SC.socketDeActivate() == 0) 135 | DebugSerial.println("TCP Socket DeActivation!!!"); 136 | 137 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 138 | DebugSerial.print("Socket Info : "); 139 | DebugSerial.println(sckInfo); 140 | } 141 | 142 | /* 6 :TCP Socket DeActivation */ 143 | if (TYPE1SC.socketClose() == 0) 144 | DebugSerial.println("TCP Socket Close!!!"); 145 | } 146 | 147 | void loop() { delay(1000); } 148 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_MQTT_demo/TYPE1SC_MQTT_demo.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define DHTPIN A0 7 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 8 | // Uncomment whatever type you're using! 9 | //#define DHTTYPE DHT11 // DHT 11 10 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 11 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 12 | 13 | DHT dht(DHTPIN, DHTTYPE); 14 | 15 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 16 | 17 | void setup() { 18 | // initialize digital pin LED_BUILTIN as an output. 19 | pinMode(LED_BUILTIN, OUTPUT); 20 | 21 | dht.begin(); 22 | delay(2000); 23 | 24 | #if defined(ARDUINO_NANO_ESP32) 25 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 26 | #else 27 | M1Serial.begin(115200); 28 | #endif 29 | DebugSerial.begin(115200); 30 | DebugSerial.println("TYPE1SC Module Start!!!"); 31 | 32 | /* Board Reset */ 33 | TYPE1SC.reset(); 34 | delay(2000); 35 | 36 | /* TYPE1SC Module Initialization */ 37 | if (TYPE1SC.init()) { 38 | DebugSerial.println("TYPE1SC Module Error!!!"); 39 | } 40 | 41 | /* Network Registration Check */ 42 | while (TYPE1SC.canConnect() != 0) { 43 | DebugSerial.println("Network not Ready !!!"); 44 | delay(2000); 45 | } 46 | 47 | DebugSerial.println("TYPE1SC Module Ready!!!"); 48 | } 49 | 50 | void loop() { 51 | 52 | digitalWrite(LED_BUILTIN, 53 | HIGH); // turn the LED on (HIGH is the voltage level) 54 | 55 | char _IP[] = "broker.hivemq.com"; 56 | char _NodeID[] = "Cellular_node"; 57 | char _Topic[] = "type1sc/0/test"; 58 | char _message[64]; 59 | uint32_t conn_timeout = 1200; 60 | float t = 0.0; // Stores temperature value 61 | float h = 0.0; // Stores humidity value 62 | char temp[8]; 63 | char humi[8]; 64 | int cnt = 10; /* Data report Count */ 65 | /* 66 | * qos : 0 - at most one delivery (default) 67 | * 1 - Delivered at least once 68 | * 2 - Exactly one delivery 69 | */ 70 | int qos = 0; 71 | 72 | /* 1 : Enable MQTT events */ 73 | if (TYPE1SC.setMQTT_EV(1) == 0) 74 | DebugSerial.println("1.Enable MQTT events"); 75 | 76 | /* 2 : Configure node parameters (ID, Address) */ 77 | if (TYPE1SC.setMQTT_NODES(_NodeID, _IP) == 0) 78 | DebugSerial.println("2.Configure node parameter:ID, Address"); 79 | 80 | /* 3 : Configure node parameters (Connection Timeout) */ 81 | if (TYPE1SC.setMQTT_TIMEOUT(conn_timeout) == 0) 82 | DebugSerial.println("3.Configure node parameter:Timeout"); 83 | 84 | /* 4 : Establish connection */ 85 | if (TYPE1SC.MQTT_Connect() == 0) 86 | DebugSerial.println("4.Establish connection"); 87 | 88 | /* 5 : Subscribe (register) to the topic on the endpoint */ 89 | if (TYPE1SC.MQTT_SUBSCRIBE(qos, _Topic) == 0) 90 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 91 | 92 | /* 6 : Publish data to broker */ 93 | while (cnt--) { 94 | /*Get Temperature & Humidity */ 95 | while (1) { 96 | /* Get DHT22 Sensor */ 97 | t = dht.readTemperature(); 98 | h = dht.readHumidity(); 99 | if (String(t) != "nan" && String(h) != "nan") 100 | break; 101 | else { 102 | DebugSerial.println("case nan ..."); 103 | delay(1000); 104 | } 105 | } 106 | 107 | dtostrf(t, 4, 1, temp); 108 | dtostrf(h, 4, 1, humi); 109 | 110 | memset(_message, 0x0, sizeof(_message)); 111 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 112 | if (TYPE1SC.MQTT_Publish(qos, _Topic, strlen(_message), _message) == 0) 113 | DebugSerial.println("6.Publish data to broker"); 114 | } 115 | 116 | /* 7 : UnSubscribe to the topic on the endpoint */ 117 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 118 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 119 | } else { 120 | delay(1000); 121 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 122 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 123 | } 124 | } 125 | /* 8 : Disconnect MQTT Server */ 126 | if (TYPE1SC.MQTT_DisConnect() == 0) 127 | DebugSerial.println("8.Disconnect MQTT Server"); 128 | 129 | /* 0 : Disable MQTT events */ 130 | if (TYPE1SC.setMQTT_EV(0) == 0) 131 | DebugSerial.println("9.Disable MQTT events"); 132 | 133 | DebugSerial.println("/=========================================/"); 134 | DebugSerial.println(""); 135 | digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 136 | 137 | delay(600000); /* 10min */ 138 | } 139 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_MQTT_test/TYPE1SC_MQTT_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define DHTPIN A0 7 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 8 | // Uncomment whatever type you're using! 9 | //#define DHTTYPE DHT11 // DHT 11 10 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 11 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 12 | 13 | DHT dht(DHTPIN, DHTTYPE); 14 | 15 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 16 | 17 | void setup() { 18 | pinMode(LED_BUILTIN, OUTPUT); 19 | digitalWrite(LED_BUILTIN, HIGH); 20 | 21 | /* DHT22 Sensor Initialization */ 22 | dht.begin(); 23 | delay(2000); 24 | 25 | #if defined(ARDUINO_NANO_ESP32) 26 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 27 | #else 28 | M1Serial.begin(115200); 29 | #endif 30 | DebugSerial.begin(115200); 31 | DebugSerial.println("TYPE1SC Module Start!!!"); 32 | 33 | /* Board Reset */ 34 | TYPE1SC.reset(); 35 | delay(2000); 36 | 37 | /* TYPE1SC Module Initialization */ 38 | if (TYPE1SC.init()) { 39 | DebugSerial.println("TYPE1SC Module Error!!!"); 40 | } 41 | 42 | /* Network Registration Check */ 43 | while (TYPE1SC.canConnect() != 0) { 44 | DebugSerial.println("Network not Ready !!!"); 45 | delay(2000); 46 | } 47 | 48 | DebugSerial.println("TYPE1SC Module Ready!!!"); 49 | 50 | char _IP[] = "broker.hivemq.com"; 51 | char _NodeID[] = "Cellular_node"; 52 | char _Topic[] = "type1sc/0/test"; 53 | char _message[64]; 54 | uint32_t conn_timeout = 1200; 55 | float t = 0.0; 56 | float h = 0.0; 57 | char temp[8]; // Stores temperature value 58 | char humi[8]; // Stores humidity value 59 | 60 | /* 61 | * qos : 0 - at most one delivery (default) 62 | * 1 - Delivered at least once 63 | * 2 - Exactly one delivery 64 | */ 65 | int qos = 0; 66 | 67 | /* 1 : Enable MQTT events */ 68 | if (TYPE1SC.setMQTT_EV(1) == 0) 69 | DebugSerial.println("1.Enable MQTT events"); 70 | 71 | /* 2 : Configure node parameters (ID, Address) */ 72 | if (TYPE1SC.setMQTT_NODES(_NodeID, _IP) == 0) 73 | DebugSerial.println("2.Configure node parameter:ID, Address"); 74 | 75 | /* 3 : Configure node parameters (Connection Timeout) */ 76 | if (TYPE1SC.setMQTT_TIMEOUT(conn_timeout) == 0) 77 | DebugSerial.println("3.Configure node parameter:Timeout"); 78 | 79 | /* 4 : Establish connection */ 80 | if (TYPE1SC.MQTT_Connect() == 0) 81 | DebugSerial.println("4.Establish connection"); 82 | 83 | /* 5 : Subscribe (register) to the topic on the endpoint */ 84 | if (TYPE1SC.MQTT_SUBSCRIBE(qos, _Topic) == 0) 85 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 86 | 87 | /*Get Temperature & Humidity */ 88 | while (1) { 89 | /* Get DHT22 Sensor */ 90 | t = dht.readTemperature(); 91 | h = dht.readHumidity(); 92 | if (String(t) != "nan" && String(h) != "nan") 93 | break; 94 | else { 95 | DebugSerial.println("case nan ..."); 96 | delay(1000); 97 | } 98 | } 99 | 100 | dtostrf(t, 4, 1, temp); 101 | dtostrf(h, 4, 1, humi); 102 | 103 | memset(_message, 0x0, sizeof(_message)); 104 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 105 | /* 6 : Publish data to broker */ 106 | if (TYPE1SC.MQTT_Publish(qos, _Topic, strlen(_message), _message) == 0) 107 | DebugSerial.println("6.Publish data to broker"); 108 | 109 | /* 7 : UnSubscribe to the topic on the endpoint */ 110 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 111 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 112 | } else { 113 | delay(1000); 114 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 115 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 116 | } 117 | } 118 | /* 8 : Disconnect MQTT Server */ 119 | if (TYPE1SC.MQTT_DisConnect() == 0) 120 | DebugSerial.println("8.Disconnect MQTT Server"); 121 | 122 | /* 0 : Disable MQTT events */ 123 | if (TYPE1SC.setMQTT_EV(0) == 0) 124 | DebugSerial.println("9.Disable MQTT events"); 125 | } 126 | 127 | void loop() { delay(1000); } 128 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_SET_APN/TYPE1SC_SET_APN.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 7 | 8 | void setup() { 9 | pinMode(LED_BUILTIN, OUTPUT); 10 | digitalWrite(LED_BUILTIN, HIGH); 11 | 12 | #if defined(ARDUINO_NANO_ESP32) 13 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 14 | #else 15 | M1Serial.begin(115200); 16 | #endif 17 | DebugSerial.begin(115200); 18 | DebugSerial.println("TYPE1SC Module Start!!!"); 19 | 20 | /* Board Reset */ 21 | TYPE1SC.reset(); 22 | delay(2000); 23 | 24 | /* TYPE1SC Module Initialization */ 25 | if (TYPE1SC.init()) { 26 | DebugSerial.println("TYPE1SC Module Error!!!"); 27 | } 28 | 29 | /* Network Disable */ 30 | if (TYPE1SC.setCFUN(0) == 0) { 31 | DebugSerial.println("TYPE1SC Network Disable!!!"); 32 | } 33 | 34 | delay(1000); 35 | 36 | char *apnAddr = "simplio.apn"; /* Vodafone Global IoT SIM APN */ 37 | 38 | if (TYPE1SC.setAPN(apnAddr) == 0) { 39 | DebugSerial.println("TYPE1SC Set APN Address !!!"); 40 | } 41 | /* Board Reset */ 42 | TYPE1SC.reset(); 43 | delay(2000); 44 | 45 | /* TYPE1SC Module Initialization */ 46 | if (TYPE1SC.init()) { 47 | DebugSerial.println("TYPE1SC Module Error!!!"); 48 | } 49 | 50 | DebugSerial.println("TYPE1SC Module Ready!!!"); 51 | 52 | char apn[128]; 53 | if (TYPE1SC.getAPN(apn, sizeof(apn)) == 0) { 54 | DebugSerial.print("GET APN Address: "); 55 | DebugSerial.println(apn); 56 | } 57 | } 58 | 59 | void loop() { delay(1000); } 60 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_TCP_test/TYPE1SC_TCP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 7 | 8 | void setup() { 9 | pinMode(LED_BUILTIN, OUTPUT); 10 | digitalWrite(LED_BUILTIN, HIGH); 11 | 12 | #if defined(ARDUINO_NANO_ESP32) 13 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 14 | #else 15 | M1Serial.begin(115200); 16 | #endif 17 | DebugSerial.begin(115200); 18 | DebugSerial.println("TYPE1SC Module Start!!!"); 19 | 20 | /* Board Reset */ 21 | TYPE1SC.reset(); 22 | delay(2000); 23 | 24 | /* TYPE1SC Module Initialization */ 25 | if (TYPE1SC.init()) { 26 | DebugSerial.println("TYPE1SC Module Error!!!"); 27 | } 28 | 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | 37 | /* Enter a DNS address to get an IP address */ 38 | char IPAddr[32]; 39 | 40 | while (1) { 41 | 42 | if (TYPE1SC.getIPAddr("echo.mbedcloudtesting.com", IPAddr, 43 | sizeof(IPAddr)) == 0) { 44 | DebugSerial.print("IP Address : "); 45 | DebugSerial.println(IPAddr); 46 | break; 47 | } else { 48 | DebugSerial.println("IP Address Error!!!"); 49 | } 50 | delay(2000); 51 | } 52 | 53 | int _PORT = 7; 54 | char sckInfo[128]; 55 | 56 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 57 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 58 | DebugSerial.println("TCP Socket Create!!!"); 59 | 60 | INFO: 61 | 62 | /* 2 :TCP Socket Activation */ 63 | if (TYPE1SC.socketActivate() == 0) 64 | DebugSerial.println("TCP Socket Activation!!!"); 65 | 66 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 67 | DebugSerial.print("Socket Info : "); 68 | DebugSerial.println(sckInfo); 69 | 70 | if (strcmp(sckInfo, "ACTIVATED")) { 71 | delay(3000); 72 | goto INFO; 73 | } 74 | } 75 | 76 | /* 3 :TCP Socket Send Data */ 77 | char sendBuffer[] = "Hello CodeZoo!!!"; 78 | char recvBuffer[32]; 79 | int recvSize; 80 | 81 | if (TYPE1SC.socketSend(sendBuffer) == 0) { 82 | DebugSerial.print("[Send] >> "); 83 | DebugSerial.println(sendBuffer); 84 | } else 85 | DebugSerial.println("Send Fail!!!"); 86 | 87 | /* 4 :TCP Socket Recv Data */ 88 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 89 | DebugSerial.print("[Recv] >> "); 90 | DebugSerial.println(recvBuffer); 91 | DebugSerial.print("[RecvSize] >> "); 92 | DebugSerial.println(recvSize); 93 | } else { 94 | DebugSerial.println("Recv Fail!!!"); 95 | } 96 | 97 | /* 5 :TCP Socket DeActivation */ 98 | if (TYPE1SC.socketDeActivate() == 0) 99 | DebugSerial.println("TCP Socket DeActivation!!!"); 100 | 101 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 102 | DebugSerial.print("Socket Info : "); 103 | DebugSerial.println(sckInfo); 104 | } 105 | 106 | /* 6 :TCP Socket DeActivation */ 107 | if (TYPE1SC.socketClose() == 0) 108 | DebugSerial.println("TCP Socket Close!!!"); 109 | } 110 | 111 | void loop() { delay(1000); } 112 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_TLS_Socket_HTTPS_GET/TYPE1SC_TLS_Socket_HTTPS_GET.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define PROFILE_ID 2 7 | 8 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 9 | 10 | int recvCnt = 0; 11 | 12 | void setup() { 13 | pinMode(LED_BUILTIN, OUTPUT); 14 | digitalWrite(LED_BUILTIN, HIGH); 15 | 16 | #if defined(ARDUINO_NANO_ESP32) 17 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 18 | #else 19 | M1Serial.begin(115200); 20 | #endif 21 | DebugSerial.begin(115200); 22 | DebugSerial.println("TYPE1SC Module Start!!!"); 23 | 24 | /* Board Reset */ 25 | TYPE1SC.reset(); 26 | delay(2000); 27 | 28 | /* TYPE1SC Module Initialization */ 29 | if (TYPE1SC.init()) { 30 | DebugSerial.println("TYPE1SC Module Error!!!"); 31 | } 32 | /* Network Registration Check */ 33 | while (TYPE1SC.canConnect() != 0) { 34 | DebugSerial.println("Network not Ready !!!"); 35 | delay(2000); 36 | } 37 | DebugSerial.println("TYPE1SC Module Ready!!!"); 38 | 39 | /* Enter a DNS address */ 40 | char IPAddr[] = "httpbin.org"; 41 | int _PORT = 443; /* https default port */ 42 | char sckInfo[128]; 43 | char recvBuffer[1500]; 44 | int recvSize = 0; 45 | 46 | /* 0 :Socket All Event Enable */ 47 | if (TYPE1SC.setSocket_EV(1) == 0) { 48 | DebugSerial.println("Socket All Event Enable!!!"); 49 | } 50 | 51 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 52 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) { 53 | DebugSerial.println("TCP Socket Create!!!"); 54 | } 55 | 56 | /* 2 :Socket SSL Enabel */ 57 | int tlsProfileNumber = PROFILE_ID; 58 | if (TYPE1SC.socketSSL(tlsProfileNumber) == 0) { 59 | DebugSerial.println("Socket SSL Enable!!!"); 60 | } 61 | 62 | INFO: 63 | /* 3 :TLS TCP-Socket Activation */ 64 | if (TYPE1SC.socketActivate() == 0) { 65 | DebugSerial.println("TCP Socket Activation!!!"); 66 | } 67 | 68 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 69 | DebugSerial.print("Socket Info : "); 70 | DebugSerial.println(sckInfo); 71 | if (strcmp(sckInfo, "ACTIVATED")) { 72 | TYPE1SC.socketDeActivate(); 73 | delay(3000); 74 | goto INFO; 75 | } 76 | } 77 | 78 | /* 4 :TLS TCP-Socket Send Data */ 79 | String data = "GET /get HTTP/1.1\r\n"; 80 | data += "Host: httpbin.org\r\n\r\n"; 81 | 82 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 83 | DebugSerial.println("[--- HTTPS Send ---]"); 84 | DebugSerial.println(data); 85 | } else 86 | DebugSerial.println("Send Fail!!!"); 87 | 88 | /* 5 :TLS TCP-Socket Receive Data */ 89 | if (TYPE1SC.socketRecvHTTP(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 90 | DebugSerial.println("[--- HTTPS Receive Start ---]"); 91 | //DebugSerial.print("[RecvSize] >> "); 92 | //DebugSerial.println(recvSize); 93 | //DebugSerial.print("[Recv"); 94 | //DebugSerial.print(recvCnt++); 95 | //DebugSerial.print("] >> "); 96 | DebugSerial.println(recvBuffer); 97 | do{ 98 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 99 | //DebugSerial.print("[RecvSize] >> "); 100 | //DebugSerial.println(recvSize); 101 | //DebugSerial.print("[Recv"); 102 | //DebugSerial.print(recvCnt++); 103 | //DebugSerial.print("] >> "); 104 | DebugSerial.println(recvBuffer); 105 | } 106 | }while (recvSize > 0); 107 | } else { 108 | DebugSerial.println("Recv Fail!!!"); 109 | } 110 | DebugSerial.println("[--- HTTPS Receive End ---]"); 111 | 112 | /* 6 :TLS TCP-Socket DeActivation */ 113 | if (TYPE1SC.socketDeActivate() == 0) 114 | DebugSerial.println("TCP Socket DeActivation!!!"); 115 | 116 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 117 | DebugSerial.print("Socket Info : "); 118 | DebugSerial.println(sckInfo); 119 | } 120 | 121 | /* 7 :TLS TCP-Socket DeActivation */ 122 | if (TYPE1SC.socketClose() == 0) 123 | DebugSerial.println("TCP Socket Close!!!"); 124 | 125 | /* 8 :Socket All Event Disable */ 126 | if (TYPE1SC.setSocket_EV(0) == 0) 127 | DebugSerial.println("Socket All Event Disable!!!"); 128 | 129 | delay(10000); 130 | } 131 | void loop() { 132 | delay(1000); 133 | } 134 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_TLS_Socket_HTTPS_POST/TYPE1SC_TLS_Socket_HTTPS_POST.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define PROFILE_ID 2 7 | 8 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 9 | 10 | int recvCnt = 0; 11 | 12 | void setup() { 13 | #if defined(ARDUINO_NANO_ESP32) 14 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 15 | #else 16 | M1Serial.begin(115200); 17 | #endif 18 | DebugSerial.begin(115200); 19 | DebugSerial.println("TYPE1SC Module Start!!!"); 20 | 21 | /* Board Reset */ 22 | TYPE1SC.reset(); 23 | delay(2000); 24 | 25 | /* TYPE1SC Module Initialization */ 26 | if (TYPE1SC.init()) { 27 | DebugSerial.println("TYPE1SC Module Error!!!"); 28 | } 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | 37 | /* Enter a DNS address */ 38 | char IPAddr[] = "httpbin.org"; 39 | int _PORT = 443; /* https default port */ 40 | char sckInfo[128]; 41 | char recvBuffer[1500]; 42 | int recvSize = 0; 43 | 44 | /* 0 :Socket All Event Enable */ 45 | if (TYPE1SC.setSocket_EV(1) == 0) 46 | DebugSerial.println("Socket All Event Enable!!!"); 47 | 48 | /* 1 :TCP-Socket Create ( 0:UDP, 1:TCP ) */ 49 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 50 | DebugSerial.println("TCP Socket Create!!!"); 51 | 52 | /* 2 :Socket SSL Enabel */ 53 | int tlsProfileNumber = PROFILE_ID; 54 | if (TYPE1SC.socketSSL(tlsProfileNumber) == 0) { 55 | DebugSerial.println("Socket SSL Enable!!!"); 56 | } 57 | 58 | INFO: 59 | 60 | /* 3 :TLS TCP-Socket Activation */ 61 | if (TYPE1SC.socketActivate() == 0) 62 | DebugSerial.println("TCP Socket Activation!!!"); 63 | 64 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 65 | DebugSerial.print("Socket Info : "); 66 | DebugSerial.println(sckInfo); 67 | 68 | if (strcmp(sckInfo, "ACTIVATED")) { 69 | delay(3000); 70 | goto INFO; 71 | } 72 | } 73 | 74 | /* 4 :TLS TCP-Socket Send Data */ 75 | String wDB = "{\"email\": \"eve.holt@reqres.in\",\"password\": \"pistol\"}"; 76 | 77 | String data = "POST /post HTTP/1.1\r\n"; 78 | data += "Host: httpbin.org\r\n"; 79 | data += "Accept:application/json\r\n"; 80 | data += "Content-Type:application/json\r\n"; 81 | data += "Content-Length:" + String(wDB.length()) + "\r\n"; 82 | data += "\r\n" + wDB; 83 | 84 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 85 | DebugSerial.println("[--- HTTPS Send ---]"); 86 | DebugSerial.println(data); 87 | } else 88 | DebugSerial.println("Send Fail!!!"); 89 | 90 | /* 5 :TLS TCP-Socket Recv Data */ 91 | if (TYPE1SC.socketRecvHTTP(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 92 | DebugSerial.println("[--- HTTPS Receive Start ---]"); 93 | //DebugSerial.print("[RecvSize] >> "); 94 | //DebugSerial.println(recvSize); 95 | //DebugSerial.print("[Recv"); 96 | //DebugSerial.print(recvCnt++); 97 | //DebugSerial.print("] >> "); 98 | DebugSerial.println(recvBuffer); 99 | do{ 100 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 101 | //DebugSerial.print("[RecvSize] >> "); 102 | //DebugSerial.println(recvSize); 103 | //DebugSerial.print("[Recv"); 104 | //DebugSerial.print(recvCnt++); 105 | //DebugSerial.print("] >> "); 106 | DebugSerial.println(recvBuffer); 107 | } 108 | }while (recvSize > 0); 109 | } else { 110 | DebugSerial.println("Recv Fail!!!"); 111 | } 112 | DebugSerial.println("[--- HTTPS Receive End ---]"); 113 | 114 | /* 6 :TLS TCP-Socket DeActivation */ 115 | if (TYPE1SC.socketDeActivate() == 0) 116 | DebugSerial.println("TCP Socket DeActivation!!!"); 117 | 118 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 119 | DebugSerial.print("Socket Info : "); 120 | DebugSerial.println(sckInfo); 121 | } 122 | 123 | /* 7 :TLS TCP-Socket DeActivation */ 124 | if (TYPE1SC.socketClose() == 0) 125 | DebugSerial.println("TCP Socket Close!!!"); 126 | 127 | /* 8 :Socket All Event Disable */ 128 | if (TYPE1SC.setSocket_EV(0) == 0) 129 | DebugSerial.println("Socket All Event Disable!!!"); 130 | 131 | delay(10000); 132 | 133 | } 134 | 135 | void loop() { 136 | delay(1000); 137 | } 138 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_UDP_test/TYPE1SC_UDP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 7 | 8 | void setup() { 9 | pinMode(LED_BUILTIN, OUTPUT); 10 | digitalWrite(LED_BUILTIN, HIGH); 11 | 12 | #if defined(ARDUINO_NANO_ESP32) 13 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 14 | #else 15 | M1Serial.begin(115200); 16 | #endif 17 | DebugSerial.begin(115200); 18 | DebugSerial.println("TYPE1SC Module Start!!!"); 19 | 20 | /* Board Reset */ 21 | TYPE1SC.reset(); 22 | delay(2000); 23 | 24 | /* TYPE1SC Module Initialization */ 25 | if (TYPE1SC.init()) { 26 | DebugSerial.println("TYPE1SC Module Error!!!"); 27 | } 28 | 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | 37 | /* Enter a DNS address to get an IP address */ 38 | char IPAddr[32]; 39 | 40 | while (1) { 41 | 42 | if (TYPE1SC.getIPAddr("echo.mbedcloudtesting.com", IPAddr, 43 | sizeof(IPAddr)) == 0) { 44 | DebugSerial.print("IP Address : "); 45 | DebugSerial.println(IPAddr); 46 | break; 47 | } else { 48 | DebugSerial.println("IP Address Error!!!"); 49 | } 50 | delay(2000); 51 | } 52 | 53 | int _PORT = 7; 54 | char sckInfo[128]; 55 | 56 | /* 1 :UDP Socket Create ( 0:UDP, 1:TCP ) */ 57 | if (TYPE1SC.socketCreate(0, IPAddr, _PORT) == 0) 58 | DebugSerial.println("UDP Socket Create!!!"); 59 | 60 | INFO: 61 | 62 | /* 2 :UDP Socket Activation */ 63 | if (TYPE1SC.socketActivate() == 0) 64 | DebugSerial.println("UDP Socket Activation!!!"); 65 | 66 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 67 | DebugSerial.print("Socket Info : "); 68 | DebugSerial.println(sckInfo); 69 | 70 | if (strcmp(sckInfo, "ACTIVATED")) { 71 | delay(3000); 72 | goto INFO; 73 | } 74 | } 75 | 76 | /* 3 :UDP Socket Send Data */ 77 | char sendBuffer[] = "Hello CodeZoo!!!"; 78 | char recvBuffer[32]; 79 | int recvSize; 80 | 81 | if (TYPE1SC.socketSend(sendBuffer) == 0) { 82 | DebugSerial.print("[Send] >> "); 83 | DebugSerial.println(sendBuffer); 84 | } else 85 | DebugSerial.println("Send Fail!!!"); 86 | 87 | /* 4 :UDP Socket Recv Data */ 88 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 89 | DebugSerial.print("[Recv] >> "); 90 | DebugSerial.println(recvBuffer); 91 | DebugSerial.print("[RecvSize] >> "); 92 | DebugSerial.println(recvSize); 93 | } else { 94 | DebugSerial.println("Recv Fail!!!"); 95 | } 96 | 97 | /* 5 :UDP Socket DeActivation */ 98 | if (TYPE1SC.socketDeActivate() == 0) 99 | DebugSerial.println("UDP Socket DeActivation!!!"); 100 | 101 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 102 | DebugSerial.print("Socket Info : "); 103 | DebugSerial.println(sckInfo); 104 | } 105 | 106 | /* 6 :UDP Socket DeActivation */ 107 | if (TYPE1SC.socketClose() == 0) 108 | DebugSerial.println("UDP Socket Close!!!"); 109 | } 110 | 111 | void loop() { delay(1000); } 112 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_WRITE_HTTPS_CERT/TYPE1SC_WRITE_HTTPS_CERT.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #include "http_credentials.h" 4 | 5 | #define DebugSerial Serial 6 | #define M1Serial Serial1 7 | 8 | #define PROFILE_ID 2 9 | 10 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 11 | 12 | void setup() { 13 | pinMode(LED_BUILTIN, OUTPUT); 14 | digitalWrite(LED_BUILTIN, HIGH); 15 | 16 | #if defined(ARDUINO_NANO_ESP32) 17 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 18 | #else 19 | M1Serial.begin(115200); 20 | #endif 21 | DebugSerial.begin(115200); 22 | DebugSerial.println("TYPE1SC Module Start!!!"); 23 | 24 | /* Board Reset */ 25 | TYPE1SC.reset(); 26 | delay(2000); 27 | 28 | /* TYPE1SC Module Initialization */ 29 | if (TYPE1SC.init()) { 30 | DebugSerial.println("TYPE1SC Module Error!!!"); 31 | } 32 | 33 | /* Network Registration Check */ 34 | while (TYPE1SC.canConnect() != 0) { 35 | DebugSerial.println("Network not Ready !!!"); 36 | delay(2000); 37 | } 38 | 39 | DebugSerial.println("TYPE1SC Module Ready!!!"); 40 | 41 | /* DELETE Certification Profile 1-255 */ 42 | int delProfile = PROFILE_ID; 43 | if (TYPE1SC.delCert(delProfile) == 0) { 44 | DebugSerial.println("Delete Certification in Profile.."); 45 | } 46 | delay(2000); 47 | 48 | /* Write server CA, Don't edit the file name */ 49 | if (TYPE1SC.writeKEY("server.crt", 0, serverCrt) == 0) { 50 | DebugSerial.println("Server CA Write!!!"); 51 | } 52 | delay(5000); 53 | 54 | /* ADD Certification Profile 1-255 */ 55 | int addProfile = PROFILE_ID; 56 | if (TYPE1SC.addHTTPCert(addProfile) == 0) { 57 | DebugSerial.println("ADD Server Certification in Profile.."); 58 | } 59 | } 60 | 61 | void loop() { delay(1000); } 62 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_WRITE_HTTPS_CERT/http_credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTP_CREDENTIALS_H 2 | #define HTTP_CREDENTIALS_H 3 | 4 | const char serverCrt[] = "-----BEGIN CERTIFICATE-----\n" 5 | "MIIEXjCCA0agAwIBAgITB3MSSkvL1E7HtTvq8ZSELToPoTANBgkqhkiG9w0BAQsF\n" 6 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" 7 | "b24gUm9vdCBDQSAxMB4XDTIyMDgyMzIyMjUzMFoXDTMwMDgyMzIyMjUzMFowPDEL\n" 8 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEcMBoGA1UEAxMTQW1hem9uIFJT\n" 9 | "QSAyMDQ4IE0wMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALtDGMZa\n" 10 | "qHneKei1by6+pUPPLljTB143Si6VpEWPc6mSkFhZb/6qrkZyoHlQLbDYnI2D7hD0\n" 11 | "sdzEqfnuAjIsuXQLG3A8TvX6V3oFNBFVe8NlLJHvBseKY88saLwufxkZVwk74g4n\n" 12 | "WlNMXzla9Y5F3wwRHwMVH443xGz6UtGSZSqQ94eFx5X7Tlqt8whi8qCaKdZ5rNak\n" 13 | "+r9nUThOeClqFd4oXych//Rc7Y0eX1KNWHYSI1Nk31mYgiK3JvH063g+K9tHA63Z\n" 14 | "eTgKgndlh+WI+zv7i44HepRZjA1FYwYZ9Vv/9UkC5Yz8/yU65fgjaE+wVHM4e/Yy\n" 15 | "C2osrPWE7gJ+dXMCAwEAAaOCAVowggFWMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYD\n" 16 | "VR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNV\n" 17 | "HQ4EFgQUwDFSzVpQw4J8dHHOy+mc+XrrguIwHwYDVR0jBBgwFoAUhBjMhTTsvAyU\n" 18 | "lC4IWZzHshBOCggwewYIKwYBBQUHAQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8v\n" 19 | "b2NzcC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDov\n" 20 | "L2NydC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8E\n" 21 | "ODA2MDSgMqAwhi5odHRwOi8vY3JsLnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jv\n" 22 | "b3RjYTEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IB\n" 23 | "AQAtTi6Fs0Azfi+iwm7jrz+CSxHH+uHl7Law3MQSXVtR8RV53PtR6r/6gNpqlzdo\n" 24 | "Zq4FKbADi1v9Bun8RY8D51uedRfjsbeodizeBB8nXmeyD33Ep7VATj4ozcd31YFV\n" 25 | "fgRhvTSxNrrTlNpWkUk0m3BMPv8sg381HhA6uEYokE5q9uws/3YkKqRiEz3TsaWm\n" 26 | "JqIRZhMbgAfp7O7FUwFIb7UIspogZSKxPIWJpxiPo3TcBambbVtQOcNRWz5qCQdD\n" 27 | "slI2yayq0n2TXoHyNCLEH8rpsJRVILFsg0jc7BaFrMnF462+ajSehgj12IidNeRN\n" 28 | "4zl+EoNaWdpnWndvSpAEkq2P\n" 29 | "-----END CERTIFICATE-----"; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_WRITE_KEY/TYPE1SC_WRITE_KEY.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #include "aws_credentials.h" 4 | 5 | #define DebugSerial Serial 6 | #define M1Serial Serial1 7 | 8 | TYPE1SC TYPE1SC(M1Serial, DebugSerial); 9 | 10 | void setup() { 11 | pinMode(LED_BUILTIN, OUTPUT); 12 | digitalWrite(LED_BUILTIN, HIGH); 13 | 14 | #if defined(ARDUINO_NANO_ESP32) 15 | M1Serial.begin(115200, SERIAL_8N1, D0, D1); 16 | #else 17 | M1Serial.begin(115200); 18 | #endif 19 | DebugSerial.begin(115200); 20 | DebugSerial.println("TYPE1SC Module Start!!!"); 21 | 22 | /* Board Reset */ 23 | TYPE1SC.reset(); 24 | delay(2000); 25 | 26 | /* TYPE1SC Module Initialization */ 27 | if (TYPE1SC.init()) { 28 | DebugSerial.println("TYPE1SC Module Error!!!"); 29 | } 30 | 31 | /* Network Registration Check */ 32 | while (TYPE1SC.canConnect() != 0) { 33 | DebugSerial.println("Network not Ready !!!"); 34 | delay(2000); 35 | } 36 | 37 | DebugSerial.println("TYPE1SC Module Ready!!!"); 38 | 39 | /* DELETE Certification Profile 1-255 */ 40 | int delProfile = 9; 41 | if (TYPE1SC.delCert(delProfile) == 0) { 42 | DebugSerial.println("Delete Certification Profile!!!"); 43 | } 44 | delay(2000); 45 | 46 | /* Write root CA, Don't edit the file name */ 47 | if (TYPE1SC.writeKEY("rootCA.pem", 0, rootCA) == 0) { 48 | DebugSerial.println("Root CA Write!!!"); 49 | } 50 | delay(5000); 51 | 52 | /* Write client CA, Don't edit the file name */ 53 | if (TYPE1SC.writeKEY("cert.pem.crt", 0, clientCrt) == 0) { 54 | DebugSerial.println("Client CA Write!!!"); 55 | } 56 | delay(5000); 57 | 58 | /* Write client KEY, Don't edit the file name */ 59 | if (TYPE1SC.writeKEY("private.pem.key", 1, clientKey) == 0) { 60 | DebugSerial.println("Client KEY Write!!!"); 61 | } 62 | delay(5000); 63 | 64 | /* ADD Certification Profile 1-255 */ 65 | int addProfile = 9; 66 | if (TYPE1SC.addCert(addProfile) == 0) { 67 | DebugSerial.println("ADD Certification Profile!!!"); 68 | } 69 | } 70 | 71 | void loop() { delay(1000); } 72 | -------------------------------------------------------------------------------- /examples/Arduino_New_Nano/TYPE1SC_WRITE_KEY/aws_credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef AWS_CREDENTIALS_H 2 | #define AWS_CREDENTIALS_H 3 | const char rootCA[] = "-----BEGIN CERTIFICATE-----\n" 4 | "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" 5 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" 6 | "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" 7 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" 8 | "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" 9 | "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" 10 | "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" 11 | "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" 12 | "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" 13 | "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" 14 | "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" 15 | "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" 16 | "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" 17 | "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" 18 | "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" 19 | "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" 20 | "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" 21 | "rqXRfboQnoZsG4q5WTP468SQvvG5\n" 22 | "-----END CERTIFICATE-----"; 23 | 24 | const char clientCrt[] = "-----BEGIN CERTIFICATE-----\n" 25 | "\n" 26 | "\n" 27 | "\n" 28 | "\n" 29 | "\n" 30 | "\n" 31 | "\n" 32 | "\n" 33 | "\n" 34 | "\n" 35 | "\n" 36 | "\n" 37 | "\n" 38 | "\n" 39 | "\n" 40 | "\n" 41 | "\n" 42 | "\n" 43 | "-----END CERTIFICATE-----"; 44 | 45 | const char clientKey[] = "-----BEGIN RSA PRIVATE KEY-----\n" 46 | "\n" 47 | "\n" 48 | "\n" 49 | "\n" 50 | "\n" 51 | "\n" 52 | "\n" 53 | "\n" 54 | "\n" 55 | "\n" 56 | "\n" 57 | "\n" 58 | "\n" 59 | "\n" 60 | "\n" 61 | "\n" 62 | "\n" 63 | "\n" 64 | "\n" 65 | "\n" 66 | "\n" 67 | "\n" 68 | "\n" 69 | "\n" 70 | "\n" 71 | "-----END RSA PRIVATE KEY-----"; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_AWSIOT_SiteWise_demo/TYPE1SC_AWSIOT_SiteWise_demo.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include //https://github.com/GyverLibs/UnixTime 3 | 4 | #define DebugSerial Serial 5 | #define PWR_PIN 5 6 | #define RST_PIN 18 7 | #define WAKEUP_PIN 19 8 | 9 | #define DHTPIN 33 10 | 11 | // AM2302(DHT22) Temperature & Humidity Sensor 12 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 13 | // Uncomment whatever type you're using! 14 | //#define DHTTYPE DHT11 // DHT 11 15 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 16 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 17 | 18 | DHT dht(DHTPIN, DHTTYPE); 19 | UnixTime stamp(9); // Seoul GMT + 09 20 | 21 | HardwareSerial M1Serial(2); // use ESP32 UART2 22 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 23 | 24 | void setup() { 25 | /* DHT22 Sensor Initialization */ 26 | dht.begin(); 27 | delay(2000); 28 | // put your setup code here, to run once: 29 | /* Serial2 Initialization */ 30 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 31 | DebugSerial.begin(115200); 32 | 33 | DebugSerial.println("TYPE1SC Module Start!!!"); 34 | /* Board Reset */ 35 | TYPE1SC.reset(); 36 | delay(2000); 37 | 38 | /* TYPE1SC Module Initialization */ 39 | if (TYPE1SC.init()) { 40 | DebugSerial.println("TYPE1SC Module Error!!!"); 41 | } 42 | 43 | /* Network Registration Check */ 44 | while (TYPE1SC.canConnect() != 0) { 45 | DebugSerial.println("Network not Ready !!!"); 46 | delay(2000); 47 | } 48 | 49 | DebugSerial.println("TYPE1SC Module Ready!!!"); 50 | 51 | /* Device Data EndPoint Address AWS IoT > Settings > Device data endpoint > 52 | * Copy&Paste */ 53 | char _IP[] = "*****.amazonaws.com"; 54 | 55 | char _NodeID[] = "MCU_AI_Things"; 56 | char _Topic[] = "iot/topic"; 57 | char _message[512]; 58 | int tlsProfile = 9; 59 | int conn_timeout = 1200; 60 | float t = 0.0; // Stores temperature value 61 | float h = 0.0; // Stores humidity value 62 | char temp[8]; 63 | char humi[8]; 64 | 65 | /* 1 : Configure AWS_IOT parameters (ID, Address, tlsProfile) */ 66 | if (TYPE1SC.setAWSIOT_CONN(_NodeID, _IP, tlsProfile) == 0) 67 | DebugSerial.println( 68 | "1.Configure AWS_IOT parameter:ID, Address, tls Profile"); 69 | 70 | /* 2 : Configure AWS_IOT parameters (Connection Timeout) */ 71 | if (TYPE1SC.setAWSIOT_TIMEOUT(conn_timeout) == 0) 72 | DebugSerial.println("2.Configure AWS_IOT parameter:Timeout"); 73 | 74 | /* 3 : Enable AWS_IOT events */ 75 | if (TYPE1SC.setAWSIOT_EV(1) == 0) 76 | DebugSerial.println("3.Enable AWS_IOT events"); 77 | 78 | /* 4 : Establish connection */ 79 | if (TYPE1SC.AWSIOT_Connect() == 0) { 80 | DebugSerial.println("4.Establish connection"); 81 | } 82 | 83 | /* 5 : Subscribe (register) to the topic on the endpoint */ 84 | if (TYPE1SC.AWSIOT_SUBSCRIBE(_Topic) == 0) 85 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 86 | 87 | /*Get Temperature & Humidity */ 88 | while (1) { 89 | /* Get DHT22 Sensor */ 90 | t = dht.readTemperature(); 91 | h = dht.readHumidity(); 92 | if (String(t) != "nan" && String(h) != "nan") 93 | break; 94 | else { 95 | DebugSerial.println("case nan ..."); 96 | delay(1000); 97 | } 98 | } 99 | 100 | dtostrf(t, 4, 1, temp); 101 | dtostrf(h, 4, 1, humi); 102 | 103 | // Make Unix TimeStamp 104 | char szTime[32]; 105 | uint32_t _year, _month, _day, _hour, _minute, _second, _tmp; 106 | 107 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 108 | sscanf(szTime, "\"%d/%d/%d,%d:%d:%d+%d\"", &_year, &_month, &_day, &_hour, 109 | &_minute, &_second, &_tmp); 110 | } 111 | 112 | // Set Date Time 113 | _year += 2000; 114 | stamp.setDateTime(_year, _month, _day, _hour, _minute, _second); 115 | 116 | // Get Unix Time 117 | uint32_t unix = stamp.getUnix(); 118 | 119 | memset(_message, 0x0, sizeof(_message)); 120 | sprintf(_message, 121 | "{\\\"timeInSeconds\\\":\\\"%lu\\\",\\\"Temperature\\\":\\\"%s\\\"," 122 | "\\\"Humidity\\\":\\\"%s\\\"}", 123 | unix, temp, humi); 124 | 125 | /* 6 : Publish data to broker */ 126 | if (TYPE1SC.AWSIOT_Publish(_Topic, _message) == 0) 127 | DebugSerial.println("6.Publish data to broker"); 128 | 129 | /* 7 : UnSubscribe to the topic on the endpoint */ 130 | if (TYPE1SC.AWSIOT_UnSUBSCRIBE(_Topic) == 0) { 131 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 132 | } 133 | 134 | /* 8 : Disconnect AWS_IOT Service */ 135 | if (TYPE1SC.AWSIOT_DisConnect() == 0) 136 | DebugSerial.println("8.Disconnect AWS_IOT Service"); 137 | 138 | /* 9 : Disable AWS_IOT events */ 139 | if (TYPE1SC.setAWSIOT_EV(0) == 0) 140 | DebugSerial.println("9.Disable AWS_IOT events"); 141 | } 142 | 143 | void loop() { delay(1000); } 144 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_AWSIOT_test/TYPE1SC_AWSIOT_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | #define DHTPIN 33 9 | 10 | // AM2302(DHT22) Temperature & Humidity Sensor 11 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 12 | // Uncomment whatever type you're using! 13 | //#define DHTTYPE DHT11 // DHT 11 14 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 15 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 16 | 17 | DHT dht(DHTPIN, DHTTYPE); 18 | 19 | HardwareSerial M1Serial(2); // use ESP32 UART2 20 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 21 | 22 | void setup() { 23 | dht.begin(); 24 | delay(2000); 25 | // put your setup code here, to run once: 26 | /* Serial2 Initialization */ 27 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 28 | DebugSerial.begin(115200); 29 | 30 | DebugSerial.println("TYPE1SC Module Start!!!"); 31 | /* Board Reset */ 32 | TYPE1SC.reset(); 33 | delay(2000); 34 | 35 | /* TYPE1SC Module Initialization */ 36 | if (TYPE1SC.init()) { 37 | DebugSerial.println("TYPE1SC Module Error!!!"); 38 | } 39 | 40 | /* Network Registration Check */ 41 | while (TYPE1SC.canConnect() != 0) { 42 | DebugSerial.println("Network not Ready !!!"); 43 | delay(2000); 44 | } 45 | 46 | DebugSerial.println("TYPE1SC Module Ready!!!"); 47 | 48 | /* Device Data EndPoint Address AWS IoT > Settings > Device data endpoint > 49 | * Copy&Paste */ 50 | char _IP[] = "*****.amazonaws.com"; 51 | 52 | char _NodeID[] = "Murata_Node01"; 53 | char _Topic[] = "sdkTest/sub"; 54 | char _message[64]; 55 | int tlsProfile = 9; 56 | int conn_timeout = 1200; 57 | float t = 0.0; // Stores temperature value 58 | float h = 0.0; // Stores humidity value 59 | char temp[8]; 60 | char humi[8]; 61 | 62 | /* 1 : Configure AWS_IOT parameters (ID, Address, tlsProfile) */ 63 | if (TYPE1SC.setAWSIOT_CONN(_NodeID, _IP, tlsProfile) == 0) 64 | DebugSerial.println( 65 | "1.Configure AWS_IOT parameter:ID, Address, tls Profile"); 66 | 67 | /* 2 : Configure AWS_IOT parameters (Connection Timeout) */ 68 | if (TYPE1SC.setAWSIOT_TIMEOUT(conn_timeout) == 0) 69 | DebugSerial.println("2.Configure AWS_IOT parameter:Timeout"); 70 | 71 | /* 3 : Enable AWS_IOT events */ 72 | if (TYPE1SC.setAWSIOT_EV(1) == 0) 73 | DebugSerial.println("3.Enable AWS_IOT events"); 74 | 75 | /* 4 : Establish connection */ 76 | if (TYPE1SC.AWSIOT_Connect() == 0) { 77 | DebugSerial.println("4.Establish connection"); 78 | } 79 | 80 | /* 5 : Subscribe (register) to the topic on the endpoint */ 81 | if (TYPE1SC.AWSIOT_SUBSCRIBE(_Topic) == 0) 82 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 83 | 84 | /*Get Temperature & Humidity */ 85 | while (1) { 86 | /* Get DHT22 Sensor */ 87 | t = dht.readTemperature(); 88 | h = dht.readHumidity(); 89 | if (String(t) != "nan" && String(h) != "nan") 90 | break; 91 | else { 92 | DebugSerial.println("case nan ..."); 93 | delay(1000); 94 | } 95 | } 96 | 97 | dtostrf(t, 4, 1, temp); 98 | dtostrf(h, 4, 1, humi); 99 | 100 | memset(_message, 0x0, sizeof(_message)); 101 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 102 | 103 | /* 6 : Publish data to broker */ 104 | if (TYPE1SC.AWSIOT_Publish(_Topic, _message) == 0) 105 | DebugSerial.println("6.Publish data to broker"); 106 | 107 | /* 7 : UnSubscribe to the topic on the endpoint */ 108 | if (TYPE1SC.AWSIOT_UnSUBSCRIBE(_Topic) == 0) { 109 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 110 | } 111 | 112 | /* 8 : Disconnect AWS_IOT Service */ 113 | if (TYPE1SC.AWSIOT_DisConnect() == 0) 114 | DebugSerial.println("8.Disconnect AWS_IOT Service"); 115 | 116 | /* 9 : Disable AWS_IOT events */ 117 | if (TYPE1SC.setAWSIOT_EV(0) == 0) 118 | DebugSerial.println("9.Disable AWS_IOT events"); 119 | } 120 | 121 | void loop() { delay(1000); } 122 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_Basic_test/TYPE1SC_Basic_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | HardwareSerial M1Serial(2); // use ESP32 UART2 9 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 10 | 11 | void setup() { 12 | 13 | // put your setup code here, to run once: 14 | /* Serial2 Initialization */ 15 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 16 | DebugSerial.begin(115200); 17 | 18 | DebugSerial.println("TYPE1SC Module Start!!!"); 19 | /* Board Reset */ 20 | TYPE1SC.reset(); 21 | delay(2000); 22 | 23 | /* TYPE1SC Module Initialization */ 24 | if (TYPE1SC.init()) { 25 | DebugSerial.println("TYPE1SC Module Error!!!"); 26 | } 27 | 28 | /* Network Registration Check */ 29 | while (TYPE1SC.canConnect() != 0) { 30 | DebugSerial.println("Network not Ready !!!"); 31 | delay(2000); 32 | } 33 | 34 | DebugSerial.println("TYPE1SC Module Ready!!!"); 35 | } 36 | 37 | void loop() { 38 | /*** TYPE1SC Basic Test Code ***/ 39 | /* SIM Card Check */ 40 | if (!TYPE1SC.chkSIM()) { 41 | DebugSerial.println("SIM Card OK!!!"); 42 | } 43 | delay(1000); 44 | 45 | /* Get Phone Number */ 46 | char szCIMI[16]; 47 | if (TYPE1SC.getCIMI(szCIMI, sizeof(szCIMI)) == 0) { 48 | DebugSerial.print("CIMI : "); 49 | DebugSerial.println(szCIMI); 50 | } 51 | delay(1000); 52 | 53 | char szIMEI[16]; 54 | if (TYPE1SC.getIMEI(szIMEI, sizeof(szIMEI)) == 0) { 55 | DebugSerial.print("IMEI : "); 56 | DebugSerial.println(szIMEI); 57 | } 58 | delay(1000); 59 | 60 | /* Get Fimrware version */ 61 | char szCGMR[20]; 62 | if (TYPE1SC.getCGMR(szCGMR, sizeof(szCGMR)) == 0) { 63 | DebugSerial.print("CGMR : "); 64 | DebugSerial.println(szCGMR); 65 | } 66 | delay(1000); 67 | 68 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 69 | char szTime[32]; 70 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 71 | DebugSerial.print("Time : "); 72 | DebugSerial.println(szTime); 73 | } 74 | delay(1000); 75 | 76 | /* Get RSSI */ 77 | int rssi; 78 | if (TYPE1SC.getRSSI(&rssi) == 0) { 79 | DebugSerial.print("RSSI : "); 80 | DebugSerial.println(rssi); 81 | } 82 | delay(1000); 83 | 84 | /* Get RSRP */ 85 | int rsrp; 86 | if (TYPE1SC.getRSRP(&rsrp) == 0) { 87 | DebugSerial.print("RSRP : "); 88 | DebugSerial.println(rsrp); 89 | } 90 | delay(1000); 91 | 92 | /* Get RSRQ */ 93 | int rsrq; 94 | if (TYPE1SC.getRSRQ(&rsrq) == 0) { 95 | DebugSerial.print("RSRQ : "); 96 | DebugSerial.println(rsrq); 97 | } 98 | delay(1000); 99 | 100 | /* Get SINR */ 101 | int sinr; 102 | if (TYPE1SC.getSINR(&sinr) == 0) { 103 | DebugSerial.print("SINR : "); 104 | DebugSerial.println(sinr); 105 | } 106 | delay(1000); 107 | 108 | /* Get TX Power */ 109 | char txPower[64]; 110 | if (TYPE1SC.getTxPower(txPower, sizeof(txPower)) == 0) { 111 | DebugSerial.print("TX Power : "); 112 | DebugSerial.println(txPower); 113 | } 114 | delay(1000); 115 | } 116 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_GET_UnixTime/TYPE1SC_GET_UnixTime.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include //https://github.com/GyverLibs/UnixTime 3 | 4 | #define DebugSerial Serial 5 | #define PWR_PIN 5 6 | #define RST_PIN 18 7 | #define WAKEUP_PIN 19 8 | 9 | UnixTime stamp(9); // Seoul GMT + 09 10 | HardwareSerial M1Serial(2); // use ESP32 UART2 11 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 12 | 13 | void setup() { 14 | 15 | // put your setup code here, to run once: 16 | /* Serial2 Initialization */ 17 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 18 | DebugSerial.begin(115200); 19 | 20 | DebugSerial.println("TYPE1SC Module Start!!!"); 21 | 22 | /* Board Reset(Using ATCmd) */ 23 | TYPE1SC.reset(); 24 | delay(2000); 25 | 26 | /* TYPE1SC Module Initialization */ 27 | if (TYPE1SC.init()) { 28 | DebugSerial.println("TYPE1SC Module Error!!!"); 29 | } 30 | 31 | /* Network Registration Check */ 32 | while (TYPE1SC.canConnect() != 0) { 33 | DebugSerial.println("Network not Ready !!!"); 34 | delay(2000); 35 | } 36 | 37 | DebugSerial.println("TYPE1SC Module Ready!!!"); 38 | } 39 | 40 | void loop() { 41 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 42 | char szTime[32]; 43 | uint32_t _year, _month, _day, _hour, _minute, _second, _tmp; 44 | 45 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 46 | DebugSerial.print("Time : "); 47 | DebugSerial.println(szTime); 48 | sscanf(szTime, "\"%d/%d/%d,%d:%d:%d+%d\"", &_year, &_month, &_day, &_hour, 49 | &_minute, &_second, &_tmp); 50 | /* Debug */ 51 | DebugSerial.println(_year); 52 | DebugSerial.println(_month); 53 | DebugSerial.println(_day); 54 | DebugSerial.println(_hour); 55 | DebugSerial.println(_minute); 56 | DebugSerial.println(_second); 57 | } 58 | // Set Date Time 59 | _year += 2000; 60 | stamp.setDateTime(_year, _month, _day, _hour, _minute, _second); 61 | 62 | // Get Unix Time 63 | uint32_t unix = stamp.getUnix(); 64 | DebugSerial.println(unix); 65 | 66 | // ========== UNIX to date and time =========== 67 | // convert unix to date and time 68 | // getDateTime(unix stamp) runs ~500 us on AVR 69 | // https://www.unixtimestamp.com/index.php 70 | stamp.getDateTime(unix); 71 | 72 | // pick up like this 73 | DebugSerial.println(stamp.year); 74 | DebugSerial.println(stamp.month); 75 | DebugSerial.println(stamp.day); 76 | DebugSerial.println(stamp.hour); 77 | DebugSerial.println(stamp.minute); 78 | DebugSerial.println(stamp.second); 79 | 80 | delay(1000); 81 | } 82 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_HTTP_test/TYPE1SC_HTTP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | #define DHTPIN 33 9 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 10 | // Uncomment whatever type you're using! 11 | //#define DHTTYPE DHT11 // DHT 11 12 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 13 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 14 | 15 | DHT dht(DHTPIN, DHTTYPE); 16 | 17 | HardwareSerial M1Serial(2); // use ESP32 UART2 18 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 19 | 20 | void setup() { 21 | dht.begin(); 22 | // put your setup code here, to run once: 23 | /* Serial2 Initialization */ 24 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 25 | DebugSerial.begin(115200); 26 | 27 | DebugSerial.println("TYPE1SC Module Start!!!"); 28 | /* Board Reset */ 29 | TYPE1SC.reset(); 30 | delay(2000); 31 | 32 | /* TYPE1SC Module Initialization */ 33 | if (TYPE1SC.init()) { 34 | DebugSerial.println("TYPE1SC Module Error!!!"); 35 | } 36 | 37 | /* Network Registration Check */ 38 | while (TYPE1SC.canConnect() != 0) { 39 | DebugSerial.println("Network not Ready !!!"); 40 | delay(2000); 41 | } 42 | 43 | DebugSerial.println("TYPE1SC Module Ready!!!"); 44 | 45 | /* Enter a DNS address to get an IP address */ 46 | char IPAddr[32]; 47 | 48 | while (1) { 49 | 50 | if (TYPE1SC.getIPAddr("api.thingspeak.com", IPAddr, sizeof(IPAddr)) == 0) { 51 | DebugSerial.print("IP Address : "); 52 | DebugSerial.println(IPAddr); 53 | break; 54 | } else { 55 | DebugSerial.println("IP Address Error!!!"); 56 | } 57 | delay(2000); 58 | } 59 | 60 | int _PORT = 80; 61 | char sckInfo[128]; 62 | char recvBuffer[700]; 63 | int recvSize; 64 | 65 | String WApiKey = "****************"; // Thing Speak Write API Key 16Character 66 | float temp = 0.0; 67 | float humi = 0.0; 68 | String fieldTemp = "field1"; // Air temperature 69 | String fieldHumi = "field2"; // Air humidity 70 | 71 | /*Get Temperature & Humidity */ 72 | while (1) { 73 | /* Get DHT22 Sensor */ 74 | temp = dht.readTemperature(); 75 | humi = dht.readHumidity(); 76 | if (String(temp) != "nan" && String(humi) != "nan") 77 | break; 78 | else { 79 | DebugSerial.println("case nan ..."); 80 | delay(1000); 81 | } 82 | } 83 | 84 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 85 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 86 | DebugSerial.println("TCP Socket Create!!!"); 87 | 88 | INFO: 89 | 90 | /* 2 :TCP Socket Activation */ 91 | if (TYPE1SC.socketActivate() == 0) 92 | DebugSerial.println("TCP Socket Activation!!!"); 93 | 94 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 95 | DebugSerial.print("Socket Info : "); 96 | DebugSerial.println(sckInfo); 97 | 98 | if (strcmp(sckInfo, "ACTIVATED")) { 99 | delay(3000); 100 | goto INFO; 101 | } 102 | } 103 | 104 | /* 3 :TCP Socket Send Data */ 105 | String data = "GET /update"; 106 | data += "?api_key=" + WApiKey + "&" + fieldTemp + "=" + String(temp) + "&" + 107 | fieldHumi + "=" + String(humi); 108 | data += " HTTP/1.1\r\n"; 109 | data += "Host: api.thingspeak.com\r\n"; 110 | data += "Connection: close\r\n\r\n"; 111 | 112 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 113 | DebugSerial.print("[HTTP Send] >> "); 114 | DebugSerial.println(data); 115 | } else 116 | DebugSerial.println("Send Fail!!!"); 117 | 118 | /* 4 :TCP Socket Recv Data */ 119 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 120 | DebugSerial.print("[Recv] >> "); 121 | DebugSerial.println(recvBuffer); 122 | DebugSerial.print("[RecvSize] >> "); 123 | DebugSerial.println(recvSize); 124 | } else { 125 | DebugSerial.println("Recv Fail!!!"); 126 | } 127 | 128 | /* 5 :TCP Socket DeActivation */ 129 | if (TYPE1SC.socketDeActivate() == 0) 130 | DebugSerial.println("TCP Socket DeActivation!!!"); 131 | 132 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 133 | DebugSerial.print("Socket Info : "); 134 | DebugSerial.println(sckInfo); 135 | } 136 | 137 | /* 6 :TCP Socket DeActivation */ 138 | if (TYPE1SC.socketClose() == 0) 139 | DebugSerial.println("TCP Socket Close!!!"); 140 | } 141 | 142 | void loop() { delay(1000); } 143 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_MQTT_test/TYPE1SC_MQTT_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | #define DHTPIN 33 9 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 10 | // Uncomment whatever type you're using! 11 | //#define DHTTYPE DHT11 // DHT 11 12 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 13 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 14 | 15 | DHT dht(DHTPIN, DHTTYPE); 16 | HardwareSerial M1Serial(2); // use ESP32 UART2 17 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 18 | 19 | void setup() { 20 | dht.begin(); 21 | // put your setup code here, to run once: 22 | /* Serial2 Initialization */ 23 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 24 | DebugSerial.begin(115200); 25 | 26 | DebugSerial.println("TYPE1SC Module Start!!!"); 27 | /* Board Reset */ 28 | TYPE1SC.reset(); 29 | delay(2000); 30 | 31 | /* TYPE1SC Module Initialization */ 32 | if (TYPE1SC.init()) { 33 | DebugSerial.println("TYPE1SC Module Error!!!"); 34 | } 35 | 36 | /* Network Registration Check */ 37 | while (TYPE1SC.canConnect() != 0) { 38 | DebugSerial.println("Network not Ready !!!"); 39 | delay(2000); 40 | } 41 | 42 | DebugSerial.println("TYPE1SC Module Ready!!!"); 43 | 44 | char _IP[] = "broker.hivemq.com"; 45 | char _NodeID[] = "Cellular_node"; 46 | char _Topic[] = "type1sc/0/test"; 47 | char _message[64]; 48 | uint32_t conn_timeout = 1200; 49 | float t = 0.0; 50 | float h = 0.0; 51 | char temp[8]; // Stores temperature value 52 | char humi[8]; // Stores humidity value 53 | 54 | /* 55 | * qos : 0 - at most one delivery (default) 56 | * 1 - Delivered at least once 57 | * 2 - Exactly one delivery 58 | */ 59 | int qos = 0; 60 | 61 | /* 1 : Enable MQTT events */ 62 | if (TYPE1SC.setMQTT_EV(1) == 0) 63 | DebugSerial.println("1.Enable MQTT events"); 64 | 65 | /* 2 : Configure node parameters (ID, Address) */ 66 | if (TYPE1SC.setMQTT_NODES(_NodeID, _IP) == 0) 67 | DebugSerial.println("2.Configure node parameter:ID, Address"); 68 | 69 | /* 3 : Configure node parameters (Connection Timeout) */ 70 | if (TYPE1SC.setMQTT_TIMEOUT(conn_timeout) == 0) 71 | DebugSerial.println("3.Configure node parameter:Timeout"); 72 | 73 | /* 4 : Establish connection */ 74 | if (TYPE1SC.MQTT_Connect() == 0) 75 | DebugSerial.println("4.Establish connection"); 76 | 77 | /* 5 : Subscribe (register) to the topic on the endpoint */ 78 | if (TYPE1SC.MQTT_SUBSCRIBE(qos, _Topic) == 0) 79 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 80 | 81 | /*Get Temperature & Humidity */ 82 | while (1) { 83 | /* Get DHT22 Sensor */ 84 | t = dht.readTemperature(); 85 | h = dht.readHumidity(); 86 | if (String(t) != "nan" && String(h) != "nan") 87 | break; 88 | else { 89 | DebugSerial.println("case nan ..."); 90 | delay(1000); 91 | } 92 | } 93 | 94 | dtostrf(t, 4, 1, temp); 95 | dtostrf(h, 4, 1, humi); 96 | 97 | memset(_message, 0x0, sizeof(_message)); 98 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 99 | /* 6 : Publish data to broker */ 100 | if (TYPE1SC.MQTT_Publish(qos, _Topic, strlen(_message), _message) == 0) 101 | DebugSerial.println("6.Publish data to broker"); 102 | 103 | /* 7 : UnSubscribe to the topic on the endpoint */ 104 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 105 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 106 | } else { 107 | delay(1000); 108 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 109 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 110 | } 111 | } 112 | /* 8 : Disconnect MQTT Server */ 113 | if (TYPE1SC.MQTT_DisConnect() == 0) 114 | DebugSerial.println("8.Disconnect MQTT Server"); 115 | 116 | /* 0 : Disable MQTT events */ 117 | if (TYPE1SC.setMQTT_EV(0) == 0) 118 | DebugSerial.println("9.Disable MQTT events"); 119 | } 120 | 121 | void loop() { delay(1000); } 122 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_SET_APN/TYPE1SC_SET_APN.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | HardwareSerial M1Serial(2); // use ESP32 UART2 9 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 10 | 11 | void setup() { 12 | 13 | // put your setup code here, to run once: 14 | /* Serial2 Initialization */ 15 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 16 | DebugSerial.begin(115200); 17 | 18 | DebugSerial.println("TYPE1SC Module Start!!!"); 19 | /* Board Reset */ 20 | TYPE1SC.reset(); 21 | delay(2000); 22 | 23 | /* TYPE1SC Module Initialization */ 24 | if (TYPE1SC.init()) { 25 | DebugSerial.println("TYPE1SC Module Error!!!"); 26 | } 27 | 28 | /* Network Disable */ 29 | if (TYPE1SC.setCFUN(0) == 0) { 30 | DebugSerial.println("TYPE1SC Network Disable!!!"); 31 | } 32 | 33 | delay(1000); 34 | 35 | char *apnAddr = "simplio.apn"; /* Vodafone Global IoT SIM APN */ 36 | 37 | if (TYPE1SC.setAPN(apnAddr) == 0) { 38 | DebugSerial.println("TYPE1SC Set APN Address !!!"); 39 | } 40 | 41 | /* Board Reset */ 42 | TYPE1SC.reset(); 43 | 44 | delay(2000); 45 | 46 | /* TYPE1SC Module Initialization */ 47 | if (TYPE1SC.init()) { 48 | DebugSerial.println("TYPE1SC Module Error!!!"); 49 | } 50 | 51 | DebugSerial.println("TYPE1SC Module Ready!!!"); 52 | 53 | char apn[128]; 54 | if (TYPE1SC.getAPN(apn, sizeof(apn)) == 0) { 55 | DebugSerial.print("GET APN Address: "); 56 | DebugSerial.println(apn); 57 | } 58 | } 59 | 60 | void loop() { delay(1000); } 61 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_TCP_test/TYPE1SC_TCP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | HardwareSerial M1Serial(2); // use ESP32 UART2 9 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 10 | 11 | void setup() { 12 | 13 | // put your setup code here, to run once: 14 | /* Serial2 Initialization */ 15 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 16 | DebugSerial.begin(115200); 17 | 18 | DebugSerial.println("TYPE1SC Module Start!!!"); 19 | /* Board Reset */ 20 | TYPE1SC.reset(); 21 | delay(2000); 22 | 23 | /* TYPE1SC Module Initialization */ 24 | if (TYPE1SC.init()) { 25 | DebugSerial.println("TYPE1SC Module Error!!!"); 26 | } 27 | 28 | /* Network Registration Check */ 29 | while (TYPE1SC.canConnect() != 0) { 30 | DebugSerial.println("Network not Ready !!!"); 31 | delay(2000); 32 | } 33 | 34 | DebugSerial.println("TYPE1SC Module Ready!!!"); 35 | 36 | /* Enter a DNS address to get an IP address */ 37 | char IPAddr[32]; 38 | 39 | while (1) { 40 | 41 | if (TYPE1SC.getIPAddr("echo.mbedcloudtesting.com", IPAddr, 42 | sizeof(IPAddr)) == 0) { 43 | DebugSerial.print("IP Address : "); 44 | DebugSerial.println(IPAddr); 45 | break; 46 | } else { 47 | DebugSerial.println("IP Address Error!!!"); 48 | } 49 | delay(2000); 50 | } 51 | 52 | int _PORT = 7; 53 | char sckInfo[128]; 54 | 55 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 56 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 57 | DebugSerial.println("TCP Socket Create!!!"); 58 | 59 | INFO: 60 | 61 | /* 2 :TCP Socket Activation */ 62 | if (TYPE1SC.socketActivate() == 0) 63 | DebugSerial.println("TCP Socket Activation!!!"); 64 | 65 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 66 | DebugSerial.print("Socket Info : "); 67 | DebugSerial.println(sckInfo); 68 | 69 | if (strcmp(sckInfo, "ACTIVATED")) { 70 | delay(3000); 71 | goto INFO; 72 | } 73 | } 74 | 75 | /* 3 :TCP Socket Send Data */ 76 | char sendBuffer[] = "Hello CodeZoo!!!"; 77 | char recvBuffer[32]; 78 | int recvSize; 79 | 80 | if (TYPE1SC.socketSend(sendBuffer) == 0) { 81 | DebugSerial.print("[Send] >> "); 82 | DebugSerial.println(sendBuffer); 83 | } else 84 | DebugSerial.println("Send Fail!!!"); 85 | 86 | /* 4 :TCP Socket Recv Data */ 87 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 88 | DebugSerial.print("[Recv] >> "); 89 | DebugSerial.println(recvBuffer); 90 | DebugSerial.print("[RecvSize] >> "); 91 | DebugSerial.println(recvSize); 92 | } else { 93 | DebugSerial.println("Recv Fail!!!"); 94 | } 95 | 96 | /* 5 :TCP Socket DeActivation */ 97 | if (TYPE1SC.socketDeActivate() == 0) 98 | DebugSerial.println("TCP Socket DeActivation!!!"); 99 | 100 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 101 | DebugSerial.print("Socket Info : "); 102 | DebugSerial.println(sckInfo); 103 | } 104 | 105 | /* 6 :TCP Socket DeActivation */ 106 | if (TYPE1SC.socketClose() == 0) 107 | DebugSerial.println("TCP Socket Close!!!"); 108 | } 109 | 110 | void loop() { delay(1000); } 111 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_TLS_Socket_HTTPS_GET/TYPE1SC_TLS_Socket_HTTPS_GET.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | #define PROFILE_ID 2 9 | 10 | HardwareSerial M1Serial(2); // use ESP32 UART2 11 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 12 | 13 | int recvCnt = 0; 14 | 15 | void setup() { 16 | 17 | // put your setup code here, to run once: 18 | /* Serial2 Initialization */ 19 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 20 | DebugSerial.begin(115200); 21 | DebugSerial.println("TYPE1SC Module Start!!!"); 22 | 23 | /* Board Reset */ 24 | TYPE1SC.reset(); 25 | delay(2000); 26 | 27 | /* TYPE1SC Module Initialization */ 28 | if (TYPE1SC.init()) { 29 | DebugSerial.println("TYPE1SC Module Error!!!"); 30 | } 31 | /* Network Registration Check */ 32 | while (TYPE1SC.canConnect() != 0) { 33 | DebugSerial.println("Network not Ready !!!"); 34 | delay(2000); 35 | } 36 | DebugSerial.println("TYPE1SC Module Ready!!!"); 37 | 38 | /* Enter a DNS address */ 39 | char IPAddr[] = "httpbin.org"; 40 | int _PORT = 443; /* https default port */ 41 | char sckInfo[128]; 42 | char recvBuffer[1500]; 43 | int recvSize = 0; 44 | 45 | /* 0 :Socket All Event Enable */ 46 | if (TYPE1SC.setSocket_EV(1) == 0) { 47 | DebugSerial.println("Socket All Event Enable!!!"); 48 | } 49 | 50 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 51 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) { 52 | DebugSerial.println("TCP Socket Create!!!"); 53 | } 54 | 55 | /* 2 :Socket SSL Enabel */ 56 | int tlsProfileNumber = PROFILE_ID; 57 | if (TYPE1SC.socketSSL(tlsProfileNumber) == 0) { 58 | DebugSerial.println("Socket SSL Enable!!!"); 59 | } 60 | 61 | INFO: 62 | /* 3 :TLS TCP-Socket Activation */ 63 | if (TYPE1SC.socketActivate() == 0) { 64 | DebugSerial.println("TCP Socket Activation!!!"); 65 | } 66 | 67 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 68 | DebugSerial.print("Socket Info : "); 69 | DebugSerial.println(sckInfo); 70 | if (strcmp(sckInfo, "ACTIVATED")) { 71 | TYPE1SC.socketDeActivate(); 72 | delay(3000); 73 | goto INFO; 74 | } 75 | } 76 | 77 | /* 4 :TLS TCP-Socket Send Data */ 78 | String data = "GET /get HTTP/1.1\r\n"; 79 | data += "Host: httpbin.org\r\n\r\n"; 80 | 81 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 82 | DebugSerial.println("[--- HTTPS Send ---]"); 83 | DebugSerial.println(data); 84 | } else 85 | DebugSerial.println("Send Fail!!!"); 86 | 87 | /* 5 :TLS TCP-Socket Receive Data */ 88 | if (TYPE1SC.socketRecvHTTP(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 89 | DebugSerial.println("[--- HTTPS Receive Start ---]"); 90 | //DebugSerial.print("[RecvSize] >> "); 91 | //DebugSerial.println(recvSize); 92 | //DebugSerial.print("[Recv"); 93 | //DebugSerial.print(recvCnt++); 94 | //DebugSerial.print("] >> "); 95 | DebugSerial.println(recvBuffer); 96 | do{ 97 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 98 | //DebugSerial.print("[RecvSize] >> "); 99 | //DebugSerial.println(recvSize); 100 | //DebugSerial.print("[Recv"); 101 | //DebugSerial.print(recvCnt++); 102 | //DebugSerial.print("] >> "); 103 | DebugSerial.println(recvBuffer); 104 | } 105 | }while (recvSize > 0); 106 | } else { 107 | DebugSerial.println("Recv Fail!!!"); 108 | } 109 | DebugSerial.println("[--- HTTPS Receive End ---]"); 110 | 111 | /* 6 :TLS TCP-Socket DeActivation */ 112 | if (TYPE1SC.socketDeActivate() == 0) 113 | DebugSerial.println("TCP Socket DeActivation!!!"); 114 | 115 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 116 | DebugSerial.print("Socket Info : "); 117 | DebugSerial.println(sckInfo); 118 | } 119 | 120 | /* 7 :TLS TCP-Socket DeActivation */ 121 | if (TYPE1SC.socketClose() == 0) 122 | DebugSerial.println("TCP Socket Close!!!"); 123 | 124 | /* 8 :Socket All Event Disable */ 125 | if (TYPE1SC.setSocket_EV(0) == 0) 126 | DebugSerial.println("Socket All Event Disable!!!"); 127 | 128 | delay(10000); 129 | } 130 | void loop() { 131 | delay(1000); 132 | } 133 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_TLS_Socket_HTTPS_POST/TYPE1SC_TLS_Socket_HTTPS_POST.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | #define PROFILE_ID 2 9 | 10 | HardwareSerial M1Serial(2); // use ESP32 UART2 11 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 12 | 13 | int recvCnt = 0; 14 | 15 | void setup() { 16 | /* Serial2 Initialization */ 17 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 18 | DebugSerial.begin(115200); 19 | DebugSerial.println("TYPE1SC Module Start!!!"); 20 | 21 | /* Board Reset */ 22 | TYPE1SC.reset(); 23 | delay(2000); 24 | 25 | /* TYPE1SC Module Initialization */ 26 | if (TYPE1SC.init()) { 27 | DebugSerial.println("TYPE1SC Module Error!!!"); 28 | } 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | 37 | /* Enter a DNS address */ 38 | char IPAddr[] = "httpbin.org"; 39 | int _PORT = 443; /* https default port */ 40 | char sckInfo[128]; 41 | char recvBuffer[1500]; 42 | int recvSize = 0; 43 | 44 | /* 0 :Socket All Event Enable */ 45 | if (TYPE1SC.setSocket_EV(1) == 0) 46 | DebugSerial.println("Socket All Event Enable!!!"); 47 | 48 | /* 1 :TCP-Socket Create ( 0:UDP, 1:TCP ) */ 49 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 50 | DebugSerial.println("TCP Socket Create!!!"); 51 | 52 | /* 2 :Socket SSL Enabel */ 53 | int tlsProfileNumber = PROFILE_ID; 54 | if (TYPE1SC.socketSSL(tlsProfileNumber) == 0) { 55 | DebugSerial.println("Socket SSL Enable!!!"); 56 | } 57 | 58 | INFO: 59 | 60 | /* 3 :TLS TCP-Socket Activation */ 61 | if (TYPE1SC.socketActivate() == 0) 62 | DebugSerial.println("TCP Socket Activation!!!"); 63 | 64 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 65 | DebugSerial.print("Socket Info : "); 66 | DebugSerial.println(sckInfo); 67 | 68 | if (strcmp(sckInfo, "ACTIVATED")) { 69 | delay(3000); 70 | goto INFO; 71 | } 72 | } 73 | 74 | /* 4 :TLS TCP-Socket Send Data */ 75 | String wDB = "{\"email\": \"eve.holt@reqres.in\",\"password\": \"pistol\"}"; 76 | 77 | String data = "POST /post HTTP/1.1\r\n"; 78 | data += "Host: httpbin.org\r\n"; 79 | data += "Accept:application/json\r\n"; 80 | data += "Content-Type:application/json\r\n"; 81 | data += "Content-Length:" + String(wDB.length()) + "\r\n"; 82 | data += "\r\n" + wDB; 83 | 84 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 85 | DebugSerial.println("[--- HTTPS Send ---]"); 86 | DebugSerial.println(data); 87 | } else 88 | DebugSerial.println("Send Fail!!!"); 89 | 90 | /* 5 :TLS TCP-Socket Recv Data */ 91 | if (TYPE1SC.socketRecvHTTP(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 92 | DebugSerial.println("[--- HTTPS Receive Start ---]"); 93 | //DebugSerial.print("[RecvSize] >> "); 94 | //DebugSerial.println(recvSize); 95 | //DebugSerial.print("[Recv"); 96 | //DebugSerial.print(recvCnt++); 97 | //DebugSerial.print("] >> "); 98 | DebugSerial.println(recvBuffer); 99 | do{ 100 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 101 | //DebugSerial.print("[RecvSize] >> "); 102 | //DebugSerial.println(recvSize); 103 | //DebugSerial.print("[Recv"); 104 | //DebugSerial.print(recvCnt++); 105 | //DebugSerial.print("] >> "); 106 | DebugSerial.println(recvBuffer); 107 | } 108 | }while (recvSize > 0); 109 | } else { 110 | DebugSerial.println("Recv Fail!!!"); 111 | } 112 | DebugSerial.println("[--- HTTPS Receive End ---]"); 113 | 114 | /* 6 :TLS TCP-Socket DeActivation */ 115 | if (TYPE1SC.socketDeActivate() == 0) 116 | DebugSerial.println("TCP Socket DeActivation!!!"); 117 | 118 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 119 | DebugSerial.print("Socket Info : "); 120 | DebugSerial.println(sckInfo); 121 | } 122 | 123 | /* 7 :TLS TCP-Socket DeActivation */ 124 | if (TYPE1SC.socketClose() == 0) 125 | DebugSerial.println("TCP Socket Close!!!"); 126 | 127 | /* 8 :Socket All Event Disable */ 128 | if (TYPE1SC.setSocket_EV(0) == 0) 129 | DebugSerial.println("Socket All Event Disable!!!"); 130 | 131 | delay(10000); 132 | 133 | } 134 | 135 | void loop() { 136 | delay(1000); 137 | } 138 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_UDP_test/TYPE1SC_UDP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define PWR_PIN 5 5 | #define RST_PIN 18 6 | #define WAKEUP_PIN 19 7 | 8 | HardwareSerial M1Serial(2); // use ESP32 UART2 9 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 10 | 11 | void setup() { 12 | 13 | // put your setup code here, to run once: 14 | /* Serial2 Initialization */ 15 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 16 | DebugSerial.begin(115200); 17 | 18 | DebugSerial.println("TYPE1SC Module Start!!!"); 19 | /* Board Reset */ 20 | TYPE1SC.reset(); 21 | delay(2000); 22 | 23 | /* TYPE1SC Module Initialization */ 24 | if (TYPE1SC.init()) { 25 | DebugSerial.println("TYPE1SC Module Error!!!"); 26 | } 27 | 28 | /* Network Registration Check */ 29 | while (TYPE1SC.canConnect() != 0) { 30 | DebugSerial.println("Network not Ready !!!"); 31 | delay(2000); 32 | } 33 | 34 | DebugSerial.println("TYPE1SC Module Ready!!!"); 35 | 36 | /* Enter a DNS address to get an IP address */ 37 | char IPAddr[32]; 38 | 39 | while (1) { 40 | 41 | if (TYPE1SC.getIPAddr("echo.mbedcloudtesting.com", IPAddr, 42 | sizeof(IPAddr)) == 0) { 43 | DebugSerial.print("IP Address : "); 44 | DebugSerial.println(IPAddr); 45 | break; 46 | } else { 47 | DebugSerial.println("IP Address Error!!!"); 48 | } 49 | delay(2000); 50 | } 51 | 52 | int _PORT = 7; 53 | char sckInfo[128]; 54 | 55 | /* 1 :UDP Socket Create ( 0:UDP, 1:TCP ) */ 56 | if (TYPE1SC.socketCreate(0, IPAddr, _PORT) == 0) 57 | DebugSerial.println("UDP Socket Create!!!"); 58 | 59 | INFO: 60 | 61 | /* 2 :UDP Socket Activation */ 62 | if (TYPE1SC.socketActivate() == 0) 63 | DebugSerial.println("UDP Socket Activation!!!"); 64 | 65 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 66 | DebugSerial.print("Socket Info : "); 67 | DebugSerial.println(sckInfo); 68 | 69 | if (strcmp(sckInfo, "ACTIVATED")) { 70 | delay(3000); 71 | goto INFO; 72 | } 73 | } 74 | 75 | /* 3 :UDP Socket Send Data */ 76 | char sendBuffer[] = "Hello CodeZoo!!!"; 77 | char recvBuffer[32]; 78 | int recvSize; 79 | 80 | if (TYPE1SC.socketSend(sendBuffer) == 0) { 81 | DebugSerial.print("[Send] >> "); 82 | DebugSerial.println(sendBuffer); 83 | } else 84 | DebugSerial.println("Send Fail!!!"); 85 | 86 | /* 4 :UDP Socket Recv Data */ 87 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 88 | DebugSerial.print("[Recv] >> "); 89 | DebugSerial.println(recvBuffer); 90 | DebugSerial.print("[RecvSize] >> "); 91 | DebugSerial.println(recvSize); 92 | } else { 93 | DebugSerial.println("Recv Fail!!!"); 94 | } 95 | 96 | /* 5 :UDP Socket DeActivation */ 97 | if (TYPE1SC.socketDeActivate() == 0) 98 | DebugSerial.println("UDP Socket DeActivation!!!"); 99 | 100 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 101 | DebugSerial.print("Socket Info : "); 102 | DebugSerial.println(sckInfo); 103 | } 104 | 105 | /* 6 :UDP Socket DeActivation */ 106 | if (TYPE1SC.socketClose() == 0) 107 | DebugSerial.println("UDP Socket Close!!!"); 108 | } 109 | 110 | void loop() { delay(1000); } 111 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_WRITE_HTTPS_CERT/TYPE1SC_WRITE_HTTPS_CERT.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #include "http_credentials.h" 4 | 5 | #define DebugSerial Serial 6 | #define PWR_PIN 5 7 | #define RST_PIN 18 8 | #define WAKEUP_PIN 19 9 | 10 | #define PROFILE_ID 2 11 | 12 | HardwareSerial M1Serial(2); // use ESP32 UART2 13 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 14 | 15 | void setup() { 16 | /* Serial2 Initialization */ 17 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 18 | DebugSerial.begin(115200); 19 | 20 | DebugSerial.println("TYPE1SC Module Start!!!"); 21 | 22 | /* Board Reset */ 23 | TYPE1SC.reset(); 24 | delay(2000); 25 | 26 | /* TYPE1SC Module Initialization */ 27 | if (TYPE1SC.init()) { 28 | DebugSerial.println("TYPE1SC Module Error!!!"); 29 | } 30 | 31 | /* Network Registration Check */ 32 | while (TYPE1SC.canConnect() != 0) { 33 | DebugSerial.println("Network not Ready !!!"); 34 | delay(2000); 35 | } 36 | 37 | DebugSerial.println("TYPE1SC Module Ready!!!"); 38 | 39 | /* DELETE Certification Profile 1-255 */ 40 | int delProfile = PROFILE_ID; 41 | if (TYPE1SC.delCert(delProfile) == 0) { 42 | DebugSerial.println("Delete Certification in Profile.."); 43 | } 44 | delay(2000); 45 | 46 | /* Write server CA, Don't edit the file name */ 47 | if (TYPE1SC.writeKEY("server.crt", 0, serverCrt) == 0) { 48 | DebugSerial.println("Server CA Write!!!"); 49 | } 50 | delay(5000); 51 | 52 | /* ADD Certification Profile 1-255 */ 53 | int addProfile = PROFILE_ID; 54 | if (TYPE1SC.addHTTPCert(addProfile) == 0) { 55 | DebugSerial.println("ADD Server Certification in Profile.."); 56 | } 57 | } 58 | 59 | void loop() { delay(1000); } 60 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_WRITE_HTTPS_CERT/http_credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTP_CREDENTIALS_H 2 | #define HTTP_CREDENTIALS_H 3 | 4 | const char serverCrt[] = "-----BEGIN CERTIFICATE-----\n" 5 | "MIIEXjCCA0agAwIBAgITB3MSSkvL1E7HtTvq8ZSELToPoTANBgkqhkiG9w0BAQsF\n" 6 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" 7 | "b24gUm9vdCBDQSAxMB4XDTIyMDgyMzIyMjUzMFoXDTMwMDgyMzIyMjUzMFowPDEL\n" 8 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEcMBoGA1UEAxMTQW1hem9uIFJT\n" 9 | "QSAyMDQ4IE0wMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALtDGMZa\n" 10 | "qHneKei1by6+pUPPLljTB143Si6VpEWPc6mSkFhZb/6qrkZyoHlQLbDYnI2D7hD0\n" 11 | "sdzEqfnuAjIsuXQLG3A8TvX6V3oFNBFVe8NlLJHvBseKY88saLwufxkZVwk74g4n\n" 12 | "WlNMXzla9Y5F3wwRHwMVH443xGz6UtGSZSqQ94eFx5X7Tlqt8whi8qCaKdZ5rNak\n" 13 | "+r9nUThOeClqFd4oXych//Rc7Y0eX1KNWHYSI1Nk31mYgiK3JvH063g+K9tHA63Z\n" 14 | "eTgKgndlh+WI+zv7i44HepRZjA1FYwYZ9Vv/9UkC5Yz8/yU65fgjaE+wVHM4e/Yy\n" 15 | "C2osrPWE7gJ+dXMCAwEAAaOCAVowggFWMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYD\n" 16 | "VR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNV\n" 17 | "HQ4EFgQUwDFSzVpQw4J8dHHOy+mc+XrrguIwHwYDVR0jBBgwFoAUhBjMhTTsvAyU\n" 18 | "lC4IWZzHshBOCggwewYIKwYBBQUHAQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8v\n" 19 | "b2NzcC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDov\n" 20 | "L2NydC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8E\n" 21 | "ODA2MDSgMqAwhi5odHRwOi8vY3JsLnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jv\n" 22 | "b3RjYTEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IB\n" 23 | "AQAtTi6Fs0Azfi+iwm7jrz+CSxHH+uHl7Law3MQSXVtR8RV53PtR6r/6gNpqlzdo\n" 24 | "Zq4FKbADi1v9Bun8RY8D51uedRfjsbeodizeBB8nXmeyD33Ep7VATj4ozcd31YFV\n" 25 | "fgRhvTSxNrrTlNpWkUk0m3BMPv8sg381HhA6uEYokE5q9uws/3YkKqRiEz3TsaWm\n" 26 | "JqIRZhMbgAfp7O7FUwFIb7UIspogZSKxPIWJpxiPo3TcBambbVtQOcNRWz5qCQdD\n" 27 | "slI2yayq0n2TXoHyNCLEH8rpsJRVILFsg0jc7BaFrMnF462+ajSehgj12IidNeRN\n" 28 | "4zl+EoNaWdpnWndvSpAEkq2P\n" 29 | "-----END CERTIFICATE-----"; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_WRITE_KEY/TYPE1SC_WRITE_KEY.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include "aws_credentials.h" 3 | 4 | #define DebugSerial Serial 5 | #define PWR_PIN 5 6 | #define RST_PIN 18 7 | #define WAKEUP_PIN 19 8 | 9 | HardwareSerial M1Serial(2); // use ESP32 UART2 10 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 11 | 12 | void setup() { 13 | 14 | // put your setup code here, to run once: 15 | /* Serial2 Initialization */ 16 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 17 | DebugSerial.begin(115200); 18 | 19 | DebugSerial.println("TYPE1SC Module Start!!!"); 20 | 21 | /* Board Reset */ 22 | TYPE1SC.reset(); 23 | delay(2000); 24 | 25 | /* TYPE1SC Module Initialization */ 26 | if (TYPE1SC.init()) { 27 | DebugSerial.println("TYPE1SC Module Error!!!"); 28 | } 29 | 30 | /* Network Registration Check */ 31 | while (TYPE1SC.canConnect() != 0) { 32 | DebugSerial.println("Network not Ready !!!"); 33 | delay(2000); 34 | } 35 | 36 | DebugSerial.println("TYPE1SC Module Ready!!!"); 37 | 38 | /* DELETE Certification Profile 1-255 */ 39 | int delProfile = 9; 40 | if (TYPE1SC.delCert(delProfile) == 0) { 41 | DebugSerial.println("Delete Certification Profile!!!"); 42 | } 43 | delay(2000); 44 | 45 | /* Write root CA, Don't edit the file name */ 46 | if (TYPE1SC.writeKEY("rootCA.pem", 0, rootCA) == 0) { 47 | DebugSerial.println("Root CA Write!!!"); 48 | } 49 | delay(5000); 50 | 51 | /* Write client CA, Don't edit the file name */ 52 | if (TYPE1SC.writeKEY("cert.pem.crt", 0, clientCrt) == 0) { 53 | DebugSerial.println("Client CA Write!!!"); 54 | } 55 | delay(5000); 56 | 57 | /* Write client KEY, Don't edit the file name */ 58 | if (TYPE1SC.writeKEY("private.pem.key", 1, clientKey) == 0) { 59 | DebugSerial.println("Client KEY Write!!!"); 60 | } 61 | delay(5000); 62 | 63 | /* ADD Certification Profile 1-255 */ 64 | int addProfile = 9; 65 | if (TYPE1SC.addCert(addProfile) == 0) { 66 | DebugSerial.println("ADD Certification Profile!!!"); 67 | } 68 | } 69 | 70 | void loop() { delay(1000); } 71 | -------------------------------------------------------------------------------- /examples/ESP32/TYPE1SC_WRITE_KEY/aws_credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef AWS_CREDENTIALS_H 2 | #define AWS_CREDENTIALS_H 3 | const char rootCA[] = "-----BEGIN CERTIFICATE-----\n" 4 | "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" 5 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" 6 | "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" 7 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" 8 | "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" 9 | "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" 10 | "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" 11 | "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" 12 | "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" 13 | "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" 14 | "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" 15 | "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" 16 | "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" 17 | "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" 18 | "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" 19 | "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" 20 | "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" 21 | "rqXRfboQnoZsG4q5WTP468SQvvG5\n" 22 | "-----END CERTIFICATE-----"; 23 | 24 | const char clientCrt[] = "-----BEGIN CERTIFICATE-----\n" 25 | "\n" 26 | "\n" 27 | "\n" 28 | "\n" 29 | "\n" 30 | "\n" 31 | "\n" 32 | "\n" 33 | "\n" 34 | "\n" 35 | "\n" 36 | "\n" 37 | "\n" 38 | "\n" 39 | "\n" 40 | "\n" 41 | "\n" 42 | "\n" 43 | "-----END CERTIFICATE-----"; 44 | 45 | const char clientKey[] = "-----BEGIN RSA PRIVATE KEY-----\n" 46 | "\n" 47 | "\n" 48 | "\n" 49 | "\n" 50 | "\n" 51 | "\n" 52 | "\n" 53 | "\n" 54 | "\n" 55 | "\n" 56 | "\n" 57 | "\n" 58 | "\n" 59 | "\n" 60 | "\n" 61 | "\n" 62 | "\n" 63 | "\n" 64 | "\n" 65 | "\n" 66 | "\n" 67 | "\n" 68 | "\n" 69 | "\n" 70 | "\n" 71 | "-----END RSA PRIVATE KEY-----"; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_AWSIOT_test/TYPE1SC_AWSIOT_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | 5 | #define DebugSerial Serial 6 | #define PWR_PIN 5 7 | #define RST_PIN 18 8 | #define WAKEUP_PIN 19 9 | #define EXT_ANT 4 10 | 11 | #define DHTPIN 0 12 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 13 | // Uncomment whatever type you're using! 14 | //#define DHTTYPE DHT11 // DHT 11 15 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 16 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 17 | 18 | DHT dht(DHTPIN, DHTTYPE); 19 | 20 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 21 | HardwareSerial M1Serial(2); // use ESP32 UART2 22 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 23 | 24 | #define U8LOG_WIDTH 16 25 | #define U8LOG_HEIGHT 8 26 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 27 | U8X8LOG u8x8log; 28 | 29 | /* EXT_ANT_ON 0 : Use an internal antenna. 30 | * EXT_ANT_ON 1 : Use an external antenna. 31 | */ 32 | #define EXT_ANT_ON 0 33 | 34 | void extAntenna() { 35 | if (EXT_ANT_ON) { 36 | pinMode(EXT_ANT, OUTPUT); 37 | digitalWrite(EXT_ANT, HIGH); 38 | delay(100); 39 | } 40 | } 41 | 42 | void setup() { 43 | u8x8.begin(); 44 | u8x8.setFont(u8x8_font_chroma48medium8_r); 45 | 46 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 47 | u8x8log.setRedrawMode( 48 | 1); // 0: Update screen with newline, 1: Update screen for every char 49 | 50 | // put your setup code here, to run once: 51 | /* Serial2 Initialization */ 52 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 53 | DebugSerial.begin(115200); 54 | 55 | DebugSerial.println("TYPE1SC Module Start!!!"); 56 | u8x8log.print("TYPE1SC Module Start!!!\n"); 57 | 58 | extAntenna(); 59 | 60 | dht.begin(); 61 | 62 | /* TYPE1SC Module Initialization */ 63 | if (TYPE1SC.init()) { 64 | DebugSerial.println("TYPE1SC Module Error!!!"); 65 | u8x8log.print("TYPE1SC Module Error!!!\n"); 66 | } 67 | 68 | /* Network Registration Check */ 69 | while (TYPE1SC.canConnect() != 0) { 70 | DebugSerial.println("Network not Ready!!!"); 71 | u8x8log.print("Network not Ready!!!\n"); 72 | delay(2000); 73 | } 74 | 75 | DebugSerial.println("TYPE1SC Module Ready!!!"); 76 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 77 | 78 | /* Device Data EndPoint Address AWS IoT > Settings > Device data endpoint > 79 | * Copy&Paste */ 80 | char _IP[] = "*****.amazonaws.com"; 81 | 82 | char _NodeID[] = "Murata_Node01"; 83 | char _Topic[] = "sdkTest/sub"; 84 | char _message[64]; 85 | int tlsProfile = 9; 86 | int conn_timeout = 1200; 87 | float t = 0.0; // Stores temperature value 88 | float h = 0.0; // Stores humidity value 89 | char temp[8]; 90 | char humi[8]; 91 | 92 | /* 1 : Configure AWS_IOT parameters (ID, Address, tlsProfile) */ 93 | if (TYPE1SC.setAWSIOT_CONN(_NodeID, _IP, tlsProfile) == 0) { 94 | DebugSerial.println( 95 | "1.Configure AWS_IOT parameter:ID, Address, tls Profile"); 96 | u8x8log.print("1.Configure AWS_IOT parameter:ID, Address, tls Profile\n"); 97 | } 98 | 99 | /* 2 : Configure AWS_IOT parameters (Connection Timeout) */ 100 | if (TYPE1SC.setAWSIOT_TIMEOUT(conn_timeout) == 0) { 101 | DebugSerial.println("2.Configure AWS_IOT parameter:Timeout"); 102 | u8x8log.print("2.Configure AWS_IOT parameter:Timeout\n"); 103 | } 104 | 105 | /* 3 : Enable AWS_IOT events */ 106 | if (TYPE1SC.setAWSIOT_EV(1) == 0) { 107 | DebugSerial.println("3.Enable AWS_IOT events"); 108 | u8x8log.print("3.Enable AWS_IOT events\n"); 109 | } 110 | 111 | /* 4 : Establish connection */ 112 | if (TYPE1SC.AWSIOT_Connect() == 0) { 113 | DebugSerial.println("4.Establish connection"); 114 | u8x8log.print("4.Establish connection\n"); 115 | } 116 | 117 | /* 5 : Subscribe (register) to the topic on the endpoint */ 118 | if (TYPE1SC.AWSIOT_SUBSCRIBE(_Topic) == 0) { 119 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 120 | u8x8log.print("5.Subscribe to the topic on the endpoint\n"); 121 | } 122 | /*Get Temperature & Humidity */ 123 | while (1) { 124 | /* Get DHT22 Sensor */ 125 | t = dht.readTemperature(); 126 | h = dht.readHumidity(); 127 | if (String(t) != "nan" && String(h) != "nan") 128 | break; 129 | else { 130 | DebugSerial.println("case nan ..."); 131 | u8x8log.print("case nan ...\n"); 132 | delay(1000); 133 | } 134 | } 135 | 136 | dtostrf(t, 4, 1, temp); 137 | dtostrf(h, 4, 1, humi); 138 | 139 | memset(_message, 0x0, sizeof(_message)); 140 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 141 | 142 | /* 6 : Publish data to broker */ 143 | if (TYPE1SC.AWSIOT_Publish(_Topic, _message) == 0) { 144 | DebugSerial.println("6.Publish data to broker"); 145 | u8x8log.print("6.Publish data to broker\n"); 146 | } 147 | 148 | /* 7 : UnSubscribe to the topic on the endpoint */ 149 | if (TYPE1SC.AWSIOT_UnSUBSCRIBE(_Topic) == 0) { 150 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 151 | u8x8log.print("7.UnSubscribe to the topic on the endpoint\n"); 152 | } 153 | 154 | /* 8 : Disconnect AWS_IOT Service */ 155 | if (TYPE1SC.AWSIOT_DisConnect() == 0) { 156 | DebugSerial.println("8.Disconnect AWS_IOT Service"); 157 | u8x8log.print("8.Disconnect AWS_IOT Service\n"); 158 | } 159 | 160 | /* 9 : Disable AWS_IOT events */ 161 | if (TYPE1SC.setAWSIOT_EV(0) == 0) 162 | DebugSerial.println("9.Disable AWS_IOT events"); 163 | u8x8log.print("9.Disable AWS_IOT events\n"); 164 | 165 | /* 10 :Detach Network */ 166 | if (TYPE1SC.setCFUN(0) == 0) { 167 | DebugSerial.println("10.detach Network!!!"); 168 | u8x8log.print("10.detach Network!!!\n"); 169 | } 170 | delay(10000); // Detach Setup Time : 10sec 171 | } 172 | 173 | void loop() { delay(1000); } 174 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_Basic_test/TYPE1SC_Basic_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | 5 | #define DebugSerial Serial 6 | #define PWR_PIN 5 7 | #define RST_PIN 18 8 | #define WAKEUP_PIN 19 9 | #define EXT_ANT 4 10 | 11 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 12 | HardwareSerial M1Serial(2); // use ESP32 UART2 13 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 14 | 15 | #define U8LOG_WIDTH 16 16 | #define U8LOG_HEIGHT 8 17 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 18 | U8X8LOG u8x8log; 19 | 20 | /* EXT_ANT_ON 0 : Use an internal antenna. 21 | * EXT_ANT_ON 1 : Use an external antenna. 22 | */ 23 | #define EXT_ANT_ON 0 24 | 25 | void extAntenna() { 26 | if (EXT_ANT_ON) { 27 | pinMode(EXT_ANT, OUTPUT); 28 | digitalWrite(EXT_ANT, HIGH); 29 | delay(100); 30 | } 31 | } 32 | 33 | void setup() { 34 | u8x8.begin(); 35 | u8x8.setFont(u8x8_font_chroma48medium8_r); 36 | 37 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 38 | u8x8log.setRedrawMode( 39 | 1); // 0: Update screen with newline, 1: Update screen for every char 40 | 41 | // put your setup code here, to run once: 42 | /* Serial2 Initialization */ 43 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 44 | DebugSerial.begin(115200); 45 | 46 | DebugSerial.println("TYPE1SC Module Start!!!"); 47 | u8x8log.print("TYPE1SC Module Start!!!\n"); 48 | 49 | extAntenna(); 50 | 51 | /* TYPE1SC Module Initialization */ 52 | if (TYPE1SC.init()) { 53 | DebugSerial.println("TYPE1SC Module Error!!!"); 54 | u8x8log.print("TYPE1SC Module Error!!!\n"); 55 | } 56 | 57 | /* Network Registration Check */ 58 | while (TYPE1SC.canConnect() != 0) { 59 | DebugSerial.println("Network not Ready!!!"); 60 | u8x8log.print("Network not Ready!!!\n"); 61 | delay(2000); 62 | } 63 | 64 | DebugSerial.println("TYPE1SC Module Ready!!!"); 65 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 66 | } 67 | 68 | void loop() { 69 | /*** TYPE1SC Basic Test Code ***/ 70 | /* SIM Card Check */ 71 | if (!TYPE1SC.chkSIM()) { 72 | DebugSerial.println("SIM Card OK!!!"); 73 | u8x8log.print("SIM Card OK!!!\n"); 74 | } 75 | delay(1000); 76 | 77 | /* Get Phone Number */ 78 | char szCIMI[32]; 79 | if (TYPE1SC.getCIMI(szCIMI, sizeof(szCIMI)) == 0) { 80 | DebugSerial.print("IMSI : "); 81 | DebugSerial.println(szCIMI); 82 | u8x8log.print("IMSI : "); 83 | u8x8log.print(szCIMI); 84 | u8x8log.print("\n"); 85 | } 86 | delay(1000); 87 | 88 | /* Get IMEI Number */ 89 | char szIMEI[32]; 90 | if (TYPE1SC.getIMEI(szIMEI, sizeof(szIMEI)) == 0) { 91 | DebugSerial.print("IMEI : "); 92 | DebugSerial.println(szIMEI); 93 | u8x8log.print("IMEI : "); 94 | u8x8log.print(szIMEI); 95 | u8x8log.print("\n"); 96 | } 97 | delay(1000); 98 | 99 | /* Get ICCID Number */ 100 | char szICCID[32]; 101 | if (TYPE1SC.getICCID(szICCID, sizeof(szICCID)) == 0) { 102 | DebugSerial.print("ICCID : "); 103 | DebugSerial.println(szICCID); 104 | u8x8log.print("ICCID : "); 105 | u8x8log.print(szICCID); 106 | u8x8log.print("\n"); 107 | } 108 | delay(1000); 109 | 110 | /* Get Fimrware version */ 111 | char szCGMR[32]; 112 | if (TYPE1SC.getCGMR(szCGMR, sizeof(szCGMR)) == 0) { 113 | DebugSerial.print("CGMR : "); 114 | DebugSerial.println(szCGMR); 115 | u8x8log.print("CGMR : "); 116 | u8x8log.print(szCGMR); 117 | u8x8log.print("\n"); 118 | } 119 | delay(1000); 120 | 121 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 122 | char szTime[32]; 123 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 124 | DebugSerial.print("Time : "); 125 | DebugSerial.println(szTime); 126 | u8x8log.print("Time : "); 127 | u8x8log.print(szTime); 128 | u8x8log.print("\n"); 129 | } 130 | delay(1000); 131 | 132 | /* Get RSSI */ 133 | int rssi; 134 | if (TYPE1SC.getRSSI(&rssi) == 0) { 135 | DebugSerial.print("RSSI : "); 136 | DebugSerial.println(rssi); 137 | u8x8log.print("RSSI : "); 138 | u8x8log.print(rssi); 139 | u8x8log.print("\n"); 140 | } 141 | delay(1000); 142 | 143 | /* Get RSRP */ 144 | int rsrp; 145 | if (TYPE1SC.getRSRP(&rsrp) == 0) { 146 | DebugSerial.print("RSRP : "); 147 | DebugSerial.println(rsrp); 148 | u8x8log.print("RSRP : "); 149 | u8x8log.print(rsrp); 150 | u8x8log.print("\n"); 151 | } 152 | delay(1000); 153 | 154 | /* Get RSRQ */ 155 | int rsrq; 156 | if (TYPE1SC.getRSRQ(&rsrq) == 0) { 157 | DebugSerial.print("RSRQ : "); 158 | DebugSerial.println(rsrq); 159 | u8x8log.print("RSRQ : "); 160 | u8x8log.print(rsrq); 161 | u8x8log.print("\n"); 162 | } 163 | delay(1000); 164 | 165 | /* Get SINR */ 166 | int sinr; 167 | if (TYPE1SC.getSINR(&sinr) == 0) { 168 | DebugSerial.print("SINR : "); 169 | DebugSerial.println(sinr); 170 | u8x8log.print("SINR : "); 171 | u8x8log.print(sinr); 172 | u8x8log.print("\n"); 173 | } 174 | delay(1000); 175 | 176 | /* Get TX Power */ 177 | char txPower[64]; 178 | if (TYPE1SC.getTxPower(txPower, sizeof(txPower)) == 0) { 179 | DebugSerial.print("TX Power : "); 180 | DebugSerial.println(txPower); 181 | u8x8log.print("TX Power : "); 182 | u8x8log.print(txPower); 183 | u8x8log.print("\n"); 184 | } 185 | delay(1000); 186 | } 187 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_Basic_test_Serial1/TYPE1SC_Basic_test_Serial1.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #define DebugSerial SerialPort 7 | #define PWR_PIN 5 8 | #define RST_PIN 18 9 | #define WAKEUP_PIN 19 10 | #define EXT_ANT 4 11 | 12 | HardwareSerial SerialPort(1); // use ESP32 UART1 13 | 14 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 15 | HardwareSerial M1Serial(2); // use ESP32 UART2 16 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 17 | 18 | #define U8LOG_WIDTH 16 19 | #define U8LOG_HEIGHT 8 20 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 21 | U8X8LOG u8x8log; 22 | 23 | /* EXT_ANT_ON 0 : Use an internal antenna. 24 | * EXT_ANT_ON 1 : Use an external antenna. 25 | */ 26 | #define EXT_ANT_ON 0 27 | 28 | void extAntenna() { 29 | if (EXT_ANT_ON) { 30 | pinMode(EXT_ANT, OUTPUT); 31 | digitalWrite(EXT_ANT, HIGH); 32 | delay(100); 33 | } 34 | } 35 | 36 | void setup() { 37 | u8x8.begin(); 38 | u8x8.setFont(u8x8_font_chroma48medium8_r); 39 | 40 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 41 | u8x8log.setRedrawMode( 42 | 1); // 0: Update screen with newline, 1: Update screen for every char 43 | 44 | /* Serial1 Initialization */ 45 | SerialPort.begin(115200, SERIAL_8N1, 33, 32); // RXD1 : 33, TXD1 : 32 46 | 47 | // put your setup code here, to run once: 48 | /* Serial2 Initialization */ 49 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 50 | DebugSerial.println("TYPE1SC Module Start!!!"); 51 | u8x8log.print("TYPE1SC Module Start!!!\n"); 52 | 53 | extAntenna(); 54 | 55 | /* TYPE1SC Module Initialization */ 56 | if (TYPE1SC.init()) { 57 | DebugSerial.println("TYPE1SC Module Error!!!"); 58 | u8x8log.print("TYPE1SC Module Error!!!\n"); 59 | } 60 | 61 | /* Network Registration Check */ 62 | while (TYPE1SC.canConnect() != 0) { 63 | DebugSerial.println("Network not Ready!!!"); 64 | u8x8log.print("Network not Ready!!!\n"); 65 | delay(2000); 66 | } 67 | 68 | DebugSerial.println("TYPE1SC Module Ready!!!"); 69 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 70 | } 71 | 72 | void loop() { 73 | /*** TYPE1SC Basic Test Code ***/ 74 | /* SIM Card Check */ 75 | if (!TYPE1SC.chkSIM()) { 76 | DebugSerial.println("SIM Card OK!!!"); 77 | u8x8log.print("SIM Card OK!!!\n"); 78 | } 79 | delay(1000); 80 | 81 | /* Get Phone Number */ 82 | char szCIMI[32]; 83 | if (TYPE1SC.getCIMI(szCIMI, sizeof(szCIMI)) == 0) { 84 | DebugSerial.print("IMSI : "); 85 | DebugSerial.println(szCIMI); 86 | u8x8log.print("IMSI : "); 87 | u8x8log.print(szCIMI); 88 | u8x8log.print("\n"); 89 | } 90 | delay(1000); 91 | 92 | /* Get IMEI Number */ 93 | char szIMEI[32]; 94 | if (TYPE1SC.getIMEI(szIMEI, sizeof(szIMEI)) == 0) { 95 | DebugSerial.print("IMEI : "); 96 | DebugSerial.println(szIMEI); 97 | u8x8log.print("IMEI : "); 98 | u8x8log.print(szIMEI); 99 | u8x8log.print("\n"); 100 | } 101 | delay(1000); 102 | 103 | /* Get ICCID Number */ 104 | char szICCID[32]; 105 | if (TYPE1SC.getICCID(szICCID, sizeof(szICCID)) == 0) { 106 | DebugSerial.print("ICCID : "); 107 | DebugSerial.println(szICCID); 108 | u8x8log.print("ICCID : "); 109 | u8x8log.print(szICCID); 110 | u8x8log.print("\n"); 111 | } 112 | delay(1000); 113 | 114 | /* Get Fimrware version */ 115 | char szCGMR[32]; 116 | if (TYPE1SC.getCGMR(szCGMR, sizeof(szCGMR)) == 0) { 117 | DebugSerial.print("CGMR : "); 118 | DebugSerial.println(szCGMR); 119 | u8x8log.print("CGMR : "); 120 | u8x8log.print(szCGMR); 121 | u8x8log.print("\n"); 122 | } 123 | delay(1000); 124 | 125 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 126 | char szTime[32]; 127 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 128 | DebugSerial.print("Time : "); 129 | DebugSerial.println(szTime); 130 | u8x8log.print("Time : "); 131 | u8x8log.print(szTime); 132 | u8x8log.print("\n"); 133 | } 134 | delay(1000); 135 | 136 | /* Get RSSI */ 137 | int rssi; 138 | if (TYPE1SC.getRSSI(&rssi) == 0) { 139 | DebugSerial.print("RSSI : "); 140 | DebugSerial.println(rssi); 141 | u8x8log.print("RSSI : "); 142 | u8x8log.print(rssi); 143 | u8x8log.print("\n"); 144 | } 145 | delay(1000); 146 | 147 | /* Get RSRP */ 148 | int rsrp; 149 | if (TYPE1SC.getRSRP(&rsrp) == 0) { 150 | DebugSerial.print("RSRP : "); 151 | DebugSerial.println(rsrp); 152 | u8x8log.print("RSRP : "); 153 | u8x8log.print(rsrp); 154 | u8x8log.print("\n"); 155 | } 156 | delay(1000); 157 | 158 | /* Get RSRQ */ 159 | int rsrq; 160 | if (TYPE1SC.getRSRQ(&rsrq) == 0) { 161 | DebugSerial.print("RSRQ : "); 162 | DebugSerial.println(rsrq); 163 | u8x8log.print("RSRQ : "); 164 | u8x8log.print(rsrq); 165 | u8x8log.print("\n"); 166 | } 167 | delay(1000); 168 | 169 | /* Get SINR */ 170 | int sinr; 171 | if (TYPE1SC.getSINR(&sinr) == 0) { 172 | DebugSerial.print("SINR : "); 173 | DebugSerial.println(sinr); 174 | u8x8log.print("SINR : "); 175 | u8x8log.print(sinr); 176 | u8x8log.print("\n"); 177 | } 178 | delay(1000); 179 | 180 | /* Get TX Power */ 181 | char txPower[64]; 182 | if (TYPE1SC.getTxPower(txPower, sizeof(txPower)) == 0) { 183 | DebugSerial.print("TX Power : "); 184 | DebugSerial.println(txPower); 185 | u8x8log.print("TX Power : "); 186 | u8x8log.print(txPower); 187 | u8x8log.print("\n"); 188 | } 189 | delay(1000); 190 | } 191 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_GET_UnixTime/TYPE1SC_GET_UnixTime.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | #include //https://github.com/GyverLibs/UnixTime 5 | 6 | #define DebugSerial Serial 7 | #define PWR_PIN 5 8 | #define RST_PIN 18 9 | #define WAKEUP_PIN 19 10 | #define EXT_ANT 4 11 | 12 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 13 | HardwareSerial M1Serial(2); // use ESP32 UART2 14 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 15 | UnixTime stamp(9); // Seoul GMT + 09 16 | 17 | #define U8LOG_WIDTH 16 18 | #define U8LOG_HEIGHT 8 19 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 20 | U8X8LOG u8x8log; 21 | 22 | /* EXT_ANT_ON 0 : Use an internal antenna. 23 | * EXT_ANT_ON 1 : Use an external antenna. 24 | */ 25 | #define EXT_ANT_ON 0 26 | 27 | void extAntenna() { 28 | if (EXT_ANT_ON) { 29 | pinMode(EXT_ANT, OUTPUT); 30 | digitalWrite(EXT_ANT, HIGH); 31 | delay(100); 32 | } 33 | } 34 | 35 | void setup() { 36 | u8x8.begin(); 37 | u8x8.setFont(u8x8_font_chroma48medium8_r); 38 | 39 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 40 | u8x8log.setRedrawMode( 41 | 1); // 0: Update screen with newline, 1: Update screen for every char 42 | 43 | // put your setup code here, to run once: 44 | /* Serial2 Initialization */ 45 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 46 | DebugSerial.begin(115200); 47 | 48 | DebugSerial.println("TYPE1SC Module Start!!!"); 49 | u8x8log.print("TYPE1SC Module Start!!!\n"); 50 | 51 | extAntenna(); 52 | 53 | /* TYPE1SC Module Initialization */ 54 | if (TYPE1SC.init()) { 55 | DebugSerial.println("TYPE1SC Module Error!!!"); 56 | u8x8log.print("TYPE1SC Module Error!!!\n"); 57 | } 58 | 59 | /* Network Registration Check */ 60 | while (TYPE1SC.canConnect() != 0) { 61 | DebugSerial.println("Network not Ready !!!"); 62 | u8x8log.print("Network not Ready!!!\n"); 63 | delay(2000); 64 | } 65 | 66 | DebugSerial.println("TYPE1SC Module Ready!!!"); 67 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 68 | } 69 | 70 | void loop() { 71 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 72 | char szTime[32]; 73 | uint32_t _year, _month, _day, _hour, _minute, _second, _tmp; 74 | 75 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 76 | DebugSerial.print("Time : "); 77 | DebugSerial.println(szTime); 78 | u8x8log.print("Time : "); 79 | u8x8log.print(szTime); 80 | u8x8log.print("\n"); 81 | sscanf(szTime, "\"%d/%d/%d,%d:%d:%d+%d\"", &_year, &_month, &_day, &_hour, 82 | &_minute, &_second, &_tmp); 83 | /* Debug */ 84 | DebugSerial.println(_year); 85 | u8x8log.print(_year); 86 | u8x8log.print("\n"); 87 | DebugSerial.println(_month); 88 | u8x8log.print(_month); 89 | u8x8log.print("\n"); 90 | DebugSerial.println(_day); 91 | u8x8log.print(_day); 92 | u8x8log.print("\n"); 93 | DebugSerial.println(_hour); 94 | u8x8log.print(_hour); 95 | u8x8log.print("\n"); 96 | DebugSerial.println(_minute); 97 | u8x8log.print(_minute); 98 | u8x8log.print("\n"); 99 | DebugSerial.println(_second); 100 | u8x8log.print(_second); 101 | u8x8log.print("\n"); 102 | } 103 | // Set Date Time 104 | _year += 2000; 105 | stamp.setDateTime(_year, _month, _day, _hour, _minute, _second); 106 | 107 | // Get Unix Time 108 | uint32_t unix = stamp.getUnix(); 109 | DebugSerial.println(unix); 110 | u8x8log.print(unix); 111 | u8x8log.print("\n"); 112 | 113 | // ========== UNIX to date and time =========== 114 | // convert unix to date and time 115 | // getDateTime(unix stamp) runs ~500 us on AVR 116 | // https://www.unixtimestamp.com/index.php 117 | stamp.getDateTime(unix); 118 | 119 | // pick up like this 120 | DebugSerial.println(stamp.year); 121 | u8x8log.print(stamp.year); 122 | u8x8log.print("\n"); 123 | DebugSerial.println(stamp.month); 124 | u8x8log.print(stamp.month); 125 | u8x8log.print("\n"); 126 | DebugSerial.println(stamp.day); 127 | u8x8log.print(stamp.day); 128 | u8x8log.print("\n"); 129 | DebugSerial.println(stamp.hour); 130 | u8x8log.print(stamp.hour); 131 | u8x8log.print("\n"); 132 | DebugSerial.println(stamp.minute); 133 | u8x8log.print(stamp.minute); 134 | u8x8log.print("\n"); 135 | DebugSerial.println(stamp.second); 136 | u8x8log.print(stamp.second); 137 | u8x8log.print("\n"); 138 | 139 | delay(1000); 140 | } 141 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_MQTT_test/TYPE1SC_MQTT_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | 5 | #define DebugSerial Serial 6 | #define PWR_PIN 5 7 | #define RST_PIN 18 8 | #define WAKEUP_PIN 19 9 | #define EXT_ANT 4 10 | 11 | #define DHTPIN 0 12 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 13 | // Uncomment whatever type you're using! 14 | //#define DHTTYPE DHT11 // DHT 11 15 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 16 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 17 | 18 | DHT dht(DHTPIN, DHTTYPE); 19 | 20 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 21 | HardwareSerial M1Serial(2); // use ESP32 UART2 22 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 23 | 24 | #define U8LOG_WIDTH 16 25 | #define U8LOG_HEIGHT 8 26 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 27 | U8X8LOG u8x8log; 28 | 29 | /* EXT_ANT_ON 0 : Use an internal antenna. 30 | * EXT_ANT_ON 1 : Use an external antenna. 31 | */ 32 | #define EXT_ANT_ON 0 33 | 34 | void extAntenna() { 35 | if (EXT_ANT_ON) { 36 | pinMode(EXT_ANT, OUTPUT); 37 | digitalWrite(EXT_ANT, HIGH); 38 | delay(100); 39 | } 40 | } 41 | 42 | void setup() { 43 | u8x8.begin(); 44 | u8x8.setFont(u8x8_font_chroma48medium8_r); 45 | 46 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 47 | u8x8log.setRedrawMode( 48 | 1); // 0: Update screen with newline, 1: Update screen for every char 49 | 50 | // put your setup code here, to run once: 51 | /* Serial2 Initialization */ 52 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 53 | DebugSerial.begin(115200); 54 | 55 | DebugSerial.println("TYPE1SC Module Start!!!"); 56 | u8x8log.print("TYPE1SC Module Start!!!\n"); 57 | 58 | extAntenna(); 59 | 60 | dht.begin(); 61 | 62 | /* TYPE1SC Module Initialization */ 63 | if (TYPE1SC.init()) { 64 | DebugSerial.println("TYPE1SC Module Error!!!"); 65 | u8x8log.print("TYPE1SC Module Error!!!\n"); 66 | } 67 | 68 | /* Network Registration Check */ 69 | while (TYPE1SC.canConnect() != 0) { 70 | DebugSerial.println("Network not Ready!!!"); 71 | u8x8log.print("Network not Ready!!!\n"); 72 | delay(2000); 73 | } 74 | 75 | DebugSerial.println("TYPE1SC Module Ready!!!"); 76 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 77 | 78 | char _IP[] = "broker.hivemq.com"; 79 | char _NodeID[] = "Cellular_node"; 80 | char _Topic[] = "type1sc/0/test"; 81 | char _message[64]; 82 | uint32_t conn_timeout = 1200; 83 | float t = 0.0; 84 | float h = 0.0; 85 | char temp[8]; // Stores temperature value 86 | char humi[8]; // Stores humidity value 87 | 88 | /* 89 | * qos : 0 - at most one delivery (default) 90 | * 1 - Delivered at least once 91 | * 2 - Exactly one delivery 92 | */ 93 | int qos = 0; 94 | 95 | /* 1 : Enable MQTT events */ 96 | if (TYPE1SC.setMQTT_EV(1) == 0) { 97 | DebugSerial.println("1.Enable MQTT events"); 98 | u8x8log.print("1.Enable MQTT events\n"); 99 | } 100 | 101 | /* 2 : Configure node parameters (ID, Address) */ 102 | if (TYPE1SC.setMQTT_NODES(_NodeID, _IP) == 0) { 103 | DebugSerial.println("2.Configure node parameter:ID, Address"); 104 | u8x8log.print("2.Configure node parameter:ID, Address\n"); 105 | } 106 | 107 | /* 3 : Configure node parameters (Connection Timeout) */ 108 | if (TYPE1SC.setMQTT_TIMEOUT(conn_timeout) == 0) { 109 | DebugSerial.println("3.Configure node parameter:Timeout"); 110 | u8x8log.print("3.Configure node parameter:Timeout\n"); 111 | } 112 | 113 | /* 4 : Establish connection */ 114 | if (TYPE1SC.MQTT_Connect() == 0) { 115 | DebugSerial.println("4.Establish connection"); 116 | u8x8log.print("4.Establish connection\n"); 117 | } 118 | 119 | /* 5 : Subscribe (register) to the topic on the endpoint */ 120 | if (TYPE1SC.MQTT_SUBSCRIBE(qos, _Topic) == 0) { 121 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 122 | u8x8log.print("5.Subscribe to the topic on the endpoint\n"); 123 | } 124 | 125 | /*Get Temperature & Humidity */ 126 | while (1) { 127 | /* Get DHT22 Sensor */ 128 | t = dht.readTemperature(); 129 | h = dht.readHumidity(); 130 | if (String(t) != "nan" && String(h) != "nan") 131 | break; 132 | else { 133 | DebugSerial.println("case nan ..."); 134 | u8x8log.print("case nan ...\n"); 135 | delay(1000); 136 | } 137 | } 138 | 139 | dtostrf(t, 4, 1, temp); 140 | dtostrf(h, 4, 1, humi); 141 | 142 | memset(_message, 0x0, sizeof(_message)); 143 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 144 | /* 6 : Publish data to broker */ 145 | if (TYPE1SC.MQTT_Publish(qos, _Topic, strlen(_message), _message) == 0) { 146 | DebugSerial.println("6.Publish data to broker"); 147 | u8x8log.print("6.Publish data to broker\n"); 148 | } 149 | 150 | /* 7 : UnSubscribe to the topic on the endpoint */ 151 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 152 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 153 | u8x8log.print("7.UnSubscribe to the topic on the endpoint\n"); 154 | } else { 155 | delay(1000); 156 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 157 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 158 | u8x8log.print("7.UnSubscribe to the topic on the endpoint\n"); 159 | } 160 | } 161 | /* 8 : Disconnect MQTT Server */ 162 | if (TYPE1SC.MQTT_DisConnect() == 0) { 163 | DebugSerial.println("8.Disconnect MQTT Server"); 164 | u8x8log.print("8.Disconnect MQTT Server\n"); 165 | } 166 | 167 | /* 9 : Disable MQTT events */ 168 | if (TYPE1SC.setMQTT_EV(0) == 0) { 169 | DebugSerial.println("9.Disable MQTT events"); 170 | u8x8log.print("9.Disable MQTT events\n"); 171 | } 172 | 173 | /* 10 :Detach Network */ 174 | if (TYPE1SC.setCFUN(0) == 0) { 175 | DebugSerial.println("10.detach Network!!!"); 176 | u8x8log.print("10.detach Network!!!\n"); 177 | } 178 | delay(10000); // Detach Setup Time : 10sec 179 | } 180 | 181 | void loop() { delay(1000); } 182 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_RS485_XY-MD02/TYPE1SC_RS485_XY-MD02.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This code demonstrates how to interact with an Arduino Mega 2560 and 3 | a Modbus RTU temperature and humidity sensor (SHT20). It reads the 4 | temperature and humidity values every 1 seconds and display data to 5 | the serial monitor. 6 | 7 | Note: Serial Port 0 is not used to connect the RS485 Converter (MAX485) 8 | because its used for debugging. The Serial Port 1 (TX1, RX1) is used 9 | for ModBus communication interface. 10 | 11 | Wiring of Sensor, Arduino, and MAX485 TTL to RS485 Converter: 12 | ___________________________________________________________________________________________ 13 | | Sensor (SHT20) | MAX485 TTL to RS485 Converter 14 | | A (Yellow) | A (Terminal block) 15 | | B (White) | B (Terminal block) 16 | | GND (Black) | GND (External Supply) 17 | | Vs (Red) | 9-30V (External Supply) 18 | ___________________________________________________________________________________________ 19 | | MAX485 TTL to RS485 Converter | Arduino (Hardware Serial) | Arduino (Software Serial) 20 | | RO (Reciever Output) | D19 (RX1) | D9 (RX) 21 | | RE (Reciever Enable) | D2 | D2 22 | | DE (Driver Enable) | D3 | D3 23 | | DI (Driver Input) | D18 (TX1) | D10 (TX) 24 | ___________________________________________________________________________________________ 25 | */ 26 | #include 27 | #include 28 | #include 29 | 30 | #define RS485Serial SerialPort 31 | 32 | HardwareSerial SerialPort(1); // use ESP32 UART1 33 | ModbusMaster node; 34 | 35 | void setup() { 36 | 37 | /* Serial1 Initialization */ 38 | SerialPort.begin(9600, SERIAL_8N1, 33, 32); // RXD1 : 33, TXD1 : 32 39 | 40 | // Modbus communication runs at 9600 baud 41 | Serial.begin(115200); 42 | 43 | // Modbus slave ID 1 44 | node.begin(1, RS485Serial); 45 | 46 | // Callbacks allow us to configure the RS485 transceiver correctly 47 | // Auto FlowControl - NULL 48 | node.preTransmission(NULL); 49 | node.postTransmission(NULL); 50 | 51 | delay(2000); 52 | } 53 | 54 | void loop() { 55 | // Request 2 registers starting at 0x0001 56 | uint8_t result = node.readInputRegisters(0x0001, 2); 57 | Serial.println("Data Requested"); 58 | 59 | if (result == node.ku8MBSuccess) { 60 | // Get response data from sensor 61 | Serial.print("Temperature: "); 62 | Serial.print(float(node.getResponseBuffer(0) / 10.00F)); 63 | Serial.print(" Humidity: "); 64 | Serial.println(float(node.getResponseBuffer(1) / 10.00F)); 65 | } 66 | delay(2000); 67 | } 68 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_RS485_XY-MD02/readme: -------------------------------------------------------------------------------- 1 | SZH-CVBE-010 2 | - MAX1348 TTL to RS485 converter 3 | - Auto FlowControl 4 | - Supply Voltage 3.3V/5V 5 | 6 | https://www.devicemart.co.kr/goods/view?no=1324908 7 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_SET_APN/TYPE1SC_SET_APN.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | 5 | #define DebugSerial Serial 6 | #define PWR_PIN 5 7 | #define RST_PIN 18 8 | #define WAKEUP_PIN 19 9 | #define EXT_ANT 4 10 | 11 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 12 | HardwareSerial M1Serial(2); // use ESP32 UART2 13 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 14 | 15 | #define U8LOG_WIDTH 16 16 | #define U8LOG_HEIGHT 8 17 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 18 | U8X8LOG u8x8log; 19 | 20 | /* EXT_ANT_ON 0 : Use an internal antenna. 21 | * EXT_ANT_ON 1 : Use an external antenna. 22 | */ 23 | #define EXT_ANT_ON 0 24 | 25 | void extAntenna() { 26 | if (EXT_ANT_ON) { 27 | pinMode(EXT_ANT, OUTPUT); 28 | digitalWrite(EXT_ANT, HIGH); 29 | delay(100); 30 | } 31 | } 32 | 33 | void setup() { 34 | u8x8.begin(); 35 | u8x8.setFont(u8x8_font_chroma48medium8_r); 36 | 37 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 38 | u8x8log.setRedrawMode( 39 | 1); // 0: Update screen with newline, 1: Update screen for every char 40 | 41 | // put your setup code here, to run once: 42 | /* Serial2 Initialization */ 43 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 44 | DebugSerial.begin(115200); 45 | 46 | DebugSerial.println("TYPE1SC Module Start!!!"); 47 | u8x8log.print("TYPE1SC Module Start!!!\n"); 48 | 49 | extAntenna(); 50 | 51 | /* TYPE1SC Module Initialization */ 52 | if (TYPE1SC.init()) { 53 | DebugSerial.println("TYPE1SC Module Error!!!"); 54 | u8x8log.print("TYPE1SC Module Error!!!\n"); 55 | } 56 | 57 | /* Network Disable */ 58 | if (TYPE1SC.setCFUN(0) == 0) { 59 | DebugSerial.println("TYPE1SC Network Disable!!!"); 60 | u8x8log.print("TYPE1SC Network Disable!!!\n"); 61 | } 62 | 63 | delay(1000); 64 | 65 | char *apnAddr = "simplio.apn"; /* Vodafone Global IoT SIM APN */ 66 | 67 | if (TYPE1SC.setAPN(apnAddr) == 0) { 68 | DebugSerial.println("TYPE1SC Set APN Address!!!"); 69 | u8x8log.print("TYPE1SC Set APN Address!!!\n"); 70 | } 71 | 72 | /* Board Reset */ 73 | TYPE1SC.reset(); 74 | delay(2000); 75 | 76 | /* TYPE1SC Module Initialization */ 77 | if (TYPE1SC.init()) { 78 | DebugSerial.println("TYPE1SC Module Error!!!"); 79 | u8x8log.print("TYPE1SC Module Error!!!\n"); 80 | } 81 | 82 | DebugSerial.println("TYPE1SC Module Ready!!!"); 83 | u8x8log.print("TYPE1SC Module Ready!!\n"); 84 | 85 | char apn[128]; 86 | if (TYPE1SC.getAPN(apn, sizeof(apn)) == 0) { 87 | DebugSerial.print("GET APN Address: "); 88 | DebugSerial.println(apn); 89 | u8x8log.print("GET APN Address: "); 90 | u8x8log.print(apn); 91 | u8x8log.print("\n"); 92 | } 93 | 94 | DebugSerial.println("TYPE1SC APN Setup Complete!!!"); 95 | u8x8log.print("TYPE1SC APN Setup Complete!!!\n"); 96 | } 97 | 98 | void loop() { delay(1000); } 99 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_TCP_test/TYPE1SC_TCP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | 5 | #define DebugSerial Serial 6 | #define PWR_PIN 5 7 | #define RST_PIN 18 8 | #define WAKEUP_PIN 19 9 | #define EXT_ANT 4 10 | 11 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 12 | HardwareSerial M1Serial(2); // use ESP32 UART2 13 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 14 | 15 | #define U8LOG_WIDTH 16 16 | #define U8LOG_HEIGHT 8 17 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 18 | U8X8LOG u8x8log; 19 | 20 | /* EXT_ANT_ON 0 : Use an internal antenna. 21 | * EXT_ANT_ON 1 : Use an external antenna. 22 | */ 23 | #define EXT_ANT_ON 0 24 | 25 | void extAntenna() { 26 | if (EXT_ANT_ON) { 27 | pinMode(EXT_ANT, OUTPUT); 28 | digitalWrite(EXT_ANT, HIGH); 29 | delay(100); 30 | } 31 | } 32 | 33 | void setup() { 34 | u8x8.begin(); 35 | u8x8.setFont(u8x8_font_chroma48medium8_r); 36 | 37 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 38 | u8x8log.setRedrawMode(1); // 0: Update screen with newline, 1: Update screen for every char 39 | 40 | // put your setup code here, to run once: 41 | /* Serial2 Initialization */ 42 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 43 | DebugSerial.begin(115200); 44 | 45 | DebugSerial.println("TYPE1SC Module Start!!!"); 46 | u8x8log.print("TYPE1SC Module Start!!!\n"); 47 | 48 | extAntenna(); 49 | 50 | /* TYPE1SC Module Initialization */ 51 | if (TYPE1SC.init()) { 52 | DebugSerial.println("TYPE1SC Module Error!!!"); 53 | u8x8log.print("TYPE1SC Module Error!!!\n"); 54 | } 55 | 56 | /* Network Registration Check */ 57 | while (TYPE1SC.canConnect() != 0) { 58 | DebugSerial.println("Network not Ready !!!"); 59 | u8x8log.print("Network not Ready !!!\n"); 60 | delay(2000); 61 | } 62 | 63 | DebugSerial.println("TYPE1SC Module Ready!!!"); 64 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 65 | 66 | /* Enter a DNS address to get an IP address */ 67 | char IPAddr[32]; 68 | 69 | while (1) { 70 | 71 | if (TYPE1SC.getIPAddr("echo.mbedcloudtesting.com", IPAddr, 72 | sizeof(IPAddr)) == 0) { 73 | DebugSerial.print("IP Address : "); 74 | DebugSerial.println(IPAddr); 75 | u8x8log.print("IP Address : "); 76 | u8x8log.print(IPAddr); 77 | u8x8log.print("\n"); 78 | break; 79 | } else { 80 | DebugSerial.println("IP Address Error!!!"); 81 | u8x8log.print("IP Address Error!!!\n"); 82 | } 83 | delay(2000); 84 | } 85 | 86 | int _PORT = 7; 87 | char sckInfo[128]; 88 | 89 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 90 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) { 91 | DebugSerial.println("TCP Socket Create!!!"); 92 | u8x8log.print("TCP Socket Create!!!\n"); 93 | } 94 | 95 | INFO: 96 | 97 | /* 2 :TCP Socket Activation */ 98 | if (TYPE1SC.socketActivate() == 0) { 99 | DebugSerial.println("TCP Socket Activation!!!"); 100 | u8x8log.print("TCP Socket Activation!!!\n"); 101 | } 102 | 103 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 104 | DebugSerial.print("Socket Info : "); 105 | DebugSerial.println(sckInfo); 106 | u8x8log.print("Socket Info : "); 107 | u8x8log.print(sckInfo); 108 | u8x8log.print("\n"); 109 | if (strcmp(sckInfo, "ACTIVATED")) { 110 | delay(3000); 111 | goto INFO; 112 | } 113 | } 114 | 115 | /* 3 :TCP Socket Send Data */ 116 | char sendBuffer[] = "Hello CodeZoo!!!"; 117 | char recvBuffer[32]; 118 | int recvSize; 119 | 120 | if (TYPE1SC.socketSend(sendBuffer) == 0) { 121 | DebugSerial.print("[Send] >> "); 122 | DebugSerial.println(sendBuffer); 123 | u8x8log.print("[Send] >> "); 124 | u8x8log.print(sendBuffer); 125 | u8x8log.print("\n"); 126 | } else { 127 | DebugSerial.println("Send Fail!!!"); 128 | u8x8log.print("Send Fail!!!\n"); 129 | } 130 | 131 | /* 4 :TCP Socket Recv Data */ 132 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 133 | DebugSerial.print("[Recv] >> "); 134 | DebugSerial.println(recvBuffer); 135 | DebugSerial.print("[RecvSize] >> "); 136 | DebugSerial.println(recvSize); 137 | u8x8log.print("[Recv] >> "); 138 | u8x8log.print(recvBuffer); 139 | u8x8log.print("\n"); 140 | u8x8log.print("[RecvSize] >> "); 141 | u8x8log.print(recvSize); 142 | u8x8log.print("\n"); 143 | } else { 144 | DebugSerial.println("Recv Fail!!!"); 145 | u8x8log.print("Recv Fail!!!\n"); 146 | } 147 | 148 | /* 5 :TCP Socket DeActivation */ 149 | if (TYPE1SC.socketDeActivate() == 0) { 150 | DebugSerial.println("TCP Socket DeActivation!!!"); 151 | u8x8log.print("TCP Socket DeActivation!!!\n"); 152 | } 153 | 154 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 155 | DebugSerial.print("Socket Info : "); 156 | DebugSerial.println(sckInfo); 157 | u8x8log.print("Socket Info : "); 158 | u8x8log.print(sckInfo); 159 | u8x8log.print("\n"); 160 | } 161 | 162 | /* 6 :TCP Socket DeActivation */ 163 | if (TYPE1SC.socketClose() == 0) { 164 | DebugSerial.println("TCP Socket Close!!!"); 165 | u8x8log.print("TCP Socket Close!!!\n"); 166 | } 167 | 168 | /* 7 :Detach Network */ 169 | if (TYPE1SC.setCFUN(0) == 0) { 170 | DebugSerial.println("detach Network!!!"); 171 | u8x8log.print("detach Network!!!\n"); 172 | } 173 | delay(10000); // Detach Setup Time : 10sec 174 | } 175 | 176 | void loop() { delay(1000); } 177 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_TLS_Socket_HTTPS_GET/TYPE1SC_TLS_Socket_HTTPS_GET.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | 5 | #define DebugSerial Serial 6 | #define PWR_PIN 5 7 | #define RST_PIN 18 8 | #define WAKEUP_PIN 19 9 | #define EXT_ANT 4 10 | 11 | #define PROFILE_ID 2 12 | 13 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 14 | HardwareSerial M1Serial(2); // use ESP32 UART2 15 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 16 | 17 | int recvCnt = 0; 18 | 19 | #define U8LOG_WIDTH 16 20 | #define U8LOG_HEIGHT 8 21 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 22 | U8X8LOG u8x8log; 23 | 24 | /* EXT_ANT_ON 0 : Use an internal antenna. 25 | * EXT_ANT_ON 1 : Use an external antenna. 26 | */ 27 | #define EXT_ANT_ON 0 28 | 29 | void extAntenna() { 30 | if (EXT_ANT_ON) { 31 | pinMode(EXT_ANT, OUTPUT); 32 | digitalWrite(EXT_ANT, HIGH); 33 | delay(100); 34 | } 35 | } 36 | 37 | void setup() { 38 | u8x8.begin(); 39 | u8x8.setFont(u8x8_font_chroma48medium8_r); 40 | 41 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 42 | u8x8log.setRedrawMode(1); // 0: Update screen with newline, 1: Update screen for every char 43 | 44 | // put your setup code here, to run once: 45 | /* Serial2 Initialization */ 46 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 47 | DebugSerial.begin(115200); 48 | DebugSerial.println("TYPE1SC Module Start!!!"); 49 | u8x8log.print("TYPE1SC Module Start!!!\n"); 50 | 51 | extAntenna(); 52 | /* Board Reset */ 53 | TYPE1SC.reset(); 54 | delay(2000); 55 | 56 | /* TYPE1SC Module Initialization */ 57 | if (TYPE1SC.init()) { 58 | DebugSerial.println("TYPE1SC Module Error!!!"); 59 | u8x8log.print("TYPE1SC Module Error!!!\n"); 60 | } 61 | /* Network Registration Check */ 62 | while (TYPE1SC.canConnect() != 0) { 63 | DebugSerial.println("Network not Ready !!!"); 64 | u8x8log.print("Network not Ready !!!\n"); 65 | delay(2000); 66 | } 67 | DebugSerial.println("TYPE1SC Module Ready!!!"); 68 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 69 | 70 | /* Enter a DNS address */ 71 | char IPAddr[] = "httpbin.org"; 72 | int _PORT = 443; /* https default port */ 73 | char sckInfo[128]; 74 | char recvBuffer[1500]; 75 | int recvSize = 0; 76 | 77 | /* 0 :Socket All Event Enable */ 78 | if (TYPE1SC.setSocket_EV(1) == 0) { 79 | DebugSerial.println("Socket All Event Enable!!!"); 80 | u8x8log.print("Socket All Event Enable!!!\n"); 81 | } 82 | 83 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 84 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) { 85 | DebugSerial.println("TCP Socket Create!!!"); 86 | u8x8log.print("TCP Socket Create!!!\n"); 87 | } 88 | 89 | /* 2 :Socket SSL Enabel */ 90 | int tlsProfileNumber = PROFILE_ID; 91 | if (TYPE1SC.socketSSL(tlsProfileNumber) == 0) { 92 | DebugSerial.println("Socket SSL Enable!!!"); 93 | u8x8log.print("Socket SSL Enable!!!\n"); 94 | } 95 | 96 | INFO: 97 | /* 3 :TLS TCP-Socket Activation */ 98 | if (TYPE1SC.socketActivate() == 0) { 99 | DebugSerial.println("TCP Socket Activation!!!"); 100 | u8x8log.print("TCP Socket Activation!!!\n"); 101 | } 102 | 103 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 104 | DebugSerial.print("Socket Info : "); 105 | u8x8log.print("Socket Info : "); 106 | DebugSerial.println(sckInfo); 107 | u8x8log.print(sckInfo); 108 | u8x8log.print("\n"); 109 | if (strcmp(sckInfo, "ACTIVATED")) { 110 | TYPE1SC.socketDeActivate(); 111 | delay(3000); 112 | goto INFO; 113 | } 114 | } 115 | 116 | /* 4 :TLS TCP-Socket Send Data */ 117 | String data = "GET /get HTTP/1.1\r\n"; 118 | data += "Host: httpbin.org\r\n\r\n"; 119 | 120 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 121 | DebugSerial.println("[--- HTTPS Send ---]"); 122 | u8x8log.print("[--- HTTPS Send ---]\n"); 123 | DebugSerial.println(data); 124 | u8x8log.print(data); 125 | u8x8log.print("\n"); 126 | } else{ 127 | DebugSerial.println("Send Fail!!!"); 128 | u8x8log.print("Send Fail!!!\n"); 129 | } 130 | 131 | /* 5 :TLS TCP-Socket Receive Data */ 132 | if (TYPE1SC.socketRecvHTTP(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 133 | DebugSerial.println("[--- HTTPS Receive Start ---]"); 134 | u8x8log.print("[--- HTTPS Receive Start ---]\n"); 135 | //DebugSerial.print("[RecvSize] >> "); 136 | //DebugSerial.println(recvSize); 137 | //DebugSerial.print("[Recv"); 138 | //DebugSerial.print(recvCnt++); 139 | //DebugSerial.print("] >> "); 140 | DebugSerial.println(recvBuffer); 141 | u8x8log.print(recvBuffer); 142 | u8x8log.print("\n"); 143 | do{ 144 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 145 | //DebugSerial.print("[RecvSize] >> "); 146 | //DebugSerial.println(recvSize); 147 | //DebugSerial.print("[Recv"); 148 | //DebugSerial.print(recvCnt++); 149 | //DebugSerial.print("] >> "); 150 | DebugSerial.println(recvBuffer); 151 | u8x8log.print(recvBuffer); 152 | u8x8log.print("\n"); 153 | } 154 | }while (recvSize > 0); 155 | } else { 156 | DebugSerial.println("Recv Fail!!!"); 157 | u8x8log.print("Recv Fail!!!\n"); 158 | } 159 | DebugSerial.println("[--- HTTPS Receive End ---]"); 160 | u8x8log.print("[--- HTTPS Receive End ---]\n"); 161 | 162 | /* 6 :TLS TCP-Socket DeActivation */ 163 | if (TYPE1SC.socketDeActivate() == 0){ 164 | DebugSerial.println("TCP Socket DeActivation!!!"); 165 | u8x8log.print("TCP Socket DeActivation!!!\n"); 166 | } 167 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 168 | DebugSerial.print("Socket Info : "); 169 | u8x8log.print("Socket Info : "); 170 | DebugSerial.println(sckInfo); 171 | u8x8log.print(sckInfo); 172 | u8x8log.print("\n"); 173 | } 174 | 175 | /* 7 :TLS TCP-Socket DeActivation */ 176 | if (TYPE1SC.socketClose() == 0){ 177 | DebugSerial.println("TCP Socket Close!!!"); 178 | u8x8log.print("TCP Socket Close!!!\n"); 179 | } 180 | 181 | /* 8 :Socket All Event Disable */ 182 | if (TYPE1SC.setSocket_EV(0) == 0){ 183 | DebugSerial.println("Socket All Event Disable!!!"); 184 | u8x8log.print("Socket All Event Disable!!!\n"); 185 | } 186 | 187 | delay(10000); 188 | } 189 | void loop() { 190 | delay(1000); 191 | } 192 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_UDP_test/TYPE1SC_UDP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include 3 | #include 4 | 5 | #define DebugSerial Serial 6 | #define PWR_PIN 5 7 | #define RST_PIN 18 8 | #define WAKEUP_PIN 19 9 | #define EXT_ANT 4 10 | 11 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 12 | HardwareSerial M1Serial(2); // use ESP32 UART2 13 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 14 | 15 | #define U8LOG_WIDTH 16 16 | #define U8LOG_HEIGHT 8 17 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 18 | U8X8LOG u8x8log; 19 | 20 | /* EXT_ANT_ON 0 : Use an internal antenna. 21 | * EXT_ANT_ON 1 : Use an external antenna. 22 | */ 23 | #define EXT_ANT_ON 0 24 | 25 | void extAntenna() { 26 | if (EXT_ANT_ON) { 27 | pinMode(EXT_ANT, OUTPUT); 28 | digitalWrite(EXT_ANT, HIGH); 29 | delay(100); 30 | } 31 | } 32 | 33 | void setup() { 34 | u8x8.begin(); 35 | u8x8.setFont(u8x8_font_chroma48medium8_r); 36 | 37 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 38 | u8x8log.setRedrawMode( 39 | 1); // 0: Update screen with newline, 1: Update screen for every char 40 | 41 | // put your setup code here, to run once: 42 | /* Serial2 Initialization */ 43 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 44 | DebugSerial.begin(115200); 45 | 46 | DebugSerial.println("TYPE1SC Module Start!!!"); 47 | u8x8log.print("TYPE1SC Module Start!!!\n"); 48 | 49 | extAntenna(); 50 | 51 | /* TYPE1SC Module Initialization */ 52 | if (TYPE1SC.init()) { 53 | DebugSerial.println("TYPE1SC Module Error!!!"); 54 | u8x8log.print("TYPE1SC Module Error!!!\n"); 55 | } 56 | 57 | /* Network Registration Check */ 58 | while (TYPE1SC.canConnect() != 0) { 59 | DebugSerial.println("Network not Ready!!!"); 60 | u8x8log.print("Network not Ready!!!\n"); 61 | delay(2000); 62 | } 63 | 64 | DebugSerial.println("TYPE1SC Module Ready!!!"); 65 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 66 | 67 | /* Enter a DNS address to get an IP address */ 68 | char IPAddr[32]; 69 | 70 | while (1) { 71 | 72 | if (TYPE1SC.getIPAddr("echo.mbedcloudtesting.com", IPAddr, 73 | sizeof(IPAddr)) == 0) { 74 | DebugSerial.print("IP Address : "); 75 | DebugSerial.println(IPAddr); 76 | u8x8log.print("IP Address : "); 77 | u8x8log.print(IPAddr); 78 | u8x8log.print("\n"); 79 | break; 80 | } else { 81 | DebugSerial.println("IP Address Error!!!"); 82 | u8x8log.print("IP Address Error!!!\n"); 83 | } 84 | delay(2000); 85 | } 86 | 87 | int _PORT = 7; 88 | char sckInfo[128]; 89 | 90 | /* 1 :UDP Socket Create ( 0:UDP, 1:TCP ) */ 91 | if (TYPE1SC.socketCreate(0, IPAddr, _PORT) == 0) { 92 | DebugSerial.println("UDP Socket Create!!!"); 93 | u8x8log.print("UDP Socket Create!!!\n"); 94 | } 95 | 96 | INFO: 97 | 98 | /* 2 :UDP Socket Activation */ 99 | if (TYPE1SC.socketActivate() == 0) { 100 | DebugSerial.println("UDP Socket Activation!!!"); 101 | u8x8log.print("UDP Socket Activation!!!\n"); 102 | } 103 | 104 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 105 | DebugSerial.print("Socket Info : "); 106 | DebugSerial.println(sckInfo); 107 | u8x8log.print("Socket Info : "); 108 | u8x8log.print(sckInfo); 109 | u8x8log.print("\n"); 110 | if (strcmp(sckInfo, "ACTIVATED")) { 111 | delay(3000); 112 | goto INFO; 113 | } 114 | } 115 | 116 | /* 3 :UDP Socket Send Data */ 117 | char sendBuffer[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 118 | char recvBuffer[32]; 119 | int recvSize; 120 | 121 | if (TYPE1SC.socketSend(sendBuffer, sizeof(sendBuffer)) == 0) { 122 | DebugSerial.print("[Send] >> "); 123 | u8x8log.print("[Send] >> "); 124 | for (int i = 0; i < sizeof(sendBuffer); i++) { 125 | DebugSerial.print(sendBuffer[i], DEC); 126 | DebugSerial.print(" "); 127 | u8x8log.print(sendBuffer[i], DEC); 128 | u8x8log.print(" "); 129 | } 130 | DebugSerial.println(""); 131 | u8x8log.print("\n"); 132 | } else { 133 | DebugSerial.println("Send Fail!!!"); 134 | u8x8log.print("Send Fail!!!\n"); 135 | } 136 | 137 | /* 4 :UDP Socket Recv Data */ 138 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 139 | DebugSerial.print("[RecvSize] >> "); 140 | DebugSerial.println(recvSize); 141 | DebugSerial.print("[Recv] >> "); 142 | u8x8log.print("[RecvSize] >> "); 143 | u8x8log.print(recvSize); 144 | u8x8log.print("\n"); 145 | u8x8log.print("[Recv] >> "); 146 | 147 | for (int i = 0; i < recvSize; i++) { 148 | DebugSerial.print(recvBuffer[i], DEC); 149 | DebugSerial.print(" "); 150 | u8x8log.print(recvBuffer[i], DEC); 151 | u8x8log.print(" "); 152 | } 153 | DebugSerial.println(""); 154 | u8x8log.print("\n"); 155 | } else { 156 | DebugSerial.println("Recv Fail!!!"); 157 | u8x8log.print("Recv Fail!!!\n"); 158 | } 159 | 160 | /* 5 :UDP Socket DeActivation */ 161 | if (TYPE1SC.socketDeActivate() == 0) { 162 | DebugSerial.println("UDP Socket DeActivation!!!"); 163 | u8x8log.print("UDP Socket DeActivation!!!\n"); 164 | } 165 | 166 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 167 | DebugSerial.print("Socket Info : "); 168 | DebugSerial.println(sckInfo); 169 | u8x8log.print("Socket Info : "); 170 | u8x8log.print(sckInfo); 171 | u8x8log.print("\n"); 172 | } 173 | 174 | /* 6 :UDP Socket DeActivation */ 175 | if (TYPE1SC.socketClose() == 0) { 176 | DebugSerial.println("UDP Socket Close!!!"); 177 | u8x8log.print("UDP Socket Close!!!\n"); 178 | } 179 | 180 | /* 7 :Detach Network */ 181 | if (TYPE1SC.setCFUN(0) == 0) { 182 | DebugSerial.println("detach Network!!!"); 183 | u8x8log.print("detach Network!!!\n"); 184 | } 185 | delay(10000); // Detach Setup Time : 10sec 186 | } 187 | 188 | void loop() { delay(1000); } 189 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_WRITE_HTTPS_CERT/TYPE1SC_WRITE_HTTPS_CERT.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #include "http_credentials.h" 4 | #include 5 | #include 6 | 7 | #define DebugSerial Serial 8 | #define PWR_PIN 5 9 | #define RST_PIN 18 10 | #define WAKEUP_PIN 19 11 | #define EXT_ANT 4 12 | 13 | #define PROFILE_ID 2 14 | 15 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 16 | HardwareSerial M1Serial(2); // use ESP32 UART2 17 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 18 | 19 | #define U8LOG_WIDTH 16 20 | #define U8LOG_HEIGHT 8 21 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 22 | U8X8LOG u8x8log; 23 | 24 | /* EXT_ANT_ON 0 : Use an internal antenna. 25 | * EXT_ANT_ON 1 : Use an external antenna. 26 | */ 27 | #define EXT_ANT_ON 0 28 | 29 | void extAntenna() { 30 | if (EXT_ANT_ON) { 31 | pinMode(EXT_ANT, OUTPUT); 32 | digitalWrite(EXT_ANT, HIGH); 33 | delay(100); 34 | } 35 | } 36 | 37 | void setup() { 38 | u8x8.begin(); 39 | u8x8.setFont(u8x8_font_chroma48medium8_r); 40 | 41 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 42 | u8x8log.setRedrawMode( 43 | 1); // 0: Update screen with newline, 1: Update screen for every char 44 | 45 | /* Serial2 Initialization */ 46 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 47 | DebugSerial.begin(115200); 48 | 49 | DebugSerial.println("TYPE1SC Module Start!!!"); 50 | u8x8log.print("TYPE1SC Module Start!!!\n"); 51 | 52 | extAntenna(); 53 | 54 | /* Board Reset */ 55 | TYPE1SC.reset(); 56 | delay(2000); 57 | 58 | /* TYPE1SC Module Initialization */ 59 | if (TYPE1SC.init()) { 60 | DebugSerial.println("TYPE1SC Module Error!!!"); 61 | u8x8log.print("TYPE1SC Module Error!!!\n"); 62 | } 63 | 64 | /* Network Registration Check */ 65 | while (TYPE1SC.canConnect() != 0) { 66 | DebugSerial.println("Network not Ready !!!"); 67 | u8x8log.print("Network not Ready!!!\n"); 68 | delay(2000); 69 | } 70 | 71 | DebugSerial.println("TYPE1SC Module Ready!!!"); 72 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 73 | 74 | /* DELETE Certification Profile 1-255 */ 75 | int delProfile = PROFILE_ID; 76 | if (TYPE1SC.delCert(delProfile) == 0) { 77 | DebugSerial.println("Delete Certification in Profile.."); 78 | u8x8log.print("Delete Certification Profile!!!\n"); 79 | } 80 | delay(2000); 81 | 82 | /* Write server CA, Don't edit the file name */ 83 | if (TYPE1SC.writeKEY("server.crt", 0, serverCrt) == 0) { 84 | DebugSerial.println("Server CA Write!!!"); 85 | u8x8log.print("Server CA Write!!!\n"); 86 | } 87 | delay(5000); 88 | 89 | /* ADD Certification Profile 1-255 */ 90 | int addProfile = PROFILE_ID; 91 | if (TYPE1SC.addHTTPCert(addProfile) == 0) { 92 | DebugSerial.println("ADD Server Certification in Profile.."); 93 | u8x8log.print("ADD Certification Profile!!!\n"); 94 | } 95 | } 96 | 97 | void loop() { delay(1000); } 98 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_WRITE_HTTPS_CERT/http_credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTP_CREDENTIALS_H 2 | #define HTTP_CREDENTIALS_H 3 | 4 | const char serverCrt[] = "-----BEGIN CERTIFICATE-----\n" 5 | "MIIEXjCCA0agAwIBAgITB3MSSkvL1E7HtTvq8ZSELToPoTANBgkqhkiG9w0BAQsF\n" 6 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" 7 | "b24gUm9vdCBDQSAxMB4XDTIyMDgyMzIyMjUzMFoXDTMwMDgyMzIyMjUzMFowPDEL\n" 8 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEcMBoGA1UEAxMTQW1hem9uIFJT\n" 9 | "QSAyMDQ4IE0wMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALtDGMZa\n" 10 | "qHneKei1by6+pUPPLljTB143Si6VpEWPc6mSkFhZb/6qrkZyoHlQLbDYnI2D7hD0\n" 11 | "sdzEqfnuAjIsuXQLG3A8TvX6V3oFNBFVe8NlLJHvBseKY88saLwufxkZVwk74g4n\n" 12 | "WlNMXzla9Y5F3wwRHwMVH443xGz6UtGSZSqQ94eFx5X7Tlqt8whi8qCaKdZ5rNak\n" 13 | "+r9nUThOeClqFd4oXych//Rc7Y0eX1KNWHYSI1Nk31mYgiK3JvH063g+K9tHA63Z\n" 14 | "eTgKgndlh+WI+zv7i44HepRZjA1FYwYZ9Vv/9UkC5Yz8/yU65fgjaE+wVHM4e/Yy\n" 15 | "C2osrPWE7gJ+dXMCAwEAAaOCAVowggFWMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYD\n" 16 | "VR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNV\n" 17 | "HQ4EFgQUwDFSzVpQw4J8dHHOy+mc+XrrguIwHwYDVR0jBBgwFoAUhBjMhTTsvAyU\n" 18 | "lC4IWZzHshBOCggwewYIKwYBBQUHAQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8v\n" 19 | "b2NzcC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDov\n" 20 | "L2NydC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8E\n" 21 | "ODA2MDSgMqAwhi5odHRwOi8vY3JsLnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jv\n" 22 | "b3RjYTEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IB\n" 23 | "AQAtTi6Fs0Azfi+iwm7jrz+CSxHH+uHl7Law3MQSXVtR8RV53PtR6r/6gNpqlzdo\n" 24 | "Zq4FKbADi1v9Bun8RY8D51uedRfjsbeodizeBB8nXmeyD33Ep7VATj4ozcd31YFV\n" 25 | "fgRhvTSxNrrTlNpWkUk0m3BMPv8sg381HhA6uEYokE5q9uws/3YkKqRiEz3TsaWm\n" 26 | "JqIRZhMbgAfp7O7FUwFIb7UIspogZSKxPIWJpxiPo3TcBambbVtQOcNRWz5qCQdD\n" 27 | "slI2yayq0n2TXoHyNCLEH8rpsJRVILFsg0jc7BaFrMnF462+ajSehgj12IidNeRN\n" 28 | "4zl+EoNaWdpnWndvSpAEkq2P\n" 29 | "-----END CERTIFICATE-----"; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_WRITE_KEY/TYPE1SC_WRITE_KEY.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include "aws_credentials.h" 3 | #include 4 | #include 5 | 6 | #define DebugSerial Serial 7 | #define PWR_PIN 5 8 | #define RST_PIN 18 9 | #define WAKEUP_PIN 19 10 | #define EXT_ANT 4 11 | 12 | U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); 13 | HardwareSerial M1Serial(2); // use ESP32 UART2 14 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 15 | 16 | #define U8LOG_WIDTH 16 17 | #define U8LOG_HEIGHT 8 18 | uint8_t u8log_buffer[U8LOG_WIDTH * U8LOG_HEIGHT]; 19 | U8X8LOG u8x8log; 20 | 21 | /* EXT_ANT_ON 0 : Use an internal antenna. 22 | * EXT_ANT_ON 1 : Use an external antenna. 23 | */ 24 | #define EXT_ANT_ON 0 25 | 26 | void extAntenna() { 27 | if (EXT_ANT_ON) { 28 | pinMode(EXT_ANT, OUTPUT); 29 | digitalWrite(EXT_ANT, HIGH); 30 | delay(100); 31 | } 32 | } 33 | 34 | void setup() { 35 | u8x8.begin(); 36 | u8x8.setFont(u8x8_font_chroma48medium8_r); 37 | 38 | u8x8log.begin(u8x8, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); 39 | u8x8log.setRedrawMode( 40 | 1); // 0: Update screen with newline, 1: Update screen for every char 41 | 42 | /* Serial2 Initialization */ 43 | M1Serial.begin(115200, SERIAL_8N1, 16, 17); // RXD2 : 16, TXD2 : 17 44 | DebugSerial.begin(115200); 45 | 46 | DebugSerial.println("TYPE1SC Module Start!!!"); 47 | u8x8log.print("TYPE1SC Module Start!!!\n"); 48 | 49 | extAntenna(); 50 | 51 | /* Board Reset */ 52 | TYPE1SC.reset(); 53 | delay(2000); 54 | 55 | /* TYPE1SC Module Initialization */ 56 | if (TYPE1SC.init()) { 57 | DebugSerial.println("TYPE1SC Module Error!!!"); 58 | u8x8log.print("TYPE1SC Module Error!!!\n"); 59 | } 60 | 61 | /* Network Registration Check */ 62 | while (TYPE1SC.canConnect() != 0) { 63 | DebugSerial.println("Network not Ready!!!"); 64 | u8x8log.print("Network not Ready!!!\n"); 65 | delay(2000); 66 | } 67 | 68 | DebugSerial.println("TYPE1SC Module Ready!!!"); 69 | u8x8log.print("TYPE1SC Module Ready!!!\n"); 70 | 71 | /* DELETE Certification Profile 1-255 */ 72 | int delProfile = 9; 73 | if (TYPE1SC.delCert(delProfile) == 0) { 74 | DebugSerial.println("Delete Certification Profile!!!"); 75 | u8x8log.print("Delete Certification Profile!!!\n"); 76 | } 77 | delay(2000); 78 | 79 | /* Write root CA, Don't edit the file name */ 80 | if (TYPE1SC.writeKEY("rootCA.pem", 0, rootCA) == 0) { 81 | DebugSerial.println("Root CA Write!!!"); 82 | u8x8log.print("Root CA Write!!!\n"); 83 | } 84 | delay(5000); 85 | 86 | /* Write client CA, Don't edit the file name */ 87 | if (TYPE1SC.writeKEY("cert.pem.crt", 0, clientCrt) == 0) { 88 | DebugSerial.println("Client CA Write!!!"); 89 | u8x8log.print("Client CA Write!!!\n"); 90 | } 91 | delay(5000); 92 | 93 | /* Write client KEY, Don't edit the file name */ 94 | if (TYPE1SC.writeKEY("private.pem.key", 1, clientKey) == 0) { 95 | DebugSerial.println("Client KEY Write!!!"); 96 | u8x8log.print("Client KEY Write!!!\n"); 97 | } 98 | delay(5000); 99 | 100 | /* ADD Certification Profile 1-255 */ 101 | int addProfile = 9; 102 | if (TYPE1SC.addCert(addProfile) == 0) { 103 | DebugSerial.println("ADD Certification Profile!!!"); 104 | u8x8log.print("ADD Certification Profile!!!\n"); 105 | } 106 | } 107 | 108 | void loop() { delay(1000); } 109 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_WRITE_KEY/aws_credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef AWS_CREDENTIALS_H 2 | #define AWS_CREDENTIALS_H 3 | const char rootCA[] = "-----BEGIN CERTIFICATE-----\n" 4 | "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" 5 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" 6 | "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" 7 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" 8 | "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" 9 | "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" 10 | "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" 11 | "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" 12 | "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" 13 | "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" 14 | "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" 15 | "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" 16 | "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" 17 | "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" 18 | "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" 19 | "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" 20 | "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" 21 | "rqXRfboQnoZsG4q5WTP468SQvvG5\n" 22 | "-----END CERTIFICATE-----"; 23 | 24 | const char clientCrt[] = "-----BEGIN CERTIFICATE-----\n" 25 | "\n" 26 | "\n" 27 | "\n" 28 | "\n" 29 | "\n" 30 | "\n" 31 | "\n" 32 | "\n" 33 | "\n" 34 | "\n" 35 | "\n" 36 | "\n" 37 | "\n" 38 | "\n" 39 | "\n" 40 | "\n" 41 | "\n" 42 | "\n" 43 | "-----END CERTIFICATE-----"; 44 | 45 | const char clientKey[] = "-----BEGIN RSA PRIVATE KEY-----\n" 46 | "\n" 47 | "\n" 48 | "\n" 49 | "\n" 50 | "\n" 51 | "\n" 52 | "\n" 53 | "\n" 54 | "\n" 55 | "\n" 56 | "\n" 57 | "\n" 58 | "\n" 59 | "\n" 60 | "\n" 61 | "\n" 62 | "\n" 63 | "\n" 64 | "\n" 65 | "\n" 66 | "\n" 67 | "\n" 68 | "\n" 69 | "\n" 70 | "\n" 71 | "-----END RSA PRIVATE KEY-----"; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /examples/ESP32_IoT/TYPE1SC_button_interrupt/TYPE1SC_button_interrupt.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define SW_01 26 5 | #define BATT_ADC 35 6 | #define AVGCNT 30 7 | 8 | int btn1 = 0; 9 | unsigned long button_time1 = 0; 10 | unsigned long last_button_time1 = 0; 11 | 12 | // Pressed for more than 300ms 13 | void IRAM_ATTR SW01_ISR() { 14 | button_time1 = millis(); 15 | if (button_time1 - last_button_time1 > 300) { 16 | btn1 = 1; 17 | last_button_time1 = button_time1; 18 | } 19 | } 20 | 21 | float readBattery() { 22 | uint8_t samples = AVGCNT; 23 | float array[AVGCNT]; 24 | float batt_adc = 0; 25 | 26 | for (int i = 0; i < samples; i++) { 27 | int vref = 3300; 28 | uint16_t volt = analogRead(BATT_ADC); 29 | float battery_voltage = ((float)volt / 4095.0) * (vref)*2; 30 | 31 | array[i] = battery_voltage; 32 | delay(10); 33 | } 34 | 35 | std::sort(array, array + samples); 36 | for (int i = 0; i < samples; i++) { 37 | if (i == 0 || i == samples - 1) 38 | continue; 39 | batt_adc += array[i]; 40 | } 41 | 42 | batt_adc /= samples - 2; 43 | return batt_adc; 44 | } 45 | 46 | void setup() { 47 | // put your setup code here, to run once: 48 | Serial.begin(115200); 49 | delay(1000); 50 | Serial.println("hello button"); 51 | pinMode(SW_01, INPUT_PULLUP); 52 | attachInterrupt(digitalPinToInterrupt(SW_01), SW01_ISR, FALLING); 53 | } 54 | 55 | void loop() { 56 | // put your main code here, to run repeatedly: 57 | if (btn1 == 1) // SW1 interrupt 58 | { 59 | float battery_voltage = readBattery(); 60 | btn1 = 0; 61 | Serial.println("Switch_1 Pressed"); 62 | Serial.print("BATTERY : "); 63 | Serial.println(battery_voltage); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_AWSIOT_SiteWise_demo/TYPE1SC_AWSIOT_SiteWise_demo.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include //https://github.com/GyverLibs/UnixTime 3 | 4 | #define DebugSerial Serial 5 | #define M1Serial Serial1 // RPI_PICO 6 | 7 | #define PWR_PIN 4 8 | #define RST_PIN 5 9 | #define WAKEUP_PIN 6 10 | 11 | #define DHTPIN A0 12 | // AM2302(DHT22) Temperature & Humidity Sensor 13 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 14 | // Uncomment whatever type you're using! 15 | //#define DHTTYPE DHT11 // DHT 11 16 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 17 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 18 | 19 | DHT dht(DHTPIN, DHTTYPE); 20 | UnixTime stamp(9); // Seoul GMT + 09 21 | 22 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 23 | 24 | void setup() { 25 | pinMode(LED_BUILTIN, OUTPUT); 26 | digitalWrite(LED_BUILTIN, HIGH); 27 | 28 | /* DHT22 Sensor Initialization */ 29 | dht.begin(); 30 | delay(2000); 31 | // put your setup code here, to run once: 32 | M1Serial.begin(115200); 33 | DebugSerial.begin(115200); 34 | 35 | DebugSerial.println("TYPE1SC Module Start!!!"); 36 | /* Board Reset */ 37 | TYPE1SC.reset(); 38 | delay(2000); 39 | 40 | /* TYPE1SC Module Initialization */ 41 | if (TYPE1SC.init()) { 42 | DebugSerial.println("TYPE1SC Module Error!!!"); 43 | } 44 | 45 | /* Network Registration Check */ 46 | while (TYPE1SC.canConnect() != 0) { 47 | DebugSerial.println("Network not Ready !!!"); 48 | delay(2000); 49 | } 50 | 51 | DebugSerial.println("TYPE1SC Module Ready!!!"); 52 | 53 | /* Device Data EndPoint Address AWS IoT > Settings > Device data endpoint > 54 | * Copy&Paste */ 55 | char _IP[] = "*****.amazonaws.com"; 56 | 57 | char _NodeID[] = "MCU_AI_Things"; 58 | char _Topic[] = "iot/topic"; 59 | char _message[512]; 60 | int tlsProfile = 9; 61 | int conn_timeout = 1200; 62 | float t = 0.0; // Stores temperature value 63 | float h = 0.0; // Stores humidity value 64 | char temp[8]; 65 | char humi[8]; 66 | 67 | /* 1 : Configure AWS_IOT parameters (ID, Address, tlsProfile) */ 68 | if (TYPE1SC.setAWSIOT_CONN(_NodeID, _IP, tlsProfile) == 0) 69 | DebugSerial.println( 70 | "1.Configure AWS_IOT parameter:ID, Address, tls Profile"); 71 | 72 | /* 2 : Configure AWS_IOT parameters (Connection Timeout) */ 73 | if (TYPE1SC.setAWSIOT_TIMEOUT(conn_timeout) == 0) 74 | DebugSerial.println("2.Configure AWS_IOT parameter:Timeout"); 75 | 76 | /* 3 : Enable AWS_IOT events */ 77 | if (TYPE1SC.setAWSIOT_EV(1) == 0) 78 | DebugSerial.println("3.Enable AWS_IOT events"); 79 | 80 | /* 4 : Establish connection */ 81 | if (TYPE1SC.AWSIOT_Connect() == 0) { 82 | DebugSerial.println("4.Establish connection"); 83 | } 84 | 85 | /* 5 : Subscribe (register) to the topic on the endpoint */ 86 | if (TYPE1SC.AWSIOT_SUBSCRIBE(_Topic) == 0) 87 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 88 | 89 | /*Get Temperature & Humidity */ 90 | while (1) { 91 | /* Get DHT22 Sensor */ 92 | t = dht.readTemperature(); 93 | h = dht.readHumidity(); 94 | if (String(t) != "nan" && String(h) != "nan") 95 | break; 96 | else { 97 | DebugSerial.println("case nan ..."); 98 | delay(1000); 99 | } 100 | } 101 | 102 | dtostrf(t, 4, 1, temp); 103 | dtostrf(h, 4, 1, humi); 104 | 105 | // Make Unix TimeStamp 106 | char szTime[32]; 107 | uint32_t _year, _month, _day, _hour, _minute, _second, _tmp; 108 | 109 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 110 | sscanf(szTime, "\"%d/%d/%d,%d:%d:%d+%d\"", &_year, &_month, &_day, &_hour, 111 | &_minute, &_second, &_tmp); 112 | } 113 | 114 | // Set Date Time 115 | _year += 2000; 116 | stamp.setDateTime(_year, _month, _day, _hour, _minute, _second); 117 | 118 | // Get Unix Time 119 | uint32_t unix = stamp.getUnix(); 120 | 121 | memset(_message, 0x0, sizeof(_message)); 122 | sprintf(_message, 123 | "{\\\"timeInSeconds\\\":\\\"%lu\\\",\\\"Temperature\\\":\\\"%s\\\"," 124 | "\\\"Humidity\\\":\\\"%s\\\"}", 125 | unix, temp, humi); 126 | 127 | /* 6 : Publish data to broker */ 128 | if (TYPE1SC.AWSIOT_Publish(_Topic, _message) == 0) 129 | DebugSerial.println("6.Publish data to broker"); 130 | 131 | /* 7 : UnSubscribe to the topic on the endpoint */ 132 | if (TYPE1SC.AWSIOT_UnSUBSCRIBE(_Topic) == 0) { 133 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 134 | } 135 | 136 | /* 8 : Disconnect AWS_IOT Service */ 137 | if (TYPE1SC.AWSIOT_DisConnect() == 0) 138 | DebugSerial.println("8.Disconnect AWS_IOT Service"); 139 | 140 | /* 9 : Disable AWS_IOT events */ 141 | if (TYPE1SC.setAWSIOT_EV(0) == 0) 142 | DebugSerial.println("9.Disable AWS_IOT events"); 143 | } 144 | 145 | void loop() { delay(1000); } 146 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_AWSIOT_test/TYPE1SC_AWSIOT_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 // RPI_PICO 5 | 6 | #define PWR_PIN 4 7 | #define RST_PIN 5 8 | #define WAKEUP_PIN 6 9 | 10 | #define DHTPIN A0 11 | // AM2302(DHT22) Temperature & Humidity Sensor 12 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 13 | // Uncomment whatever type you're using! 14 | //#define DHTTYPE DHT11 // DHT 11 15 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 16 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 17 | 18 | DHT dht(DHTPIN, DHTTYPE); 19 | 20 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 21 | 22 | void setup() { 23 | pinMode(LED_BUILTIN, OUTPUT); 24 | digitalWrite(LED_BUILTIN, HIGH); 25 | 26 | /* DHT22 Sensor Initialization */ 27 | dht.begin(); 28 | delay(2000); 29 | // put your setup code here, to run once: 30 | M1Serial.begin(115200); 31 | DebugSerial.begin(115200); 32 | 33 | DebugSerial.println("TYPE1SC Module Start!!!"); 34 | /* Board Reset */ 35 | TYPE1SC.reset(); 36 | delay(2000); 37 | 38 | /* TYPE1SC Module Initialization */ 39 | if (TYPE1SC.init()) { 40 | DebugSerial.println("TYPE1SC Module Error!!!"); 41 | } 42 | 43 | /* Network Registration Check */ 44 | while (TYPE1SC.canConnect() != 0) { 45 | DebugSerial.println("Network not Ready !!!"); 46 | delay(2000); 47 | } 48 | 49 | DebugSerial.println("TYPE1SC Module Ready!!!"); 50 | 51 | /* Device Data EndPoint Address AWS IoT > Settings > Device data endpoint > 52 | * Copy&Paste */ 53 | char _IP[] = "*****.amazonaws.com"; 54 | 55 | char _NodeID[] = "Murata_Node01"; 56 | char _Topic[] = "sdkTest/sub"; 57 | char _message[64]; 58 | int tlsProfile = 9; 59 | int conn_timeout = 1200; 60 | float t = 0.0; // Stores temperature value 61 | float h = 0.0; // Stores humidity value 62 | char temp[8]; 63 | char humi[8]; 64 | 65 | /* 1 : Configure AWS_IOT parameters (ID, Address, tlsProfile) */ 66 | if (TYPE1SC.setAWSIOT_CONN(_NodeID, _IP, tlsProfile) == 0) 67 | DebugSerial.println( 68 | "1.Configure AWS_IOT parameter:ID, Address, tls Profile"); 69 | 70 | /* 2 : Configure AWS_IOT parameters (Connection Timeout) */ 71 | if (TYPE1SC.setAWSIOT_TIMEOUT(conn_timeout) == 0) 72 | DebugSerial.println("2.Configure AWS_IOT parameter:Timeout"); 73 | 74 | /* 3 : Enable AWS_IOT events */ 75 | if (TYPE1SC.setAWSIOT_EV(1) == 0) 76 | DebugSerial.println("3.Enable AWS_IOT events"); 77 | 78 | /* 4 : Establish connection */ 79 | if (TYPE1SC.AWSIOT_Connect() == 0) { 80 | DebugSerial.println("4.Establish connection"); 81 | } 82 | 83 | /* 5 : Subscribe (register) to the topic on the endpoint */ 84 | if (TYPE1SC.AWSIOT_SUBSCRIBE(_Topic) == 0) 85 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 86 | 87 | /*Get Temperature & Humidity */ 88 | while (1) { 89 | /* Get DHT22 Sensor */ 90 | t = dht.readTemperature(); 91 | h = dht.readHumidity(); 92 | if (String(t) != "nan" && String(h) != "nan") 93 | break; 94 | else { 95 | DebugSerial.println("case nan ..."); 96 | delay(1000); 97 | } 98 | } 99 | 100 | dtostrf(t, 4, 1, temp); 101 | dtostrf(h, 4, 1, humi); 102 | 103 | memset(_message, 0x0, sizeof(_message)); 104 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 105 | 106 | /* 6 : Publish data to broker */ 107 | if (TYPE1SC.AWSIOT_Publish(_Topic, _message) == 0) 108 | DebugSerial.println("6.Publish data to broker"); 109 | 110 | /* 7 : UnSubscribe to the topic on the endpoint */ 111 | if (TYPE1SC.AWSIOT_UnSUBSCRIBE(_Topic) == 0) { 112 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 113 | } 114 | 115 | /* 8 : Disconnect AWS_IOT Service */ 116 | if (TYPE1SC.AWSIOT_DisConnect() == 0) 117 | DebugSerial.println("8.Disconnect AWS_IOT Service"); 118 | 119 | /* 9 : Disable AWS_IOT events */ 120 | if (TYPE1SC.setAWSIOT_EV(0) == 0) 121 | DebugSerial.println("9.Disable AWS_IOT events"); 122 | } 123 | 124 | void loop() { delay(1000); } 125 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_Basic_test/TYPE1SC_Basic_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 // RPI_PICO 5 | 6 | #define PWR_PIN 4 7 | #define RST_PIN 5 8 | #define WAKEUP_PIN 6 9 | 10 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 11 | 12 | void setup() { 13 | pinMode(LED_BUILTIN, OUTPUT); 14 | digitalWrite(LED_BUILTIN, HIGH); 15 | // put your setup code here, to run once: 16 | M1Serial.begin(115200); 17 | DebugSerial.begin(115200); 18 | 19 | DebugSerial.println("TYPE1SC Module Start!!!"); 20 | /* Board Reset */ 21 | TYPE1SC.reset(); 22 | delay(2000); 23 | 24 | /* TYPE1SC Module Initialization */ 25 | if (TYPE1SC.init()) { 26 | DebugSerial.println("TYPE1SC Module Error!!!"); 27 | } 28 | 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | } 37 | 38 | void loop() { 39 | /*** TYPE1SC Basic Test Code ***/ 40 | /* SIM Card Check */ 41 | if (!TYPE1SC.chkSIM()) { 42 | DebugSerial.println("SIM Card OK!!!"); 43 | } 44 | delay(1000); 45 | 46 | /* Get Phone Number */ 47 | char szCIMI[16]; 48 | if (TYPE1SC.getCIMI(szCIMI, sizeof(szCIMI)) == 0) { 49 | DebugSerial.print("CIMI : "); 50 | DebugSerial.println(szCIMI); 51 | } 52 | delay(1000); 53 | 54 | char szIMEI[16]; 55 | if (TYPE1SC.getIMEI(szIMEI, sizeof(szIMEI)) == 0) { 56 | DebugSerial.print("IMEI : "); 57 | DebugSerial.println(szIMEI); 58 | } 59 | delay(1000); 60 | 61 | /* Get Fimrware version */ 62 | char szCGMR[20]; 63 | if (TYPE1SC.getCGMR(szCGMR, sizeof(szCGMR)) == 0) { 64 | DebugSerial.print("CGMR : "); 65 | DebugSerial.println(szCGMR); 66 | } 67 | delay(1000); 68 | 69 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 70 | char szTime[32]; 71 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 72 | DebugSerial.print("Time : "); 73 | DebugSerial.println(szTime); 74 | } 75 | delay(1000); 76 | 77 | /* Get RSSI */ 78 | int rssi; 79 | if (TYPE1SC.getRSSI(&rssi) == 0) { 80 | DebugSerial.print("RSSI : "); 81 | DebugSerial.println(rssi); 82 | } 83 | delay(1000); 84 | 85 | /* Get RSRP */ 86 | int rsrp; 87 | if (TYPE1SC.getRSRP(&rsrp) == 0) { 88 | DebugSerial.print("RSRP : "); 89 | DebugSerial.println(rsrp); 90 | } 91 | delay(1000); 92 | 93 | /* Get RSRQ */ 94 | int rsrq; 95 | if (TYPE1SC.getRSRQ(&rsrq) == 0) { 96 | DebugSerial.print("RSRQ : "); 97 | DebugSerial.println(rsrq); 98 | } 99 | delay(1000); 100 | 101 | /* Get SINR */ 102 | int sinr; 103 | if (TYPE1SC.getSINR(&sinr) == 0) { 104 | DebugSerial.print("SINR : "); 105 | DebugSerial.println(sinr); 106 | } 107 | delay(1000); 108 | 109 | /* Get TX Power */ 110 | char txPower[64]; 111 | if (TYPE1SC.getTxPower(txPower, sizeof(txPower)) == 0) { 112 | DebugSerial.print("TX Power : "); 113 | DebugSerial.println(txPower); 114 | } 115 | delay(1000); 116 | } 117 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_GET_UnixTime/TYPE1SC_GET_UnixTime.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include //https://github.com/GyverLibs/UnixTime 3 | 4 | #define DebugSerial Serial 5 | #define M1Serial Serial1 // RPI_PICO 6 | 7 | #define PWR_PIN 4 8 | #define RST_PIN 5 9 | #define WAKEUP_PIN 6 10 | 11 | UnixTime stamp(9); // Seoul GMT + 09 12 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 13 | 14 | void setup() { 15 | pinMode(LED_BUILTIN, OUTPUT); 16 | digitalWrite(LED_BUILTIN, HIGH); 17 | // put your setup code here, to run once: 18 | M1Serial.begin(115200); 19 | DebugSerial.begin(115200); 20 | 21 | DebugSerial.println("TYPE1SC Module Start!!!"); 22 | 23 | /* Board Reset(Using ATCmd) */ 24 | TYPE1SC.reset(); 25 | delay(2000); 26 | 27 | /* TYPE1SC Module Initialization */ 28 | if (TYPE1SC.init()) { 29 | DebugSerial.println("TYPE1SC Module Error!!!"); 30 | } 31 | 32 | /* Network Registration Check */ 33 | while (TYPE1SC.canConnect() != 0) { 34 | DebugSerial.println("Network not Ready !!!"); 35 | delay(2000); 36 | } 37 | 38 | DebugSerial.println("TYPE1SC Module Ready!!!"); 39 | } 40 | 41 | void loop() { 42 | /* Get Time (GMT, (+36/4) ==> Korea +9hour) */ 43 | char szTime[32]; 44 | uint32_t _year, _month, _day, _hour, _minute, _second, _tmp; 45 | 46 | if (TYPE1SC.getCCLK(szTime, sizeof(szTime)) == 0) { 47 | DebugSerial.print("Time : "); 48 | DebugSerial.println(szTime); 49 | sscanf(szTime, "\"%d/%d/%d,%d:%d:%d+%d\"", &_year, &_month, &_day, &_hour, 50 | &_minute, &_second, &_tmp); 51 | /* Debug */ 52 | DebugSerial.println(_year); 53 | DebugSerial.println(_month); 54 | DebugSerial.println(_day); 55 | DebugSerial.println(_hour); 56 | DebugSerial.println(_minute); 57 | DebugSerial.println(_second); 58 | } 59 | // Set Date Time 60 | _year += 2000; 61 | stamp.setDateTime(_year, _month, _day, _hour, _minute, _second); 62 | 63 | // Get Unix Time 64 | uint32_t unix = stamp.getUnix(); 65 | DebugSerial.println(unix); 66 | 67 | // ========== UNIX to date and time =========== 68 | // convert unix to date and time 69 | // getDateTime(unix stamp) runs ~500 us on AVR 70 | // https://www.unixtimestamp.com/index.php 71 | stamp.getDateTime(unix); 72 | 73 | // pick up like this 74 | DebugSerial.println(stamp.year); 75 | DebugSerial.println(stamp.month); 76 | DebugSerial.println(stamp.day); 77 | DebugSerial.println(stamp.hour); 78 | DebugSerial.println(stamp.minute); 79 | DebugSerial.println(stamp.second); 80 | 81 | delay(1000); 82 | } 83 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_HTTP_test/TYPE1SC_HTTP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 // RPI_PICO 5 | 6 | #define PWR_PIN 4 7 | #define RST_PIN 5 8 | #define WAKEUP_PIN 6 9 | 10 | #define DHTPIN A0 11 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 12 | // Uncomment whatever type you're using! 13 | //#define DHTTYPE DHT11 // DHT 11 14 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 15 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 16 | 17 | DHT dht(DHTPIN, DHTTYPE); 18 | 19 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 20 | 21 | void setup() { 22 | pinMode(LED_BUILTIN, OUTPUT); 23 | digitalWrite(LED_BUILTIN, HIGH); 24 | 25 | /* DHT22 Sensor Initialization */ 26 | dht.begin(); 27 | // put your setup code here, to run once: 28 | M1Serial.begin(115200); 29 | DebugSerial.begin(115200); 30 | 31 | DebugSerial.println("TYPE1SC Module Start!!!"); 32 | /* Board Reset */ 33 | TYPE1SC.reset(); 34 | delay(2000); 35 | 36 | /* TYPE1SC Module Initialization */ 37 | if (TYPE1SC.init()) { 38 | DebugSerial.println("TYPE1SC Module Error!!!"); 39 | } 40 | 41 | /* Network Registration Check */ 42 | while (TYPE1SC.canConnect() != 0) { 43 | DebugSerial.println("Network not Ready !!!"); 44 | delay(2000); 45 | } 46 | 47 | DebugSerial.println("TYPE1SC Module Ready!!!"); 48 | 49 | /* Enter a DNS address to get an IP address */ 50 | char IPAddr[32]; 51 | 52 | while (1) { 53 | 54 | if (TYPE1SC.getIPAddr("api.thingspeak.com", IPAddr, sizeof(IPAddr)) == 0) { 55 | DebugSerial.print("IP Address : "); 56 | DebugSerial.println(IPAddr); 57 | break; 58 | } else { 59 | DebugSerial.println("IP Address Error!!!"); 60 | } 61 | delay(2000); 62 | } 63 | 64 | int _PORT = 80; 65 | char sckInfo[128]; 66 | char recvBuffer[700]; 67 | int recvSize; 68 | 69 | String WApiKey = "****************"; // Thing Speak Write API Key 16Character 70 | float temp = 0.0; 71 | float humi = 0.0; 72 | String fieldTemp = "field1"; // Air temperature 73 | String fieldHumi = "field2"; // Air humidity 74 | 75 | /*Get Temperature & Humidity */ 76 | while (1) { 77 | /* Get DHT22 Sensor */ 78 | temp = dht.readTemperature(); 79 | humi = dht.readHumidity(); 80 | if (String(temp) != "nan" && String(humi) != "nan") 81 | break; 82 | else { 83 | DebugSerial.println("case nan ..."); 84 | delay(1000); 85 | } 86 | } 87 | 88 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 89 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 90 | DebugSerial.println("TCP Socket Create!!!"); 91 | 92 | INFO: 93 | 94 | /* 2 :TCP Socket Activation */ 95 | if (TYPE1SC.socketActivate() == 0) 96 | DebugSerial.println("TCP Socket Activation!!!"); 97 | 98 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 99 | DebugSerial.print("Socket Info : "); 100 | DebugSerial.println(sckInfo); 101 | 102 | if (strcmp(sckInfo, "ACTIVATED")) { 103 | delay(3000); 104 | goto INFO; 105 | } 106 | } 107 | 108 | /* 3 :TCP Socket Send Data */ 109 | String data = "GET /update"; 110 | data += "?api_key=" + WApiKey + "&" + fieldTemp + "=" + String(temp) + "&" + 111 | fieldHumi + "=" + String(humi); 112 | data += " HTTP/1.1\r\n"; 113 | data += "Host: api.thingspeak.com\r\n"; 114 | data += "Connection: close\r\n\r\n"; 115 | 116 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 117 | DebugSerial.print("[HTTP Send] >> "); 118 | DebugSerial.println(data); 119 | } else 120 | DebugSerial.println("Send Fail!!!"); 121 | 122 | /* 4 :TCP Socket Recv Data */ 123 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 124 | DebugSerial.print("[Recv] >> "); 125 | DebugSerial.println(recvBuffer); 126 | DebugSerial.print("[RecvSize] >> "); 127 | DebugSerial.println(recvSize); 128 | } else { 129 | DebugSerial.println("Recv Fail!!!"); 130 | } 131 | 132 | /* 5 :TCP Socket DeActivation */ 133 | if (TYPE1SC.socketDeActivate() == 0) 134 | DebugSerial.println("TCP Socket DeActivation!!!"); 135 | 136 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 137 | DebugSerial.print("Socket Info : "); 138 | DebugSerial.println(sckInfo); 139 | } 140 | 141 | /* 6 :TCP Socket DeActivation */ 142 | if (TYPE1SC.socketClose() == 0) 143 | DebugSerial.println("TCP Socket Close!!!"); 144 | } 145 | 146 | void loop() { delay(1000); } 147 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_MQTT_test/TYPE1SC_MQTT_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 // RPI_PICO 5 | 6 | #define PWR_PIN 4 7 | #define RST_PIN 5 8 | #define WAKEUP_PIN 6 9 | 10 | #define DHTPIN A0 11 | #include "DHT.h" /* https://github.com/markruys/arduino-DHT */ 12 | // Uncomment whatever type you're using! 13 | //#define DHTTYPE DHT11 // DHT 11 14 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 15 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 16 | 17 | DHT dht(DHTPIN, DHTTYPE); 18 | 19 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 20 | 21 | void setup() { 22 | pinMode(LED_BUILTIN, OUTPUT); 23 | digitalWrite(LED_BUILTIN, HIGH); 24 | 25 | /* DHT22 Sensor Initialization */ 26 | dht.begin(); 27 | // put your setup code here, to run once: 28 | M1Serial.begin(115200); 29 | DebugSerial.begin(115200); 30 | 31 | DebugSerial.println("TYPE1SC Module Start!!!"); 32 | /* Board Reset */ 33 | TYPE1SC.reset(); 34 | delay(2000); 35 | 36 | /* TYPE1SC Module Initialization */ 37 | if (TYPE1SC.init()) { 38 | DebugSerial.println("TYPE1SC Module Error!!!"); 39 | } 40 | 41 | /* Network Registration Check */ 42 | while (TYPE1SC.canConnect() != 0) { 43 | DebugSerial.println("Network not Ready !!!"); 44 | delay(2000); 45 | } 46 | 47 | DebugSerial.println("TYPE1SC Module Ready!!!"); 48 | 49 | char _IP[] = "broker.hivemq.com"; 50 | char _NodeID[] = "Cellular_node"; 51 | char _Topic[] = "type1sc/0/test"; 52 | char _message[64]; 53 | uint32_t conn_timeout = 1200; 54 | float t = 0.0; 55 | float h = 0.0; 56 | char temp[8]; // Stores temperature value 57 | char humi[8]; // Stores humidity value 58 | 59 | /* 60 | * qos : 0 - at most one delivery (default) 61 | * 1 - Delivered at least once 62 | * 2 - Exactly one delivery 63 | */ 64 | int qos = 0; 65 | 66 | /* 1 : Enable MQTT events */ 67 | if (TYPE1SC.setMQTT_EV(1) == 0) 68 | DebugSerial.println("1.Enable MQTT events"); 69 | 70 | /* 2 : Configure node parameters (ID, Address) */ 71 | if (TYPE1SC.setMQTT_NODES(_NodeID, _IP) == 0) 72 | DebugSerial.println("2.Configure node parameter:ID, Address"); 73 | 74 | /* 3 : Configure node parameters (Connection Timeout) */ 75 | if (TYPE1SC.setMQTT_TIMEOUT(conn_timeout) == 0) 76 | DebugSerial.println("3.Configure node parameter:Timeout"); 77 | 78 | /* 4 : Establish connection */ 79 | if (TYPE1SC.MQTT_Connect() == 0) 80 | DebugSerial.println("4.Establish connection"); 81 | 82 | /* 5 : Subscribe (register) to the topic on the endpoint */ 83 | if (TYPE1SC.MQTT_SUBSCRIBE(qos, _Topic) == 0) 84 | DebugSerial.println("5.Subscribe to the topic on the endpoint"); 85 | 86 | /*Get Temperature & Humidity */ 87 | while (1) { 88 | /* Get DHT22 Sensor */ 89 | t = dht.readTemperature(); 90 | h = dht.readHumidity(); 91 | if (String(t) != "nan" && String(h) != "nan") 92 | break; 93 | else { 94 | DebugSerial.println("case nan ..."); 95 | delay(1000); 96 | } 97 | } 98 | 99 | dtostrf(t, 4, 1, temp); 100 | dtostrf(h, 4, 1, humi); 101 | 102 | memset(_message, 0x0, sizeof(_message)); 103 | sprintf(_message, "Temperature/%s, Humidity/%s", temp, humi); 104 | /* 6 : Publish data to broker */ 105 | if (TYPE1SC.MQTT_Publish(qos, _Topic, strlen(_message), _message) == 0) 106 | DebugSerial.println("6.Publish data to broker"); 107 | 108 | /* 7 : UnSubscribe to the topic on the endpoint */ 109 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 110 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 111 | } else { 112 | delay(1000); 113 | if (TYPE1SC.MQTT_UnSUBSCRIBE(_Topic) == 0) { 114 | DebugSerial.println("7.UnSubscribe to the topic on the endpoint"); 115 | } 116 | } 117 | /* 8 : Disconnect MQTT Server */ 118 | if (TYPE1SC.MQTT_DisConnect() == 0) 119 | DebugSerial.println("8.Disconnect MQTT Server"); 120 | 121 | /* 0 : Disable MQTT events */ 122 | if (TYPE1SC.setMQTT_EV(0) == 0) 123 | DebugSerial.println("9.Disable MQTT events"); 124 | } 125 | 126 | void loop() { delay(1000); } 127 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_SET_APN/TYPE1SC_SET_APN.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 // RPI_PICO 5 | 6 | #define PWR_PIN 4 7 | #define RST_PIN 5 8 | #define WAKEUP_PIN 6 9 | 10 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 11 | 12 | void setup() { 13 | pinMode(LED_BUILTIN, OUTPUT); 14 | digitalWrite(LED_BUILTIN, HIGH); 15 | // put your setup code here, to run once: 16 | M1Serial.begin(115200); 17 | DebugSerial.begin(115200); 18 | 19 | DebugSerial.println("TYPE1SC Module Start!!!"); 20 | /* Board Reset */ 21 | TYPE1SC.reset(); 22 | delay(2000); 23 | 24 | /* TYPE1SC Module Initialization */ 25 | if (TYPE1SC.init()) { 26 | DebugSerial.println("TYPE1SC Module Error!!!"); 27 | } 28 | 29 | /* Network Disable */ 30 | if (TYPE1SC.setCFUN(0) == 0) { 31 | DebugSerial.println("TYPE1SC Network Disable!!!"); 32 | } 33 | 34 | delay(1000); 35 | 36 | char *apnAddr = "simplio.apn"; /* Vodafone Global IoT SIM APN */ 37 | 38 | if (TYPE1SC.setAPN(apnAddr) == 0) { 39 | DebugSerial.println("TYPE1SC Set APN Address !!!"); 40 | } 41 | 42 | /* Board Reset */ 43 | TYPE1SC.reset(); 44 | 45 | delay(2000); 46 | 47 | /* TYPE1SC Module Initialization */ 48 | if (TYPE1SC.init()) { 49 | DebugSerial.println("TYPE1SC Module Error!!!"); 50 | } 51 | 52 | DebugSerial.println("TYPE1SC Module Ready!!!"); 53 | 54 | char apn[128]; 55 | if (TYPE1SC.getAPN(apn, sizeof(apn)) == 0) { 56 | DebugSerial.print("GET APN Address: "); 57 | DebugSerial.println(apn); 58 | } 59 | } 60 | 61 | void loop() { delay(1000); } 62 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_TCP_test/TYPE1SC_TCP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 // RPI_PICO 5 | 6 | #define PWR_PIN 4 7 | #define RST_PIN 5 8 | #define WAKEUP_PIN 6 9 | 10 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 11 | 12 | void setup() { 13 | pinMode(LED_BUILTIN, OUTPUT); 14 | digitalWrite(LED_BUILTIN, HIGH); 15 | // put your setup code here, to run once: 16 | M1Serial.begin(115200); 17 | DebugSerial.begin(115200); 18 | 19 | DebugSerial.println("TYPE1SC Module Start!!!"); 20 | /* Board Reset */ 21 | TYPE1SC.reset(); 22 | delay(2000); 23 | 24 | /* TYPE1SC Module Initialization */ 25 | if (TYPE1SC.init()) { 26 | DebugSerial.println("TYPE1SC Module Error!!!"); 27 | } 28 | 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | 37 | /* Enter a DNS address to get an IP address */ 38 | char IPAddr[32]; 39 | 40 | while (1) { 41 | 42 | if (TYPE1SC.getIPAddr("echo.mbedcloudtesting.com", IPAddr, 43 | sizeof(IPAddr)) == 0) { 44 | DebugSerial.print("IP Address : "); 45 | DebugSerial.println(IPAddr); 46 | break; 47 | } else { 48 | DebugSerial.println("IP Address Error!!!"); 49 | } 50 | delay(2000); 51 | } 52 | 53 | int _PORT = 7; 54 | char sckInfo[128]; 55 | 56 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 57 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 58 | DebugSerial.println("TCP Socket Create!!!"); 59 | 60 | INFO: 61 | 62 | /* 2 :TCP Socket Activation */ 63 | if (TYPE1SC.socketActivate() == 0) 64 | DebugSerial.println("TCP Socket Activation!!!"); 65 | 66 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 67 | DebugSerial.print("Socket Info : "); 68 | DebugSerial.println(sckInfo); 69 | 70 | if (strcmp(sckInfo, "ACTIVATED")) { 71 | delay(3000); 72 | goto INFO; 73 | } 74 | } 75 | 76 | /* 3 :TCP Socket Send Data */ 77 | char sendBuffer[] = "Hello CodeZoo!!!"; 78 | char recvBuffer[32]; 79 | int recvSize; 80 | 81 | if (TYPE1SC.socketSend(sendBuffer) == 0) { 82 | DebugSerial.print("[Send] >> "); 83 | DebugSerial.println(sendBuffer); 84 | } else 85 | DebugSerial.println("Send Fail!!!"); 86 | 87 | /* 4 :TCP Socket Recv Data */ 88 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 89 | DebugSerial.print("[Recv] >> "); 90 | DebugSerial.println(recvBuffer); 91 | DebugSerial.print("[RecvSize] >> "); 92 | DebugSerial.println(recvSize); 93 | } else { 94 | DebugSerial.println("Recv Fail!!!"); 95 | } 96 | 97 | /* 5 :TCP Socket DeActivation */ 98 | if (TYPE1SC.socketDeActivate() == 0) 99 | DebugSerial.println("TCP Socket DeActivation!!!"); 100 | 101 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 102 | DebugSerial.print("Socket Info : "); 103 | DebugSerial.println(sckInfo); 104 | } 105 | 106 | /* 6 :TCP Socket DeActivation */ 107 | if (TYPE1SC.socketClose() == 0) 108 | DebugSerial.println("TCP Socket Close!!!"); 109 | } 110 | 111 | void loop() { delay(1000); } 112 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_TLS_Socket_HTTPS_GET/TYPE1SC_TLS_Socket_HTTPS_GET.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define PROFILE_ID 2 7 | 8 | #define PWR_PIN 4 9 | #define RST_PIN 5 10 | #define WAKEUP_PIN 6 11 | 12 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 13 | 14 | int recvCnt = 0; 15 | 16 | void setup() { 17 | pinMode(LED_BUILTIN, OUTPUT); 18 | digitalWrite(LED_BUILTIN, HIGH); 19 | 20 | M1Serial.begin(115200); 21 | DebugSerial.begin(115200); 22 | DebugSerial.println("TYPE1SC Module Start!!!"); 23 | 24 | /* Board Reset */ 25 | TYPE1SC.reset(); 26 | delay(2000); 27 | 28 | /* TYPE1SC Module Initialization */ 29 | if (TYPE1SC.init()) { 30 | DebugSerial.println("TYPE1SC Module Error!!!"); 31 | } 32 | /* Network Registration Check */ 33 | while (TYPE1SC.canConnect() != 0) { 34 | DebugSerial.println("Network not Ready !!!"); 35 | delay(2000); 36 | } 37 | DebugSerial.println("TYPE1SC Module Ready!!!"); 38 | 39 | /* Enter a DNS address */ 40 | char IPAddr[] = "httpbin.org"; 41 | int _PORT = 443; /* https default port */ 42 | char sckInfo[128]; 43 | char recvBuffer[1500]; 44 | int recvSize = 0; 45 | 46 | /* 0 :Socket All Event Enable */ 47 | if (TYPE1SC.setSocket_EV(1) == 0) { 48 | DebugSerial.println("Socket All Event Enable!!!"); 49 | } 50 | 51 | /* 1 :TCP Socket Create ( 0:UDP, 1:TCP ) */ 52 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) { 53 | DebugSerial.println("TCP Socket Create!!!"); 54 | } 55 | 56 | /* 2 :Socket SSL Enabel */ 57 | int tlsProfileNumber = PROFILE_ID; 58 | if (TYPE1SC.socketSSL(tlsProfileNumber) == 0) { 59 | DebugSerial.println("Socket SSL Enable!!!"); 60 | } 61 | 62 | INFO: 63 | /* 3 :TLS TCP-Socket Activation */ 64 | if (TYPE1SC.socketActivate() == 0) { 65 | DebugSerial.println("TCP Socket Activation!!!"); 66 | } 67 | 68 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 69 | DebugSerial.print("Socket Info : "); 70 | DebugSerial.println(sckInfo); 71 | if (strcmp(sckInfo, "ACTIVATED")) { 72 | TYPE1SC.socketDeActivate(); 73 | delay(3000); 74 | goto INFO; 75 | } 76 | } 77 | 78 | /* 4 :TLS TCP-Socket Send Data */ 79 | String data = "GET /get HTTP/1.1\r\n"; 80 | data += "Host: httpbin.org\r\n\r\n"; 81 | 82 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 83 | DebugSerial.println("[--- HTTPS Send ---]"); 84 | DebugSerial.println(data); 85 | } else 86 | DebugSerial.println("Send Fail!!!"); 87 | 88 | /* 5 :TLS TCP-Socket Receive Data */ 89 | if (TYPE1SC.socketRecvHTTP(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 90 | DebugSerial.println("[--- HTTPS Receive Start ---]"); 91 | //DebugSerial.print("[RecvSize] >> "); 92 | //DebugSerial.println(recvSize); 93 | //DebugSerial.print("[Recv"); 94 | //DebugSerial.print(recvCnt++); 95 | //DebugSerial.print("] >> "); 96 | DebugSerial.println(recvBuffer); 97 | do{ 98 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 99 | //DebugSerial.print("[RecvSize] >> "); 100 | //DebugSerial.println(recvSize); 101 | //DebugSerial.print("[Recv"); 102 | //DebugSerial.print(recvCnt++); 103 | //DebugSerial.print("] >> "); 104 | DebugSerial.println(recvBuffer); 105 | } 106 | }while (recvSize > 0); 107 | } else { 108 | DebugSerial.println("Recv Fail!!!"); 109 | } 110 | DebugSerial.println("[--- HTTPS Receive End ---]"); 111 | 112 | /* 6 :TLS TCP-Socket DeActivation */ 113 | if (TYPE1SC.socketDeActivate() == 0) 114 | DebugSerial.println("TCP Socket DeActivation!!!"); 115 | 116 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 117 | DebugSerial.print("Socket Info : "); 118 | DebugSerial.println(sckInfo); 119 | } 120 | 121 | /* 7 :TLS TCP-Socket DeActivation */ 122 | if (TYPE1SC.socketClose() == 0) 123 | DebugSerial.println("TCP Socket Close!!!"); 124 | 125 | /* 8 :Socket All Event Disable */ 126 | if (TYPE1SC.setSocket_EV(0) == 0) 127 | DebugSerial.println("Socket All Event Disable!!!"); 128 | 129 | delay(10000); 130 | } 131 | void loop() { 132 | delay(1000); 133 | } 134 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_TLS_Socket_HTTPS_POST/TYPE1SC_TLS_Socket_HTTPS_POST.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 5 | 6 | #define PROFILE_ID 2 7 | 8 | #define PWR_PIN 4 9 | #define RST_PIN 5 10 | #define WAKEUP_PIN 6 11 | 12 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 13 | 14 | int recvCnt = 0; 15 | 16 | void setup() { 17 | M1Serial.begin(115200); 18 | DebugSerial.begin(115200); 19 | DebugSerial.println("TYPE1SC Module Start!!!"); 20 | 21 | /* Board Reset */ 22 | TYPE1SC.reset(); 23 | delay(2000); 24 | 25 | /* TYPE1SC Module Initialization */ 26 | if (TYPE1SC.init()) { 27 | DebugSerial.println("TYPE1SC Module Error!!!"); 28 | } 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | 37 | /* Enter a DNS address */ 38 | char IPAddr[] = "httpbin.org"; 39 | int _PORT = 443; /* https default port */ 40 | char sckInfo[128]; 41 | char recvBuffer[1500]; 42 | int recvSize = 0; 43 | 44 | /* 0 :Socket All Event Enable */ 45 | if (TYPE1SC.setSocket_EV(1) == 0) 46 | DebugSerial.println("Socket All Event Enable!!!"); 47 | 48 | /* 1 :TCP-Socket Create ( 0:UDP, 1:TCP ) */ 49 | if (TYPE1SC.socketCreate(1, IPAddr, _PORT) == 0) 50 | DebugSerial.println("TCP Socket Create!!!"); 51 | 52 | /* 2 :Socket SSL Enabel */ 53 | int tlsProfileNumber = PROFILE_ID; 54 | if (TYPE1SC.socketSSL(tlsProfileNumber) == 0) { 55 | DebugSerial.println("Socket SSL Enable!!!"); 56 | } 57 | 58 | INFO: 59 | 60 | /* 3 :TLS TCP-Socket Activation */ 61 | if (TYPE1SC.socketActivate() == 0) 62 | DebugSerial.println("TCP Socket Activation!!!"); 63 | 64 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 65 | DebugSerial.print("Socket Info : "); 66 | DebugSerial.println(sckInfo); 67 | 68 | if (strcmp(sckInfo, "ACTIVATED")) { 69 | delay(3000); 70 | goto INFO; 71 | } 72 | } 73 | 74 | /* 4 :TLS TCP-Socket Send Data */ 75 | String wDB = "{\"email\": \"eve.holt@reqres.in\",\"password\": \"pistol\"}"; 76 | 77 | String data = "POST /post HTTP/1.1\r\n"; 78 | data += "Host: httpbin.org\r\n"; 79 | data += "Accept:application/json\r\n"; 80 | data += "Content-Type:application/json\r\n"; 81 | data += "Content-Length:" + String(wDB.length()) + "\r\n"; 82 | data += "\r\n" + wDB; 83 | 84 | if (TYPE1SC.socketSend(data.c_str()) == 0) { 85 | DebugSerial.println("[--- HTTPS Send ---]"); 86 | DebugSerial.println(data); 87 | } else 88 | DebugSerial.println("Send Fail!!!"); 89 | 90 | /* 5 :TLS TCP-Socket Recv Data */ 91 | if (TYPE1SC.socketRecvHTTP(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 92 | DebugSerial.println("[--- HTTPS Receive Start ---]"); 93 | //DebugSerial.print("[RecvSize] >> "); 94 | //DebugSerial.println(recvSize); 95 | //DebugSerial.print("[Recv"); 96 | //DebugSerial.print(recvCnt++); 97 | //DebugSerial.print("] >> "); 98 | DebugSerial.println(recvBuffer); 99 | do{ 100 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 101 | //DebugSerial.print("[RecvSize] >> "); 102 | //DebugSerial.println(recvSize); 103 | //DebugSerial.print("[Recv"); 104 | //DebugSerial.print(recvCnt++); 105 | //DebugSerial.print("] >> "); 106 | DebugSerial.println(recvBuffer); 107 | } 108 | }while (recvSize > 0); 109 | } else { 110 | DebugSerial.println("Recv Fail!!!"); 111 | } 112 | DebugSerial.println("[--- HTTPS Receive End ---]"); 113 | 114 | /* 6 :TLS TCP-Socket DeActivation */ 115 | if (TYPE1SC.socketDeActivate() == 0) 116 | DebugSerial.println("TCP Socket DeActivation!!!"); 117 | 118 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 119 | DebugSerial.print("Socket Info : "); 120 | DebugSerial.println(sckInfo); 121 | } 122 | 123 | /* 7 :TLS TCP-Socket DeActivation */ 124 | if (TYPE1SC.socketClose() == 0) 125 | DebugSerial.println("TCP Socket Close!!!"); 126 | 127 | /* 8 :Socket All Event Disable */ 128 | if (TYPE1SC.setSocket_EV(0) == 0) 129 | DebugSerial.println("Socket All Event Disable!!!"); 130 | 131 | delay(10000); 132 | 133 | } 134 | 135 | void loop() { 136 | delay(1000); 137 | } 138 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_UDP_test/TYPE1SC_UDP_test.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #define DebugSerial Serial 4 | #define M1Serial Serial1 // RPI_PICO 5 | 6 | #define PWR_PIN 4 7 | #define RST_PIN 5 8 | #define WAKEUP_PIN 6 9 | 10 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 11 | 12 | void setup() { 13 | pinMode(LED_BUILTIN, OUTPUT); 14 | digitalWrite(LED_BUILTIN, HIGH); 15 | // put your setup code here, to run once: 16 | M1Serial.begin(115200); 17 | DebugSerial.begin(115200); 18 | 19 | DebugSerial.println("TYPE1SC Module Start!!!"); 20 | /* Board Reset */ 21 | TYPE1SC.reset(); 22 | delay(2000); 23 | 24 | /* TYPE1SC Module Initialization */ 25 | if (TYPE1SC.init()) { 26 | DebugSerial.println("TYPE1SC Module Error!!!"); 27 | } 28 | 29 | /* Network Registration Check */ 30 | while (TYPE1SC.canConnect() != 0) { 31 | DebugSerial.println("Network not Ready !!!"); 32 | delay(2000); 33 | } 34 | 35 | DebugSerial.println("TYPE1SC Module Ready!!!"); 36 | 37 | /* Enter a DNS address to get an IP address */ 38 | char IPAddr[32]; 39 | 40 | while (1) { 41 | 42 | if (TYPE1SC.getIPAddr("echo.mbedcloudtesting.com", IPAddr, 43 | sizeof(IPAddr)) == 0) { 44 | DebugSerial.print("IP Address : "); 45 | DebugSerial.println(IPAddr); 46 | break; 47 | } else { 48 | DebugSerial.println("IP Address Error!!!"); 49 | } 50 | delay(2000); 51 | } 52 | 53 | int _PORT = 7; 54 | char sckInfo[128]; 55 | 56 | /* 1 :UDP Socket Create ( 0:UDP, 1:TCP ) */ 57 | if (TYPE1SC.socketCreate(0, IPAddr, _PORT) == 0) 58 | DebugSerial.println("UDP Socket Create!!!"); 59 | 60 | INFO: 61 | 62 | /* 2 :UDP Socket Activation */ 63 | if (TYPE1SC.socketActivate() == 0) 64 | DebugSerial.println("UDP Socket Activation!!!"); 65 | 66 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 67 | DebugSerial.print("Socket Info : "); 68 | DebugSerial.println(sckInfo); 69 | 70 | if (strcmp(sckInfo, "ACTIVATED")) { 71 | delay(3000); 72 | goto INFO; 73 | } 74 | } 75 | 76 | /* 3 :UDP Socket Send Data */ 77 | char sendBuffer[] = "Hello CodeZoo!!!"; 78 | char recvBuffer[32]; 79 | int recvSize; 80 | 81 | if (TYPE1SC.socketSend(sendBuffer) == 0) { 82 | DebugSerial.print("[Send] >> "); 83 | DebugSerial.println(sendBuffer); 84 | } else 85 | DebugSerial.println("Send Fail!!!"); 86 | 87 | /* 4 :UDP Socket Recv Data */ 88 | if (TYPE1SC.socketRecv(recvBuffer, sizeof(recvBuffer), &recvSize) == 0) { 89 | DebugSerial.print("[Recv] >> "); 90 | DebugSerial.println(recvBuffer); 91 | DebugSerial.print("[RecvSize] >> "); 92 | DebugSerial.println(recvSize); 93 | } else { 94 | DebugSerial.println("Recv Fail!!!"); 95 | } 96 | 97 | /* 5 :UDP Socket DeActivation */ 98 | if (TYPE1SC.socketDeActivate() == 0) 99 | DebugSerial.println("UDP Socket DeActivation!!!"); 100 | 101 | if (TYPE1SC.socketInfo(sckInfo, sizeof(sckInfo)) == 0) { 102 | DebugSerial.print("Socket Info : "); 103 | DebugSerial.println(sckInfo); 104 | } 105 | 106 | /* 6 :UDP Socket DeActivation */ 107 | if (TYPE1SC.socketClose() == 0) 108 | DebugSerial.println("UDP Socket Close!!!"); 109 | } 110 | 111 | void loop() { delay(1000); } 112 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_WRITE_HTTPS_CERT/TYPE1SC_WRITE_HTTPS_CERT.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | 3 | #include "http_credentials.h" 4 | 5 | #define DebugSerial Serial 6 | #define M1Serial Serial1 7 | 8 | #define PROFILE_ID 2 9 | 10 | #define PWR_PIN 4 11 | #define RST_PIN 5 12 | #define WAKEUP_PIN 6 13 | 14 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 15 | 16 | void setup() { 17 | pinMode(LED_BUILTIN, OUTPUT); 18 | digitalWrite(LED_BUILTIN, HIGH); 19 | 20 | M1Serial.begin(115200); 21 | DebugSerial.begin(115200); 22 | 23 | DebugSerial.println("TYPE1SC Module Start!!!"); 24 | 25 | /* Board Reset */ 26 | TYPE1SC.reset(); 27 | delay(2000); 28 | 29 | /* TYPE1SC Module Initialization */ 30 | if (TYPE1SC.init()) { 31 | DebugSerial.println("TYPE1SC Module Error!!!"); 32 | } 33 | 34 | /* Network Registration Check */ 35 | while (TYPE1SC.canConnect() != 0) { 36 | DebugSerial.println("Network not Ready !!!"); 37 | delay(2000); 38 | } 39 | 40 | DebugSerial.println("TYPE1SC Module Ready!!!"); 41 | 42 | /* DELETE Certification Profile 1-255 */ 43 | int delProfile = PROFILE_ID; 44 | if (TYPE1SC.delCert(delProfile) == 0) { 45 | DebugSerial.println("Delete Certification in Profile.."); 46 | } 47 | delay(2000); 48 | 49 | /* Write server CA, Don't edit the file name */ 50 | if (TYPE1SC.writeKEY("server.crt", 0, serverCrt) == 0) { 51 | DebugSerial.println("Server CA Write!!!"); 52 | } 53 | delay(5000); 54 | 55 | /* ADD Certification Profile 1-255 */ 56 | int addProfile = PROFILE_ID; 57 | if (TYPE1SC.addHTTPCert(addProfile) == 0) { 58 | DebugSerial.println("ADD Server Certification in Profile.."); 59 | } 60 | } 61 | 62 | void loop() { delay(1000); } 63 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_WRITE_HTTPS_CERT/http_credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTP_CREDENTIALS_H 2 | #define HTTP_CREDENTIALS_H 3 | 4 | const char serverCrt[] = "-----BEGIN CERTIFICATE-----\n" 5 | "MIIEXjCCA0agAwIBAgITB3MSSkvL1E7HtTvq8ZSELToPoTANBgkqhkiG9w0BAQsF\n" 6 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" 7 | "b24gUm9vdCBDQSAxMB4XDTIyMDgyMzIyMjUzMFoXDTMwMDgyMzIyMjUzMFowPDEL\n" 8 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEcMBoGA1UEAxMTQW1hem9uIFJT\n" 9 | "QSAyMDQ4IE0wMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALtDGMZa\n" 10 | "qHneKei1by6+pUPPLljTB143Si6VpEWPc6mSkFhZb/6qrkZyoHlQLbDYnI2D7hD0\n" 11 | "sdzEqfnuAjIsuXQLG3A8TvX6V3oFNBFVe8NlLJHvBseKY88saLwufxkZVwk74g4n\n" 12 | "WlNMXzla9Y5F3wwRHwMVH443xGz6UtGSZSqQ94eFx5X7Tlqt8whi8qCaKdZ5rNak\n" 13 | "+r9nUThOeClqFd4oXych//Rc7Y0eX1KNWHYSI1Nk31mYgiK3JvH063g+K9tHA63Z\n" 14 | "eTgKgndlh+WI+zv7i44HepRZjA1FYwYZ9Vv/9UkC5Yz8/yU65fgjaE+wVHM4e/Yy\n" 15 | "C2osrPWE7gJ+dXMCAwEAAaOCAVowggFWMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYD\n" 16 | "VR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNV\n" 17 | "HQ4EFgQUwDFSzVpQw4J8dHHOy+mc+XrrguIwHwYDVR0jBBgwFoAUhBjMhTTsvAyU\n" 18 | "lC4IWZzHshBOCggwewYIKwYBBQUHAQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8v\n" 19 | "b2NzcC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDov\n" 20 | "L2NydC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8E\n" 21 | "ODA2MDSgMqAwhi5odHRwOi8vY3JsLnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jv\n" 22 | "b3RjYTEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IB\n" 23 | "AQAtTi6Fs0Azfi+iwm7jrz+CSxHH+uHl7Law3MQSXVtR8RV53PtR6r/6gNpqlzdo\n" 24 | "Zq4FKbADi1v9Bun8RY8D51uedRfjsbeodizeBB8nXmeyD33Ep7VATj4ozcd31YFV\n" 25 | "fgRhvTSxNrrTlNpWkUk0m3BMPv8sg381HhA6uEYokE5q9uws/3YkKqRiEz3TsaWm\n" 26 | "JqIRZhMbgAfp7O7FUwFIb7UIspogZSKxPIWJpxiPo3TcBambbVtQOcNRWz5qCQdD\n" 27 | "slI2yayq0n2TXoHyNCLEH8rpsJRVILFsg0jc7BaFrMnF462+ajSehgj12IidNeRN\n" 28 | "4zl+EoNaWdpnWndvSpAEkq2P\n" 29 | "-----END CERTIFICATE-----"; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_WRITE_KEY/TYPE1SC_WRITE_KEY.ino: -------------------------------------------------------------------------------- 1 | #include "TYPE1SC.h" 2 | #include "aws_credentials.h" 3 | 4 | #define DebugSerial Serial 5 | #define M1Serial Serial1 // RPI_PICO 6 | 7 | #define PWR_PIN 4 8 | #define RST_PIN 5 9 | #define WAKEUP_PIN 6 10 | 11 | TYPE1SC TYPE1SC(M1Serial, DebugSerial, PWR_PIN, RST_PIN, WAKEUP_PIN); 12 | 13 | void setup() { 14 | pinMode(LED_BUILTIN, OUTPUT); 15 | digitalWrite(LED_BUILTIN, HIGH); 16 | 17 | // put your setup code here, to run once: 18 | M1Serial.begin(115200); 19 | DebugSerial.begin(115200); 20 | 21 | DebugSerial.println("TYPE1SC Module Start!!!"); 22 | 23 | /* Board Reset */ 24 | TYPE1SC.reset(); 25 | delay(2000); 26 | 27 | /* TYPE1SC Module Initialization */ 28 | if (TYPE1SC.init()) { 29 | DebugSerial.println("TYPE1SC Module Error!!!"); 30 | } 31 | 32 | /* Network Registration Check */ 33 | while (TYPE1SC.canConnect() != 0) { 34 | DebugSerial.println("Network not Ready !!!"); 35 | delay(2000); 36 | } 37 | 38 | DebugSerial.println("TYPE1SC Module Ready!!!"); 39 | 40 | /* DELETE Certification Profile 1-255 */ 41 | int delProfile = 9; 42 | if (TYPE1SC.delCert(delProfile) == 0) { 43 | DebugSerial.println("Delete Certification Profile!!!"); 44 | } 45 | delay(2000); 46 | 47 | /* Write root CA, Don't edit the file name */ 48 | if (TYPE1SC.writeKEY("rootCA.pem", 0, rootCA) == 0) { 49 | DebugSerial.println("Root CA Write!!!"); 50 | } 51 | delay(5000); 52 | 53 | /* Write client CA, Don't edit the file name */ 54 | if (TYPE1SC.writeKEY("cert.pem.crt", 0, clientCrt) == 0) { 55 | DebugSerial.println("Client CA Write!!!"); 56 | } 57 | delay(5000); 58 | 59 | /* Write client KEY, Don't edit the file name */ 60 | if (TYPE1SC.writeKEY("private.pem.key", 1, clientKey) == 0) { 61 | DebugSerial.println("Client KEY Write!!!"); 62 | } 63 | delay(5000); 64 | 65 | /* ADD Certification Profile 1-255 */ 66 | int addProfile = 9; 67 | if (TYPE1SC.addCert(addProfile) == 0) { 68 | DebugSerial.println("ADD Certification Profile!!!"); 69 | } 70 | } 71 | 72 | void loop() { delay(1000); } 73 | -------------------------------------------------------------------------------- /examples/RPI_PICO/TYPE1SC_WRITE_KEY/aws_credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef AWS_CREDENTIALS_H 2 | #define AWS_CREDENTIALS_H 3 | const char rootCA[] = "-----BEGIN CERTIFICATE-----\n" 4 | "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" 5 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" 6 | "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" 7 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" 8 | "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" 9 | "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" 10 | "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" 11 | "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" 12 | "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" 13 | "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" 14 | "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" 15 | "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" 16 | "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" 17 | "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" 18 | "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" 19 | "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" 20 | "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" 21 | "rqXRfboQnoZsG4q5WTP468SQvvG5\n" 22 | "-----END CERTIFICATE-----"; 23 | 24 | const char clientCrt[] = "-----BEGIN CERTIFICATE-----\n" 25 | "\n" 26 | "\n" 27 | "\n" 28 | "\n" 29 | "\n" 30 | "\n" 31 | "\n" 32 | "\n" 33 | "\n" 34 | "\n" 35 | "\n" 36 | "\n" 37 | "\n" 38 | "\n" 39 | "\n" 40 | "\n" 41 | "\n" 42 | "\n" 43 | "-----END CERTIFICATE-----"; 44 | 45 | const char clientKey[] = "-----BEGIN RSA PRIVATE KEY-----\n" 46 | "\n" 47 | "\n" 48 | "\n" 49 | "\n" 50 | "\n" 51 | "\n" 52 | "\n" 53 | "\n" 54 | "\n" 55 | "\n" 56 | "\n" 57 | "\n" 58 | "\n" 59 | "\n" 60 | "\n" 61 | "\n" 62 | "\n" 63 | "\n" 64 | "\n" 65 | "\n" 66 | "\n" 67 | "\n" 68 | "\n" 69 | "\n" 70 | "\n" 71 | "-----END RSA PRIVATE KEY-----"; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /manual/CodeZoo_LTE-CATM1_Type1SC_보드사양서v1.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/manual/CodeZoo_LTE-CATM1_Type1SC_보드사양서v1.1.pdf -------------------------------------------------------------------------------- /manual/ESP32 + CATM1 모뎀.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/manual/ESP32 + CATM1 모뎀.pdf -------------------------------------------------------------------------------- /manual/LTE-CATM1_ESP32_IoT보드_핸즈온.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/manual/LTE-CATM1_ESP32_IoT보드_핸즈온.pdf -------------------------------------------------------------------------------- /manual/LTE-CATM1_내장형모뎀_ESP32_핸즈온.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/manual/LTE-CATM1_내장형모뎀_ESP32_핸즈온.pdf -------------------------------------------------------------------------------- /manual/LTE-CATM1_내장형모뎀_라즈베리파이피코_핸즈온.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/manual/LTE-CATM1_내장형모뎀_라즈베리파이피코_핸즈온.pdf -------------------------------------------------------------------------------- /manual/LTE-CATM1_내장형모뎀_아두이노_핸즈온.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/manual/LTE-CATM1_내장형모뎀_아두이노_핸즈온.pdf -------------------------------------------------------------------------------- /manual/[ENG] LTE-CATM1_ESP32_IoT_Board_HandsOn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/manual/[ENG] LTE-CATM1_ESP32_IoT_Board_HandsOn.pdf -------------------------------------------------------------------------------- /manual/raspberrypi/Cat.M1_RaspberryPi_PPP.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/manual/raspberrypi/Cat.M1_RaspberryPi_PPP.pdf -------------------------------------------------------------------------------- /schematics_dimension/CZ-Type1SC_dimension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/schematics_dimension/CZ-Type1SC_dimension.png -------------------------------------------------------------------------------- /schematics_dimension/ESP32_IoT_Board_dimension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/schematics_dimension/ESP32_IoT_Board_dimension.png -------------------------------------------------------------------------------- /schematics_dimension/ESP32_IoT_Board_sch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/schematics_dimension/ESP32_IoT_Board_sch.pdf -------------------------------------------------------------------------------- /schematics_dimension/Murata_Module_PCB1_Rev1.0_210719 TOP.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/schematics_dimension/Murata_Module_PCB1_Rev1.0_210719 TOP.pdf -------------------------------------------------------------------------------- /schematics_dimension/Nano_to_Uno.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/schematics_dimension/Nano_to_Uno.pdf -------------------------------------------------------------------------------- /schematics_dimension/expansion_schematics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/schematics_dimension/expansion_schematics.pdf -------------------------------------------------------------------------------- /schematics_dimension/new_shield_board_schematics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codezoo-ltd/TYPE1SC/37a1400550ad8a8bf34dff1395195eba9807e5c4/schematics_dimension/new_shield_board_schematics.pdf --------------------------------------------------------------------------------