SIM800L not working with Arduino Mega

Hi,

I have a SIM800L V2 which I have working with an UNO using the default pins 10,11.

I'm trying to get the module working on a Mega 2560 and having no luck.

I've tried altering the Pins in the .ccp file. Using RX 19, TX18, and in the sketch.

#include <Sim800L.h>
*#include <SoftwareSerial.h> *

#define RX 19
#define TX 18

Sim800L GSM(RX, TX);

char* text;

char* number;

bool error; //to catch the response of sendSms

void setup(){

  • GSM.begin(115200); *

  • text="Testing Sms"; //text for the message. *

  • number="XXXXXXXXX"; //change to a valid number.*

  • error=GSM.sendSms(number,text);*

  • // OR *

  • //Sim800L.sendSms("+540111111111","the text go here")*

}

Please remember to use code tags to display your code.

Why are you using software serial on a Mega? You have multiple serial ports.

Where did you get the SIM800L library?

I found the library on the arduino library manager. Like I say the SIM800L works perfectly on the Arduino UNO.

Have you got any advice regarding how to set this up on the Mega? Potentially altering the current library?

Not using the library, no.

Pins 18 & 19 on the Mega are Serial1 so as I said, no need to use SoftwareSerial.

Obviously, try not to use Strings in non trivial code.

String outMessage = "Hello world!";
String destinationNumber = "+540111111111";

void setup()
{
 Serial1.begin(19200);
 delay(20000); // give time to log on to network.
 Serial1.print("AT+CMGF=1\r");
 delay(1000);
 Serial1.println("AT + CMGS = \"" + destinationNumber +"\"");
 delay(1000);
 Serial1.print(outMessage);
 delay(1000);
 Serial1.write((char)26); //ctrl+z
 delay(1000);
}

void loop()
{
}

ok thanks.

What do I need to add to the suggested code to get the SIM800L working then?

Is it also important to connect the RESET on the SIM800L. I've seen tutorials where the RESET is connected and others where it is not?

The sketch I posted worked the last time I tried it. No modification necessary (apart from the recipient's number, and you may need to swap Rx / Tx over).

I've not investigated the library to see what the Reset connection does. I can't recall ever using it myself.

I swapped RX and TX to 18 and 19 respectively, but the text message is not being received.

The SIM800L Version 2 module LED1 is illuminated, and LED2 flashes every 3 seconds to denote the sim is connected to a network.

With respect to the mobile number. If my mobile was 07777123456, would I type in "+07777123456" or something different?

Thanks for your help btw

To check your connections upload a Serial relay / repeater sketch to the Mega. This is simply to send what is received from Serial to Serial1, and vice versa. There are numerous versions around, just do a search and pick one. Once up and running send AT to the SIM800L, which should respond OK. Once you have got that working you can move on to uploading the sketch to send a message.

The format of the recipient's number is the plus symbol, the international dialling code and the the actual subscriber number without the leading zero. So for Italy, for instance, it would be + 39 777712345 (without the spaces)