1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| #include "M5Atom.h"
#include "M5_SIM7080G.h"
M5_SIM7080G device;
String readstr;
void log(String str) {
Serial.print(str);
}
void setup()
{
M5.begin(true,true,true);
Serial.println("Atom Install OK....");
//SIM7080
device.Init(&Serial2, 32, 26);
//SIM7080の初期化
log("[log]module reset\r\n");
device.sendMsg("AT+CREBOOT\r\n");
delay(1000);
while(1){
log("[log]csq check\r\n");
device.sendMsg("AT+CSQ\r\n");
readstr = device.waitMsg(1000);
log(readstr);
if(readstr.indexOf("+CSQ: 99,99") ==-1){
log("CSQ is OK\r\n");
break;
}
}
log("[log]waiting 5sec...\r\n");
delay(5000);
log("[log]channel activate\r\n");
device.sendMsg("AT+CNACT=0,1\r\n");
readstr = device.waitMsg(200);
log(readstr);
log("[log]ntp server set up\r\n");
device.sendMsg("AT+CNTP=\"ntp.soracom.io\",9,0,2\r\n");
readstr = device.waitMsg(200);
log(readstr);
log("[log]ntp server utc request\r\n");
device.sendMsg("AT+CNTP\r\n");
readstr = device.waitMsg(200);
log(readstr);
readstr = device.waitMsg(1000);
log(readstr);
}
void loop()
{
Serial.println("Hello");
//waitCANData
M5.update();
if(M5.Btn.isPressed())
{
esp_restart();
}
delay(10000);
}
|