Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define TINY_GSM_MODEM_SIM808
- // Set serial for debug console (to the Serial Monitor, speed 115200)
- #define SerialMon Serial
- // Set serial for AT commands (to the module)
- // Software Serial on Uno, Nano
- #include <SoftwareSerial.h>
- SoftwareSerial SerialAT(6, 7); // RX, TX
- #define TINY_GSM_DEBUG SerialMon
- #include <TinyGsmClient.h>
- // Module baud rate
- uint32_t rate = 9600; // Set to 0 for Auto-Detect
- void setup() {
- // Set console baud rate
- SerialMon.begin(115200);
- delay(3000);
- }
- void loop() {
- if (!rate) {
- rate = TinyGsmAutoBaud(SerialAT);
- }
- if (!rate) {
- SerialMon.println(F("***********************************************************"));
- SerialMon.println(F(" Module does not respond!"));
- SerialMon.println(F(" Check your Serial wiring"));
- SerialMon.println(F(" Check the module is correctly powered and turned on"));
- SerialMon.println(F("***********************************************************"));
- delay(30000L);
- return;
- }
- SerialAT.begin(rate);
- // Access AT commands from Serial Monitor
- SerialMon.println(F("***********************************************************"));
- SerialMon.println(F(" You can now send AT commands"));
- SerialMon.println(F(" Enter \"AT\" (without quotes), and you should see \"OK\""));
- SerialMon.println(F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor"));
- SerialMon.println(F("***********************************************************"));
- while(true) {
- if (SerialAT.available()) {
- SerialMon.write(SerialAT.read());
- }
- if (SerialMon.available()) {
- SerialAT.write(SerialMon.read());
- }
- delay(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement