-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAT_Debug.ino
More file actions
79 lines (66 loc) · 2.2 KB
/
AT_Debug.ino
File metadata and controls
79 lines (66 loc) · 2.2 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**************************************************************
*
* This script tries to auto-detect the baud rate
* and allows direct AT commands access
*
* SimpleNB README:
* https://github.com/techstudio-design/SimpleNB/blob/master/README.md
*
**************************************************************/
// Select your modem:
#define SIMPLE_NB_MODEM_SIM7000
// #define SIMPLE_NB_MODEM_SIM7000SSL
// #define SIMPLE_NB_MODEM_SIM7080
// #define SIMPLE_NB_MODEM_UBLOX
// #define SIMPLE_NB_MODEM_SARAR4
// #define SIMPLE_NB_MODEM_BG96
// #define SIMPLE_NB_MODEM_XBEE
// #define SIMPLE_NB_MODEM_SEQUANS_MONARCH
// Set serial for debug console (to the Serial Monitor, speed 115200)
#define Serial Serial
// Set serial for AT commands (to the module)
// Use Hardware Serial on Mega, Leonardo, Micro
#ifndef __AVR_ATmega328P__
#define SerialAT Serial1
// or Software Serial on Uno, Nano
#else
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(2, 3); // RX, TX
#endif
#define SIMPLE_NB_DEBUG Serial
#include <SimpleNBClient.h>
void setup() {
// Set console baud rate
Serial.begin(115200);
delay(6000);
}
void loop() {
if (!rate) {
rate = SimpleNBAutoBaud(SerialAT);
}
if (!rate) {
Serial.println(F("***********************************************************"));
Serial.println(F(" Module does not respond!"));
Serial.println(F(" Check your Serial wiring"));
Serial.println(F(" Check the module is correctly powered and turned on"));
Serial.println(F("***********************************************************"));
delay(30000L);
return;
}
SerialAT.begin(rate);
// Access AT commands from Serial Monitor
Serial.println(F("***********************************************************"));
Serial.println(F(" You can now send AT commands"));
Serial.println(F(" Enter \"AT\" (without quotes), and you should see \"OK\""));
Serial.println(F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor"));
Serial.println(F("***********************************************************"));
while(true) {
if (SerialAT.available()) {
Serial.write(SerialAT.read());
}
if (Serial.available()) {
SerialAT.write(Serial.read());
}
delay(0);
}
}