GPRS shield uploading sensor data


i am trying to upload the sensor data to thingspeak using the same GPRS modem. i go through the below link


and i dint get the few things which is added in the coding part…

char GPRS_Serial_wait_for_bytes(char no_of_bytes, int timeout) { while(GPRS_Serial.available() < no_of_bytes) { delay(200); timeout-=1; if(timeout == 0) { return 0; } } return 1; }

i dint get why is this function is been used there

please help


This function simply waits until the GPRS shield is ready to send a long enough response to the Arduino.
You call it with parameter “no_of_bytes” how long response you are expecting, and a “timeout” when to return with a timeout (1 second would equal 5 (5 * 200 = 1000)).

I agree it is not the best approach. In my opinion it would have been better to read the response until you get the newline character indicating a full line.

how can we know the number of bytes recieving from the GPRS

for example in the coding you are considering “GPRS_Serial_wait_for_bytes(4,10)” … how can we know that returning byes is “4”.


You can see all AT commands and their responses in this file – … _V1.03.pdf

I would recommend that at first you try using GPRS shield interactively – … PRS_Shield
You send AT commands to the shield and get the response, so you can easily see how this all works, are your commands correct and what is the exact response, sometimes it’s just “OK”, sometimes it’s a longer string. That helps a lot.