MarcoMartines / GSM-GPRS-GPS-Shield

GSM/GPRS & GPS Shield Library for modules using SIM900/SIM908
GNU General Public License v2.0
208 stars 152 forks source link

ERROR: SIM900 doesn't answer. Check power and serial pins in GSM.cpp #36

Open amarneh1 opened 8 years ago

amarneh1 commented 8 years ago

Hello

iam using itead sim908 Gsm/Gps/Gprs Module with Arduino Uno, iam trying to send Gps coordinates by Sms message and by gprs to internet server, but cant run it both same time, Although it's work separately.

when i try to send GPS coordinates via SMS message and send data via gprs to server same time i have this error :

ERROR: SIM900 doesn't answer. Check power and serial pins in GSM.cpp

this is my code, any one have a solution ?

include "SIM900.h"

include

include "inetGSM.h"

include "sms.h"

//#include "call.h"

include "gps.h"

char smsbuffer2[150]; char id[]="12"; char httpbuffer[160];

InetGSM inet; //CallGSM call; SMSGSM sms; GPSGSM gps; char msg[50]; int numdata; char lon[15]; char lat[15]; char alt[15]; char time[20]; char vel[15]; char msg1[5]; char msg2[5]; char Mobile[]="0595285486"; char stat; char inSerial[50]; int i=0; boolean started=false; void setup(){ get_gps(); delay(1000); send_server(); delay(1000); send_sms(); } void loop(){ } void get_gps(){ 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(9600)) {
      Serial.println("\nstatus=READY");
      started=true;
       gsm.forceON();
 } 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);
      convert2Degrees(lat);
      convert2Degrees(lon);
 }

} void send_server(){ if (gsm.begin(9600)) { Serial.println("\nstatus=READY"); started=true; } else Serial.println("\nstatus=IDLE");

    if(started) {

      //GPRS attach, put in order APN, username and password.
      //If no needed auth let them blank.
      if (inet.attachGPRS("internet", "", ""))
           Serial.println("status=ATTACHED");
      else Serial.println("status=ERROR");
      delay(1000);
      //Read IP address.
      gsm.SimpleWriteln("AT+CIFSR");
      delay(5000);
      //Read until serial buffer is empty.
      gsm.WhileSimpleRead();
      //TCP Client GET, send a GET request to the server and
      //save the reply.
      /*
              httpbuffer[0]='\0';

strcat(httpbuffer,"/GetData.aspx?lat="); strcat(httpbuffer,lat);

strcat(httpbuffer,"&&lon="); strcat(httpbuffer,lon); strcat(httpbuffer,"&&id"); strcat(httpbuffer,id);

        Serial.println(httpbuffer);

*/ numdata=inet.httpPOST("qou.azurewebsites.net", 80,"httpbuffer", msg, msg,12); //Print the results. Serial.println("\nNumber of data received:"); Serial.println(numdata); Serial.println("\nData received:"); Serial.println(msg); } } void send_sms(){

 if (gsm.begin(9600)) {
      Serial.println("\nstatus=READY");
      started=true;
 } else Serial.println("\nstatus=IDLE");

if(started){

            smsbuffer2[0]='\0';

strcat(smsbuffer2,"Vehicle Accident Occurs to Vehicle which Have "); strcat(smsbuffer2,"ID number"); strcat(smsbuffer2,id); strcat(smsbuffer2,"in Location :"); strcat(smsbuffer2,lat); strcat(smsbuffer2,lon); strcat(smsbuffer2,"Owner Name:Ayman Abd Albasit Sadq Daqah");
strcat(smsbuffer2,"Mobile :"); strcat(smsbuffer2,Mobile); if (sms.SendSMS(Mobile, "smsbuffer2")) Serial.println("\nSMS sent OK"); } }