[SOLVED] Problem with SIM808: It can't send SMS messages

Hi everyone!

I’m new at Ardruino and I’m working with DFRobotDyn Mega (it works as Ardruino Mega 2560) and SIM808 shield.

The issue I have at hand is my code can perform dial calls without problem, but for some reason it can’t send SMS messages.

I already test with “0x1a”/“26” character at the end of each message, but it doesn’t work. Am I forgetting something?

Thanks in advance for your help

#include <SoftwareSerial.h>
#include <String.h>
#define GSMSerial Serial1

void setup()
{
  GSMSerial.begin(9600);
  Serial.begin(9600);
  delay(1000);
}

void loop()
{

  if (Serial.available())
  switch(Serial.read())
  {
  case 's':
  SendTextMessage();
  break;
  case 'n':
  SendTextMessage2();
  break;

  case 'c':
  DialVoiceCall();
  break;

}
  if (GSMSerial.available())
  Serial.write(GSMSerial.read());
}


void SendTextMessage()
{

  delay(1000);
  GSMSerial.print("AT+CMGF=1\r");
  delay(1000);
  GSMSerial.println("AT + CMGS = \"+521XXXXXXXXXX\""); 
  delay(1000);
  GSMSerial.println("Message SMS 01");
  delay(1000);
  GSMSerial.println(26);
  delay(1000);
  GSMSerial.println();
}

void SendTextMessage2()
{

  delay(1000);
  GSMSerial.print("AT+CMGF=l\r");
  delay(1000);
  GSMSerial.println("AT + CMGS = \"+521XXXXXXXXXX\"");
  delay(1000);
  GSMSerial.println("Message SMS02");
  delay(1000);
  GSMSerial.println(26);
  delay(1000);
  GSMSerial.println();
}

void DialVoiceCall()
{
  delay(1000);
  GSMSerial.println("ATD+521XXXXXXXXXX;");//dial the number 
  delay(1000);
  GSMSerial.println();
}

SOLVED!

I just change my library to DFRobot and it works without problem (SMS & Phone calls are OK).

Here’s the solution

#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define MESSAGE_LENGHT 160
#define MESSAGE “SMS 01”
#define MESSAGE2 “SMS02”

#define mySerial Serial1 //PIN_TX,PIN_RX
#define PHONE_NUMBER “XXXXXXXX”
DFRobot_SIM808 sim808(&mySerial); //Connect PIN_TX,PIN_RX, GND

void setup()
{
mySerial.begin(9600);
Serial.begin(9600);

//---------------- Initialize sim808 module
while(!sim808.init()) {
delay(1000);
Serial.print(“Sim808 init error\r\n”);
}
delay(3000);
Serial.println(“Sim808 init success”);
}

void loop()
{

if (Serial.available())
switch(Serial.read())
{
case ‘s’:
SendTextMessage();
break;
case ‘n’:
SendTextMessage2();
break;

case ‘c’:
DialVoiceCall();
break;

}
if (mySerial.available())
Serial.write(mySerial.read());
}

void SendTextMessage()
{

delay(3000);
Serial.println(“Sending message …”);
sim808.sendSMS(PHONE_NUMBER,MESSAGE);
}

void SendTextMessage2()
{
delay(3000);
Serial.println(“Sending message …”);
sim808.sendSMS(PHONE_NUMBER,MESSAGE2);
}

void DialVoiceCall()
{
delay(3000);
Serial.println(“Start to call …”);
sim808.callUp(PHONE_NUMBER);

}