Pages: [1]   Go Down
Author Topic: Sim 300 HTTP GET  (Read 429 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-cry )

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 ?



Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

At least this line

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

should be replaced by this:

Code:
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: