Connect Arduino Mega 2560 via SIM800L to Thinger

For some reason I am unable to connect to Thinger.
I am using Arduino Mega 2560 and SIM800L.
I am using the example code from the Thinger library.
The same code works like charm on Arduino UNO.
I use the same power supply, same GPRS module, the same code.
At this point I have trouble shooted everything I could think of.
Could it be that the SoftwareSerial does not work?

#define THINGER_SERIAL_DEBUG

// Select your modem:
#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_M590

// Can be installed from Library Manager or GitHub - vshymanskyy/TinyGSM: A small Arduino library for GSM modules, that just works
#include <TinyGsmClient.h>
#include <ThingerTinyGSM.h>
#include “arduino_secrets.h”

// Emulate Serial1 on pins 10/11 if HW is not present (use interrupt pin in RX for better performance)
#ifndef HAVE_HWSERIAL1
#include “SoftwareSerial.h”
SoftwareSerial Serial1(10, 11); // RX, TX
#endif

ThingerTinyGSM thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL, Serial1);

void setup() {
// open serial for debugging
Serial.begin(115200);

// Serial for AT commands (can be higher with HW Serial, or even lower in SW Serial)
Serial1.begin(57600);

// set APN (you can remove user and password from call if your apn does not require them)
thing.setAPN(APN_NAME, APN_USER, APN_PSWD);

// set PIN (optional)
// thing.setPIN(CARD_PIN);

// resource input example (i.e, controlling a digitalPin);
pinMode(LED_BUILTIN, OUTPUT);
thing[“led”] << digitalPin(LED_BUILTIN);

// resource output example (i.e. reading a sensor value)
thing[“millis”] >> outputValue(millis());

// more details at DEVICES - Thinger.io Documentation
}

void loop() {
thing.handle();
}

I have tested the module with a simple example code to send a SMS and it works.

#include <SoftwareSerial.h>
SoftwareSerial sim(10, 11);
int _timeout;
String _buffer;
String number = “yournumber”; //-> change with your number
void setup() {
//delay(7000); //delay for 7 seconds to make sure the modules get the signal
Serial.begin(9600);
_buffer.reserve(50);
Serial.println(“Sistem Started…”);
sim.begin(9600);
delay(1000);
Serial.println(“Type s to send an SMS, r to receive an SMS, and c to make a call”);
}
void loop() {
if (Serial.available() > 0)
switch (Serial.read())
{
case ‘s’:
SendMessage();
break;
case ‘r’:
RecieveMessage();
break;
case ‘c’:
callNumber();
break;
}
if (sim.available() > 0)
Serial.write(sim.read());
}
void SendMessage()
{
//Serial.println (“Sending Message”);
sim.println(“AT+CMGF=1”); //Sets the GSM Module in Text Mode
delay(200);
//Serial.println (“Set SMS Number”);
sim.println(“AT+CMGS=”" + number + “”\r"); //Mobile phone number to send message
delay(200);
String SMS = “Hello, how are you? greetings from miliohm.com admin”;
sim.println(SMS);
delay(100);
sim.println((char)26);// ASCII code of CTRL+Z
delay(200);
_buffer = _readSerial();
}
void RecieveMessage()
{
Serial.println (“SIM800L Read an SMS”);
sim.println(“AT+CMGF=1”);
delay (200);
sim.println(“AT+CNMI=1,2,0,0,0”); // AT Command to receive a live SMS
delay(200);
Serial.write (“Unread Message done”);
}
String _readSerial() {
_timeout = 0;
while (!sim.available() && _timeout < 12000 )
{
delay(13);
_timeout++;
}
if (sim.available()) {
return sim.readString();
}
}
void callNumber() {
sim.print (F(“ATD”));
sim.print (number);
sim.print (F(";\r\n"));
_buffer = _readSerial();
Serial.println(_buffer);
}

Modify to Serial1.begin(9600); or Serial1.begin(19200);

1 Like

I have done that. Didn´t work. What I have tried and seems to work is dissable SoftwareSerial and connect the RX and TX of the GPRS module to pins 18 and 19 on the board. So far 1 successful connection.

Yep… Works like that…

#define THINGER_SERIAL_DEBUG

// Select your modem:
#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_M590

// Can be installed from Library Manager or GitHub - vshymanskyy/TinyGSM: A small Arduino library for GSM modules, that just works
#include <TinyGsmClient.h>
#include <ThingerTinyGSM.h>
#include “arduino_secrets.h”

// Emulate Serial1 on pins 10/11 if HW is not present (use interrupt pin in RX for better performance)
//#ifndef HAVE_HWSERIAL1
//#include "SoftwareSerial.h"
//SoftwareSerial Serial1(10, 11); // RX, TX
//#endif

ThingerTinyGSM thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL, Serial1);

void setup() {
// open serial for debugging
Serial.begin(115200);

// Serial for AT commands (can be higher with HW Serial, or even lower in SW Serial)
Serial1.begin(57600);

// set APN (you can remove user and password from call if your apn does not require them)
thing.setAPN(APN_NAME, APN_USER, APN_PSWD);

// set PIN (optional)
// thing.setPIN(CARD_PIN);

// resource input example (i.e, controlling a digitalPin);
pinMode(LED_BUILTIN, OUTPUT);
thing[“led”] << digitalPin(LED_BUILTIN);

// resource output example (i.e. reading a sensor value)
thing[“millis”] >> outputValue(millis());

// more details at DEVICES - Thinger.io Documentation
}

void loop() {
thing.handle();
}