Hello there, I keep having a problem with my SIM800L EVB, everything seems to work, I can make call from it and recive SMS, but I can't send an SMS from it.
In the serial monitor everything seems to be fine, I recive the respons "OK" to every request that I give, I just don't get the message on my phone. I did not hat this problem while using an Arduino UNO.
For the RX pin I use pin 10, and for TX pin I use pin 11 on the Arduino Mega.
I have removed the number from the code, but I checked it with the call function and it worked, so the number entered is valid.
#include <SoftwareSerial.h>
SoftwareSerial sim(11, 10);
int _timeout;
String _buffer;
String number = "";
void setup() {
Serial.begin(9600);
_buffer.reserve(50);
Serial.println("System 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;
case 'd':
ClearMessages();
break;
}
}
if (sim.available() > 0) {
Serial.write(sim.read());
}
}
void SendMessage() {
sim.println("AT+CMGF=1"); // Sets the GSM Module in Text Mode
delay(200);
sim.println("AT+CMGS=\"" + number + "\"\r"); // Mobile phone number to send message
delay(200);
String SMS = "Hello, how are you?";
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);
}
void ClearMessages() {
// Clear all SMS messages (both read and unread)
sim.println("AT+CMGD=1,4");
delay(5000);
}