i'm working on gsm 900 module. i want to send dynamic value of temperature sensor to cloud server i got problem as " data goes in to cloud server database but loop executes only once,
after one iteration of loop it data goes in to database and program execution stops at url "
i have attached snap shots of command window and code
#include <SoftwareSerial.h>
#include <dht.h>
dht DHT13; // pin no D13
#define DHT11_PIN13 13 //pin no (digital)
SoftwareSerial mySerial(2, 3); // RX, TX
int8_t answer;
char buff[105]; //to store the url string
char sBuff[100]; //to store the sensor parameters which appends to url string
/*
char id_wasp;
int voltage13t = 0;
int sensor = 0;
int frame_number;
*/
char data[512];
int data_size;
char aux_str[100];
char aux;
int x = 0;
//int frame_no = 0;
void setup(){
// pinMode(onModulePin, OUTPUT);
Serial.begin(9600);
mySerial.begin(9600);
Serial.println("Starting...");
// power_on();
delay(3000);
mySerial.println("AT");
//MODEM answer = sendATcommand("AT+SAPBR=0,1", "OK", 20000);
answer = sendATcommand("AT","OK", 2000);
while (sendATcommand2("AT+CREG?", "+CREG: 0,1", "+CREG: 0,5", 2000) == 0);
sendATcommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\"", "OK", 2000);
sendATcommand("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"", "OK", 2000);
sendATcommand("AT+SAPBR=2,1,\"Contype\",\"GPRS\"", "OK", 2000);
while (sendATcommand("AT+SAPBR=1,1", "OK", 20000) == 0)
{
delay(2000);
}
// Initializes HTTP service
answer = sendATcommand("AT+HTTPINIT", "OK", 10000);
// Sets CID parameter
delay(1000);
answer = sendATcommand("AT+HTTPPARA=\"CID\",1", "OK", 5000);
delay(1000);
Serial.flush(); //Clear input buffer
Serial.println("DONE...");
}
void loop(){
Serial.println("Entering loop()");
//reading DHTs
int chk13 = DHT13.read11(DHT11_PIN13);
//dht11 values
float voltage13t = (float)DHT13.temperature;
float voltage13h = (float)DHT13.humidity;
Serial.print("temp:");
Serial.println(voltage13t);
/*
frame_no = frame_no + 1;
frame_no = frame_no % 256;
Serial.print("frame-no:");
Serial.println(frame_no);
*/
char id_wasp[5]="test";
char frame_number[3]="ab";
char sensor[5]="temp";
//int value= 123;
//Store the query string in buff
sprintf(buff, "xx.xx.xxx.xx/connget7.php?");
sprintf(sBuff,"id_wasp=%s&frame_number=%s&sensor=%s&value=%d.%02d", id_wasp, frame_number, sensor, (int)voltage13t, (int)(voltage13t*100)%100);
//Concatenate sBuff and buff and store in buff
strcat(buff, sBuff);
delay(100);
char url[130];
sprintf(url, "AT+HTTPPARA=\"URL\",\"%s\"", buff);
Serial.println("xx.xx.xxx.xx/connget7.php?id_wasp=test&frame_number=ab&sensor=temp&value=0.00");
// Sets url
answer = sendATcommand(url, "OK", 5000);
delay(5000);
//Clears url buffer
memset(url, '\0', sizeof(url));
if (answer == 1)
{
// Starts GET action
delay(1000);
answer = sendATcommand("AT+HTTPACTION=0", "+HTTPACTION:0,200", 12000);
/* if (answer == 1)
{
goto END;
}*/
}
// }
delay(5000);
Serial.println("EXITING FROM loop()");
}
void power_on(){
uint8_t answer=0;
// checks if the module is started
answer = sendATcommand("AT", "OK", 2000);
if (answer == 0)
{
// waits for an answer from the module
while(answer == 0){
// Send AT every two seconds and wait for the answer
answer = sendATcommand("AT", "OK", 2000);
}
}
}
int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialize the string
delay(100);
while( mySerial.available() > 0) mySerial.read(); // Clean the input buffer
mySerial.println(ATcommand); // Send the AT command
//Serial.println(ATcommand);
x = 0;
previous = millis();
// this loop waits for the answer
do{
if(mySerial.available() != 0){
response[x] = mySerial.read();
Serial.write(response[x]);
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer1) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}
while((answer == 0) && ((millis() - previous) < timeout));
return answer;
}
int8_t sendATcommand2(char* ATcommand, char* expected_answer1,
char* expected_answer2, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialize the string
delay(100);
while( mySerial.available() > 0) mySerial.read(); // Clean the input buffer
mySerial.println(ATcommand); // Send the AT command
//Serial.println(ATcommand);
x = 0;
previous = millis();
// this loop waits for the answer
do{
if(mySerial.available() != 0){
response[x] = mySerial.read();
Serial.write(response[x]);
x++;
// check if the desired answer 1 is in the response of the module
if (strstr(response, expected_answer1) != NULL)
{
answer = 1;
}
// check if the desired answer 2 is in the response of the module
if (strstr(response, expected_answer2) != NULL)
{
answer = 2;
}
}
// Waits for the asnwer with time out
}while((answer == 0) && ((millis() - previous) < timeout));
return answer;
}
.