ARDUINO UNO + SIM808 GPS/GSM/GPRS MODULE SYNCHRONISATION

HELLO everyone,

i started a project quite recently were i intend to combine the arduino uno and the sim808 module which has gps/gsm/gprs all together in one.

using just the gps functionality works fine, just the gsm both recieving and sending messages also works good. but combining them for what i intend makes the entire system falls apart.

i intend to be able to have some coordinates registered lets say position A position B and position c, and the system i intend to design is put on a moving, lets say car, now anyone on either of the positions will send a message with the alphabet denoting the position to a number lets say "A TO +23*******98 , AND WOULD get a reply of the cars current time from that position.

with all parts combined the program would sometimes not even indicate recieving any message or evn if it did the gps part wont even work.

is there something i am doing wrong or is it not just feasible with what the components i am using
pls help as i very confused right now. thanks in advance

what_to_upload.ino (10.5 KB)

  String package;
  String BUSNUM="A";  // THIS SIM IS TO BE INSTALLED ON BUS A
  String control;
  String Number;
  static String sendersnumber;
  char* key;
  String fixstatus;
  String runstatus;
  String dateandtime;
  char MESSAGE[280];
  String latitude;
  String longitude;
  String Altitude;
  String Speed;
  int passengerNUM;
  int passengerNUMB;
  String MESSAGE_O;
  String key_0;

Do you really have that much memory to piss away uselessly?

 while(GPRS.available()) //ONLY WHEN THERE IS SOMETHING AVAILABLE,
  {
  

   GSM_NUM1(GPRS.read());  
   //delay(50);
   GPRS.println("AT+CGNSURC=1");
  // delay(40);    
     
    GPSAnalyzer(GPRS.read());
     
    sendSMS();
   
  }

Every time you read one (or a few) characters from the last command, send another command. Why? You'll never get caught up.

thanks a lot for taking your time to reply me.. perhaps i should elaborate more on the functionality of the code

i intend to wait for a message to come in, as long as there is no message nothing

happens..

then the message comes in then it extracts the sender number, and the message exactly, then the AT command which you queried me about executes and the latitude and longitude with speed is extracted from comma to comma, hence distance time are gotten then the sendsms function sends it back to the number.

about the variables wasting space i tried fewer but still the same result, and how else to or were to place the AT command i have no new clue. full re-assessment would be much much appreciated as i need to find a way to make this work very very soon..

THANKS IN ADVANCE!

please, help me out anyone, i am incredibly desperate and on a very short time leash.

Post your corrected code and your observations, warts and all.

would do that right away!

ROUGH ANALYSIS
After all declarations and initializations the first active part of the entire code is the for loop that just deletes all former messages from the sim card memory.it runs 15 times

for (int i = 1; i <= 15; i++)
{
GPRS.print("AT+CMGD=");
GPRS.println(i);
delay(300);
while(GPRS.available())
Serial.write(GPRS.read());
}
Now, having functions GSM_NUM1(); GPSAnalyzer(); sendSMS();
Which are defined below in the code

GSM_NUM1(); GPSAnalyzer(); both work similarly they extract needed data which come in separated by commas. For the gps which comes in , in the form

+UGNSINF: ,,<UTC date & Time>,,,
,,, ,,,,,,,
,,<C/N0 max>,,

lathitude, speed and any other important parameter is extracted.

For GSM_NUM1(); it gets the senders message and number into variable.

sendSMS(); this just does some calculation based on the message received and send a certain result to the number who requested it.

OBERVATIONS
When the program starts nothing happens which is good cause nothing is supposed to until something new comes in.
Hence the
void loop()
{
while(GPRS.available()) //ONLY WHEN THERE IS SOMETHING AVAILABLE,
{
GSM_NUM1(GPRS.read());
//delay(50);
GPRS.println("AT+CGNSINF");
// delay(40);
GPSAnalyzer(GPRS.read());
sendSMS();
}
Now this is were things go bad, as the first function works good, it waits gets the message and extracts the senders number and message”key” into variables but immediately after that I wantjust one return of the gps info shown below that’s why I used ("AT+CGNSINF"); instead of ("AT+CGNSURC=1"); as the later gives continuous gps data such as

+UGNSINF: ,,<UTC date & Time>,,,
,,, ,,,,,,,
,,<C/N0 max>,,

BUT instead of one line of the gps data to be gotten from were lathitude and some other parameters are extracted into variables “THE PROGRAM HANGS/STOPS for some unknown reason.

SUSPICIONS
Since the SIM808 possess gps/gsm on the same module. It makes it kind of tricky to separate them in the sense that.
IF I WANT THE GPS TO BE ON BUT NOT READ IN ANY DATA UNTIL A VALID REQUEST COMES IN , IN FORM OF AN SMS THEN THE NECESSARY GPS INFORMATION IS PARSED AND SOME CALCULATIONS ARE DONE TO GET A PARAMETER THAT WOULD BE SENT TO THE SAME NUMBER THAT REQUESTED IT.
PERSONNALY, I FEEL THAT GETTING THE GPS AND GSM TO WORK HAND IN HAND WITHOUT CANCELLING EACH OTHER OUT IN SOME WAY,SUCESSFULLY WOULD BE THE END OF MY PROBLEM. AND I THINK IT COMES DOWN TO THE POSITION OF THE AT COMMAND

GPRS.println("AT+CGNSURC=1"); AND/OR GPRS.println("AT+CGNSINF");
AS the former spits out the gps data every GNSS FIX continuously when called once and LATER spits it out just once per one command.

the attached picture just shows the continous nature of the output of ("AT+CGNSURC=1"); , just as ("AT+CGNSINF"); spits out just one line with +CGNSINF: at the begining instead.

post_to_ccc.ino (10.1 KB)

would have posted more, but didn't want my explanation to get too clumsy and cumbersome.

again i cant overemphasize how urgent this is .. thanks in ADVANCE!

GPRS.println("AT+CGNSPWR=1");etc.

Try using the F() macro.

i'm sorry i dont really understand you there!

oh, i just checked, you want me to use the flash memory.. cool but... it still behaved just the same way, as i explained above!

At this point , i Really dont know what else to do!

At this point , i Really dont know what else to do!

Post your code, post your observations.

Try not to SHOUT.

i wasn't SHOUTING, why would i, it wont be of any use to me, neither would it help my situation.

AS FOR THE OBSERVATIONS, IT STILL REMAINS THE SAME AS I POSTED BEFORE.

maybe if there was another approach i could try,i would really appreciate that. THANKS.

OK.
Good luck.

you too.

hello everyone,

i seemed to have caught a break in this problem, though i haven't tried it,since i don't exactly know how to apply it here.i am thinking of using "asynchronous programming" in other to combine two timing functions correctly.

my question is, If it is the way to go about it. how could i apply "asynchronous programming" to the above problem?

hi bro i am doing a similar project where i need to send gps coordinate via gsm would you please share your project pin config and how to connect to gsm module through audrino