Go Down

Topic: Sim 300 HTTP GET (Read 522 times) previous topic - next topic

SuryaK19

Hi,

I m using a sim 300 gsm modem:
http://shop.sumeetinstruments.com/index.php?route=product/product&product_id=1014

And arduino uno

I m trying to send sensor data to mysql database

Here is my code (which doesn't work  =( )

Quote

void setup()
{
  Serial.begin(9600); 
  Serial.print("\r");
  delay(1000);                 
  Serial.print("AT+CGATT=1\r\n");   
  delay(1000);
  Serial.print("AT+CIPCSGP=1,\"aircelgprs\"\r\n");
  delay(1000);
  Serial.print("AT+CSTT \r\n");
  delay(1000);
  Serial.print("AT+CIICR \r\n");
  delay(1000);
  Serial.print("AT+CIFSR \r\n");
  delay(1000);
  Serial.print("AT+CDNSORIP=1 \r\n");
  delay(1000);
  Serial.print("AT+CIPSPRT=1 \r\n");
  delay(1000);
  Serial.print("AT+CIPHEAD \r\n");
  delay(1000);
  Serial.print("AT+CIPSTART=\"TCP\",\"http://base-colap.rhcloud.com\",\"80\" \r\n");
  delay(1000);

}

void ContactWebServer(float bend_value, float bend_state)
{
  Serial.print("AT+CIPSEND \r\n");
  delay(3000);
  Serial.print("GET /wateralert1.php?alert=");
  Serial.print(bend_value);
  Serial.print("&flex=");
  Serial.print(bend_state);
  Serial.print(" HTTP/1.0 \r");
  Serial.print("\n");
    Serial.print("Host: http://.base-colap.rhcloud.com");
    Serial.print("\n");
    Serial.print("Connection: keep-alive");
    Serial.print("\n");
    Serial.print("Accept: */");
    Serial.print("*");
    Serial.print("\n");
    Serial.print("Accept-Language: en-us");
    Serial.print("\n\r");
    Serial.print("\n");
    
  delay(1000);
  Serial.write(0x1A);
  delay(1000);
}


void loop()
{
  float sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (100 / 1023.0000);
  float cur = sensorValue * (20.0000/100.0000) * voltage;
  // print out the value you read:
  
  delay(3000);

  ContactWebServer(voltage,cur);
  delay(5000);
}



are my AT commands correct ?




pylon

At least this line

Code: [Select]
Serial.print("AT+CIPSTART=\"TCP\",\"http://base-colap.rhcloud.com\",\"80\" \r\n");

should be replaced by this:

Code: [Select]
Serial.print("AT+CIPSTART=\"TCP\",\"base-colap.rhcloud.com\",\"80\" \r\n");

You already specified the port to use and the IP protocol with the "TCP" and "80" parameters, so the "http://" is not necessary and probably won't be recognized correctly by the GSM device.

It might help to run tcpdump on the server to confirm that the problem lies with establishing a http connection.
Also your webserver logfile can confirm that a successful connection has been made.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy