vshymanskyy / TinyGSM

A small Arduino library for GSM modules, that just works
GNU Lesser General Public License v3.0
1.91k stars 713 forks source link

Cannot make AT_DEBUG to work on a Fona808 with Arduino Uno #558

Closed tomascharad closed 3 years ago

tomascharad commented 3 years ago

[X ] I have read the Troubleshooting section of the ReadMe

What type of issues is this?

[X] Bug or issue with library functionality (ie, sending data over TCP/IP)

What are you working with?

Modem: SIM808 Main processor board: Uno TinyGSM version: 11.3 Code: AT_DEBUG

/**************************************************************
 *
 * This script tries to auto-detect the baud rate
 * and allows direct AT commands access
 *
 * TinyGSM Getting Started guide:
 *   https://tiny.cc/tinygsm-readme
 *
 **************************************************************/
#define TINY_GSM_DEBUG
// Select your modem:
//#define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM900
 #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM868
// #define TINY_GSM_MODEM_UBLOX
// #define TINY_GSM_MODEM_M95
// #define TINY_GSM_MODEM_BG96
// #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590
// #define TINY_GSM_MODEM_MC60
// #define TINY_GSM_MODEM_MC60E
// #define TINY_GSM_MODEM_ESP8266
// #define TINY_GSM_MODEM_XBEE

// Set serial for debug console (to the Serial Monitor, speed 115200)
#define SerialMon 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 TINY_GSM_DEBUG SerialMon

#include <TinyGsmClient.h>

// Module baud rate
uint32_t rate = 4800; // Set to 0 for Auto-Detect

void setup() {
  // Set console baud rate
  SerialMon.begin(115200);
  delay(6000);
}

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);
  }
}

Scenario, steps to reproduce

Hi! I'm trying to use the AT_DEBUG sketch but it doesn't work.

I'm receiving "Module does not respond"

[246438] Trying baud rate 115200 ...
[256450] Trying baud rate 57600 ...
[266462] Trying baud rate 38400 ...
[276482] Trying baud rate 19200 ...
[286512] Trying baud rate 9600 ...
[296564] Trying baud rate 74400 ...
[306576] Trying baud rate 74880 ...
[316587] Trying baud rate 14400 ...
[326618] Trying baud rate 28800 ...
***********************************************************
 Module does not respond!
   Check your Serial wiring
   Check the module is correctly powered and turned on
***********************************************************

When using the same device with FONA_Test Sketch from Adafruit, I can do everything including querying a website.

If I hardcode the Baud rate to 4800, and then I type 'AT' on serial monitor, nothing happens.

I've tried other sketchs, but I have the same problem.

Expected result

To be able to use TinyGSM.

Actual result

Cannot work with the library since I cannot seem to pass AT_DEBUG test.

Debug and AT command log

No logs appear.

tomascharad commented 3 years ago

Solved by defining RX, TX in inverse

SerialAT(3, 2);