problem with arduino and gsm shield acting like web server

hi everyone,

i got this project in which i want to upload my sensor data to a Mysql database and preview them to an HTML table in my web page. This needs to be done by clicking a button (on the web page), which “informs” the Arduino to send the sensor values to the db. Also the web page has to send a value of an HTML form variable back to arduino and use it to change the status of a relay.

I am using an arduino uno to collect the data from the sensors and sends them through an nRF24L01+ module to an arduino mega, in which i 've connected the GSM/GPRS Shield (http://eud.dx.com/product/arduino-compatible-gsm-gprs-shield-wireless-extension-board-module-w-antenna-adapter-44144865).

The shield works fine as web Client and i was able (via at commands), to use the three basic functions (send sms, make call and connect to my web page) but i can’t either post data to db or send a variable back to my arduino.

for sending the variable to arduino i tried to simply send the output of the form using POST to a blank php page and then execute an AT+HTTPREAD command to arduino but it only downloads the html head and body tags.
After that i figured that the gsm shield has to act like a server and when trying the GsmWebServer build in example of GSM library it gives me an 0.0.0.0 address which it isn’t normal. right?

Please help me with this. i don’t have much wxperience in arduino and i can’t find any solutions about this online.

Here is the code i was using but i am guessing you wont need this.

 #include <SoftwareSerial.h>
#include <String.h>
 
SoftwareSerial mySerial(2, 3);
 
void setup()
{
  mySerial.begin(19200);               // the GPRS baud rate   
  Serial.begin(19200);                 // the GPRS baud rate 
  delay(500);
}
 
void loop()
{
 
  if (Serial.available())
    switch(Serial.read())
   {
     case 't':
       SendTextMessage();
       break;
     case 'd':
       DialVoiceCall();
       break;
     case 'h':
       SubmitHttpRequest();
       break;
     case 's':
       Send2Pachube();
       break;
   } 
  if (mySerial.available())
    Serial.write(mySerial.read());
}
 
///SendTextMessage()
///this function is to send a sms message
void SendTextMessage()
{
  mySerial.print("AT+CMGF=1\r");    //Because we want to send the SMS in text mode
  delay(100);
  mySerial.println("AT + CMGS = \"+30xxxxxxxxxx\"");//send sms message, be careful need to add a country code before the cellphone number
  delay(100);
  mySerial.println("A test message!");//the content of the message
  delay(100);
  mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
  delay(100);
  mySerial.println();
}
 
///DialVoiceCall
///this function is to dial a voice call
void DialVoiceCall()
{
  mySerial.println("ATD + +30xxxxxxxxxx;");//dial the number
  delay(100);
  mySerial.println();
}
 
///SubmitHttpRequest()
///this function is submit a http request
///attention:the time of delay is very important, it must be set enough 
void SubmitHttpRequest()
{
  mySerial.println("AT+CSQ");
  delay(100);
 
  ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.
 
  mySerial.println("AT+CGATT?");
  delay(100);
 
  ShowSerialData();
 
  mySerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is using gprs
  delay(1000);
 
  ShowSerialData();
 
  mySerial.println("AT+SAPBR=3,1,\"APN\",\"internet.vodafone.gr\"");//setting the APN, the second need you fill in your local apn server
  delay(4000);
 
  ShowSerialData();
 
  mySerial.println("AT+SAPBR=1,1");//setting the SAPBR, for detail you can refer to the AT command mamual
  delay(2000);
 
  ShowSerialData();
 
  mySerial.println("AT+HTTPINIT"); //init the HTTP request
 
  delay(2000); 
  ShowSerialData();
 
  mySerial.println("AT+HTTPPARA=\"URL\",\"www.google.com\"");// setting the httppara, the second parameter is the website you want to access
  delay(1000);
 
  ShowSerialData();
 
  mySerial.println("AT+HTTPACTION=0");//submit the request 
  delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
  //while(!mySerial.available());
 
  ShowSerialData();
 
  mySerial.println("AT+HTTPREAD");// read the data from the website you access
  delay(300);
 
  ShowSerialData();
 
  mySerial.println("");
  delay(100);
}
 
///send2Pachube()///
///this function is to send the sensor data to the pachube, you can see the new value in the pachube after execute this function///
void Send2Pachube()
{
  mySerial.println("AT+CGATT?");
  delay(1000);
 
  ShowSerialData();
 
  mySerial.println("AT+CSTT=\"CMNET\"");//start task and setting the APN,
  delay(1000);
 
  ShowSerialData();
 
  mySerial.println("AT+CIICR");//bring up wireless connection
  delay(3000);
 
  ShowSerialData();
 
  mySerial.println("AT+CIFSR");//get local IP adress
  delay(2000);
 
  ShowSerialData();
 
  mySerial.println("AT+CIPSPRT=0");
  delay(3000);
 
  ShowSerialData();
 
  mySerial.println("AT+CIPSTART=\"tcp\",\"api.cosm.com\",\"8081\"");//start up the connection
  delay(2000);
 
  ShowSerialData();
 
  mySerial.println("AT+CIPSEND");//begin send data to remote server
  delay(4000);
  ShowSerialData();
  String humidity = "1031";//these 4 line code are imitate the real sensor data, because the demo did't add other sensor, so using 4 string variable to replace.
  String moisture = "1242";//you can replace these four variable to the real sensor data in your project
  String temperature = "30";//
  String barometer = "60.56";//
  mySerial.print("{\"method\": \"put\",\"resource\": \"/feeds/42742/\",\"params\"");//here is the feed you apply from pachube
  delay(500);
  ShowSerialData();
  mySerial.print(": {},\"headers\": {\"X-PachubeApiKey\":");//in here, you should replace your pachubeapikey
  delay(500);
  ShowSerialData();
  mySerial.print(" \"_cXwr5LE8qW4a296O-cDwOUvfddFer5pGmaRigPsiO0");//pachubeapikey
  delay(500);
  ShowSerialData();
  mySerial.print("jEB9OjK-W6vej56j9ItaSlIac-hgbQjxExuveD95yc8BttXc");//pachubeapikey
  delay(500);
  ShowSerialData();
  mySerial.print("Z7_seZqLVjeCOmNbEXUva45t6FL8AxOcuNSsQS\"},\"body\":");
  delay(500);
  ShowSerialData();
  mySerial.print(" {\"version\": \"1.0.0\",\"datastreams\": ");
  delay(500);
  ShowSerialData();
  mySerial.println("[{\"id\": \"01\",\"current_value\": \"" + barometer + "\"},");
  delay(500);
  ShowSerialData();
  mySerial.println("{\"id\": \"02\",\"current_value\": \"" + humidity + "\"},");
  delay(500);
  ShowSerialData();
  mySerial.println("{\"id\": \"03\",\"current_value\": \"" + moisture + "\"},");
  delay(500);
  ShowSerialData();
  mySerial.println("{\"id\": \"04\",\"current_value\": \"" + temperature + "\"}]},\"token\": \"lee\"}");
 
 
  delay(500);
  ShowSerialData();
 
  mySerial.println((char)26);//sending
  delay(5000);//waitting for reply, important! the time is base on the condition of internet 
  mySerial.println();
 
  ShowSerialData();
 
  mySerial.println("AT+CIPCLOSE");//close the connection
  delay(100);
  ShowSerialData();
}
 
void ShowSerialData()
{
  while(mySerial.available()!=0)
    Serial.write(mySerial.read());
}

arduino mega, in which i 've connected the GSM/GPRS Shield

A Mega that has 4 hardware serial ports, right?

SoftwareSerial mySerial(2, 3);

So, why are you using SoftwareSerial on pins that do not work with SoftwareSerial on the Mega?

but i am guessing you wont need this.

You'd be guessing wrong then.

Yes i know that mega has 4 hardware serial ports but i am currently using the gsm shield with uno just to test everything is okay because there are a lot of connections to my arduino mega and i have them placed in a box. so it is trouble to make all these test to the arduino mega.

Nikolaiger:
Yes i know that mega has 4 hardware serial ports but i am currently using the gsm shield with uno just to test everything is okay because there are a lot of connections to my arduino mega and i have them placed in a box. so it is trouble to make all these test to the arduino mega.

So, you have code running on a Uno that you told us was running on a Mega.

How much free memory does the Uno have, with that sketch running? Why are you trashing that using the String class?

it uses 21% of its memory. But i dont see why this is the problem in my case. i have asked to help me in a a certain problem and you try to focus in other ones. this isn't my final code anyway. i posted to you just to see that my gsm shield is working with sms calls and http requests.

Nikolaiger:
it uses 21% of its memory. But i dont see why this is the problem in my case. i have asked to help me in a a certain problem and you try to focus in other ones. this isn't my final code anyway. i posted to you just to see that my gsm shield is working with sms calls and http requests.

When I compile your code, I get:

Sketch uses 7,718 bytes (23%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,127 bytes (55%) of dynamic memory, leaving 921 bytes for local variables. Maximum is 2,048 bytes.

55% is not 21%.

But i dont see why this is the problem in my case.

I's probably more of a problem than you think.

i have asked to help me in a a certain problem

By providing incorrect information.

All I can say is good luck.