Connection to SIM808-module to determine GPS-position and handle SMS

I got the AZDelivery SIM 808 GPRS/GSM Shield (SIM808 Modul) and can´t get it working... I'm using the Arduino Mega 2560 and connected an external power source with 5V and 2Amps to the SIM808.

I tried different Pins for conecting the SIM808, but both aren´t working. I also changed the setting in the GSM.cpp file. So I connected the Arduino Mega Port 0 (RX) with TXD at the SIM808 and the Port 1 (TX) at the Arduino Mega with RXD at the SIM808.

The other time I connected Port 7 (TX) and Port 6 (RX) with the RXD and the TXD at the SIM808.

Both aren´t working :frowning:

I also tried different librarys, like the "DFRobot_SIM808-master", "GSM-GPRS-GPS-Shield-GSMSHIELD" and the "GSM".

So I also used different examples like this one from the "GSM-GPRS-GPS-Shield-GSMSHIELD"-library. I can´t find the mistake I made. I just get this message after waiting for a while:

12:19:22.591 -> GSM Shield testing. 12:19:28.200 -> DB:NO RESP
12:19:45.986 -> DB:NO RESP
12:20:03.775 -> DB:NO RESP
12:20:27.151 -> Trying to force the baud-rate to 9600
12:20:27.151 -> 
12:20:28.122 -> 1200
12:20:38.760 -> 2400
12:20:49.325 -> 4800
12:20:59.865 -> 9600
12:21:10.416 -> 19200
12:21:20.963 -> 38400
12:21:31.469 -> 57600
12:21:41.991 -> 115200
12:21:51.521 -> ERROR: SIM900 doesn't answer. Check power and serial pins in GSM.cpp
12:22:02.746 ->
12:22:02.746 -> status=IDLE

This is the script, I´m using now:

#include "SIM900.h"
#include <SoftwareSerial.h>
//#include "inetGSM.h"
//#include "sms.h"
//#include "call.h"
#include "gps.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to start a connection as client.

//InetGSM inet;
//CallGSM call;
//SMSGSM sms;
GPSGSM gps;

char lon[15];
char lat[15];
char alt[15];
char time[20];
char vel[15];
char msg1[5];
char msg2[5];

char stat;
char inSerial[20];
int i=0;
boolean started=false;

void setup()
{
     //Serial connection.
     Serial.begin(9600);
     Serial.println("GSM Shield testing.");
     //Start configuration of shield with baudrate.
     //For http uses is raccomanded to use 4800 or slower.
     if (gsm.begin(2400)) {
          Serial.println("\nstatus=READY");
          gsm.forceON();  //To ensure that SIM908 is not only in charge mode
          started=true;
     } else Serial.println("\nstatus=IDLE");

     if(started) {
          //GPS attach
          if (gps.attachGPS())
               Serial.println("status=GPSREADY");
          else Serial.println("status=ERROR");

          delay(20000); //Time for fixing
          stat=gps.getStat();
          if(stat==1)
               Serial.println("NOT FIXED");
          else if(stat==0)
               Serial.println("GPS OFF");
          else if(stat==2)
               Serial.println("2D FIXED");
          else if(stat==3)
               Serial.println("3D FIXED");
          delay(5000);
          //Get data from GPS
          gps.getPar(lon,lat,alt,time,vel);
          Serial.println(lon);
          Serial.println(lat);
          Serial.println(alt);
          Serial.println(time);
          Serial.println(vel);
     }
};

void loop()
{
     //Read for new byte on serial hardware,
     //and write them on NewSoftSerial.
     serialhwread();
     //Read for new byte on NewSoftSerial.
     serialswread();
};

void serialhwread()
{
     i=0;
     if (Serial.available() > 0) {
          while (Serial.available() > 0) {
               inSerial[i]=(Serial.read());
               delay(10);
               i++;
          }

          inSerial[i]='\0';
          if(!strcmp(inSerial,"/END")) {
               Serial.println("_");
               inSerial[0]=0x1a;
               inSerial[1]='\0';
               gsm.SimpleWriteln(inSerial);
          }
          //Send a saved AT command using serial port.
          if(!strcmp(inSerial,"TEST")) {
//      Serial.println("BATTERY TEST 1");
//      gps.getBattInf(msg1,msg2);
//      Serial.println(msg1);
//      Serial.println(msg2);
//      Serial.println("BATTERY TEST 2");
//      gps.getBattTVol(msg1);
//      Serial.println(msg1);
               stat=gps.getStat();
               if(stat==1)
                    Serial.println("NOT FIXED");
               else if(stat==0)
                    Serial.println("GPS OFF");
               else if(stat==2)
                    Serial.println("2D FIXED");
               else if(stat==3)
                    Serial.println("3D FIXED");
          }
          //Read last message saved.
          if(!strcmp(inSerial,"MSG")) {
               Serial.println(msg1);
          } else {
               Serial.println(inSerial);
               gsm.SimpleWriteln(inSerial);
          }
          inSerial[0]='\0';
     }
}

void serialswread()
{
     gsm.SimpleRead();
}

I also tried to send and recieve SMS with the same library and it also doesn´t work. The SIM808-module is able to register in the network but can´t send or receive a SMS... Here is the code for SMS:

#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"

//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to send and receive SMS.

int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];

void setup()
{
     //Serial connection.
     Serial.begin(9600);
     Serial.println("GSM Shield testing.");
     //Start configuration of shield with baudrate.
     //For http uses is raccomanded to use 4800 or slower.
     if (gsm.begin(2400)) {
          Serial.println("\nstatus=READY");
          started=true;
     } else Serial.println("\nstatus=IDLE");

     if(started) {
          //Enable this two lines if you want to send an SMS.
          //if (sms.SendSMS("3471234567", "Arduino SMS"))
          //Serial.println("\nSMS sent OK");
     }

};

void loop()
{
     if(started) {
          //Read if there are messages on SIM card and print them.
        /**  deprecated method
        if(gsm.readSMS(smsbuffer, 160, n, 20)) {
               Serial.println(n);
               Serial.println(smsbuffer);
          }
          **/
          //get 1st sms
          sms.GetSMS(1,n,20,smsbuffer,160);
          Serial.println(n);
          Serial.println(smsbuffer);
          
          delay(1000);
     }
};

Is anybody able to find my mistake? Thanks a lot, I can´t find a solution on my own!

Greetings, Jan =)

This will (more than likely) not solve your problem, but a Mega has 3 additional hardware ports; use them instead of SoftwareSerial.

Further pin 0 and 1 are used for the communication with the PC, so you can't use them for communication with anything else if you also use them for communication with the PC.

For testing the module, you can keep the Mega's processor in reset (connect reset to GND). Next connect the Mega's RX pin to the SIM's RXpin and the Mega's TX pin to the SIM's TX pin and use e.g. serial monitor to send commands.

sterretje:
This will (more than likely) not solve your problem, but a Mega has 3 additional hardware ports; use them instead of SoftwareSerial.

Are you talking about the ports 14-19 which are labeled TX1-3 and RX1-3?

So you mean I should connect TXD from the SIM 808 with the RX1 (Port 19) from the Mega and so on?

Further pin 0 and 1 are used for the communication with the PC, so you can't use them for communication with anything else if you also use them for communication with the PC.

For testing the module, you can keep the Mega's processor in reset (connect reset to GND). Next connect the Mega's RX pin to the SIM's RXpin and the Mega's TX pin to the SIM's TX pin and use e.g. serial monitor to send commands.

Which commands are you talking about? I'm sorry, I'm really new to this!

Thank you =)

I don't know the pin numbers of the Mega but RX1..3 and TX1..3 sounds right; in the software it will be Serial1 .. Serial3.

I guess that the commands that I'm talking about are hidden in the libraries that you use; can't really help you with that.

sterretje:
I don't know the pin numbers of the Mega but RX1..3 and TX1..3 sounds right; in the software it will be Serial1 .. Serial3.

I defined the ports just with the number, like this, right? Or do I have to define it as S15 or D15?

define TRX 15;

sterretje:
I guess that the commands that I'm talking about are hidden in the libraries that you use; can't really help you with that.

Okay, thank you!
I'll try it with those AT-commands.

[/quote]

When using hardware serial, you don't need to define anything. To use e.g. Serial1

In setup

void setup()
{
  Serial1.begin(your baud rate);

  // other setup code here
  ...
  ...
}

In loop()

void loop()
{
  // just some demo code
  Serial1.print("some command"); // might require a line ending.
}