my arduino program is not giving any error still can not get data on web page

hello,
i am trying to upload my arduino uno data on my web page using sim900A module with arduino uno.
my arduino program is not giving any error
and some times it prints success message (200) on serial monitor .

but still not getting data on my web page

here is my code

send data to webpage.txt (2.45 KB)

here is you code using code tags and properly indented for everyone to read without clicking

#include <SoftwareSerial.h>
//#include "test_4july.h"
SoftwareSerial myGsm(2, 3);
char frame[200];
char aux_str[30];
char  latitude[15];
int longitude = 2;
int altitude = 3;


//char url[] = "https://devanshipatel.000webhostapp.com/vts/vts/get_link.php";
void setup()
{
  myGsm.begin(9600);
  Serial.begin(9600);
  delay(500);

  //  myGsm.println("AT+CGPSIPR=9600");
  // delay(200);
  // printSerialData();
  //  myGsm.println("AT+CGPSPWR=1");
  // delay(200);
  // printSerialData();
  //
  //  myGsm.println("AT+CGATT=1");
  // delay(200);
  // printSerialData();

  myGsm.println("AT+CGATT=1");
  delay(200);
  printSerialData();

  myGsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR,connection type is GPRS
  delay(1000);
  printSerialData();

  myGsm.println("AT+SAPBR=3,1,\"APN\",\"UninorGPRS\"");//setting the APN,2nd parameter empty works for all networks
  delay(5000);
  printSerialData();

  myGsm.println("AT+SAPBR=3,1,\"USER\",\"\"");//setting the APN,2nd parameter empty works for all networks
  delay(5000);
  printSerialData();

  myGsm.println("AT+SAPBR=3,1,\"PWD\",\"\"");//setting the APN,2nd parameter empty works for all networks
  delay(5000);
  printSerialData();

  myGsm.println("AT+SAPBR=1,1");
  delay(10000);
  printSerialData();

  myGsm.println("AT+SAPBR=2,1");//setting the APN,2nd parameter empty works for all networks
  delay(5000);
  printSerialData();

  //myGsm.println();



  myGsm.println("AT+HTTPINIT");
  delay(10000);
  printSerialData();




  myGsm.println("AT+HTTPPARA=\"CID\",1");
  delay(10000);
  printSerialData();

  myGsm.println("AT+HTTPPARA=\"URL\",http://www.drpinventions.com/get_link.php?latitude=2");// setting the httppara,
  //the second parameter is the website from where you want to access data
  delay(1000);
  printSerialData();

  //   myGsm.println("AT+HTTPDATA=192,10000");
  // delay(10000);
  // printSerialData();


  myGsm.println("AT+HTTPACTION=0");//submit the GET request
  delay(1000);//the delay is important if the return datas are very large, the time required longer.
  printSerialData();

  //delay(5000);

  myGsm.println("AT+HTTPREAD");// read the data from the website you access
  delay(10000);
  printSerialData();
  //
  myGsm.println("");
  delay(1000);
  myGsm.println("AT+HTTPTERM");// terminate HTTP service
  printSerialData();



}

void loop()
{
}


void printSerialData()
{
  while (myGsm.available() != 0)
    Serial.write(myGsm.read());
}

don’t you need quotes around the URL too in the HTTPPARA AT command?

AT+HTTPPARA="URL",[color=red]"[/color]http://xxxx[color=red]"[/color]
  myGsm.println("AT+HTTPACTION=0");//submit the GET request
  delay(1000);//the delay is important if the return datas are very large, the time required longer.
  printSerialData();

this is actually a poor way of handling the answer… while you wait 1 second the incoming buffer might fill in and after 64 chars you’ll start loosing data… also the way you print the data from the buffer never guarantees you print the full response if you empty the buffer faster than the data comes in (which is likely at 9600 bauds)

read Serial Input Basics to get a view on how to best handle the Serial port

thank you for reply

do you know any appropriate way to send data on web page using sim900A ?

because i have tried TCP protocol
but my gprs send "ERROR" on AT+CIPMUX=0 and all TCP related AT commands.

and i want to send mobile data on server so WIFI and Ethernet shield is not possible for me.

please give me any suggestion to send data ....

is your SIM ok for DATA ?

yes

does it register itself on the carrier network? is the basic stuff (calls, SMS) working? (cf this tutorial for example, there are plenty on line) then you can watch this one for HTTP commands

i have tested call and sms , both are working perfectly

SIM900 GPRS HTTP AT Commands - Embedded World in this it is posting text file and i want to post variable

and i have read data on web page using http URL , it is also working

i have screen shot of that

i have gone through your instructions on http://www.instructables.com/id/GSM-SIM900A-With-Arduino/
and call and sms are working ..

please give me suggestion in this for same URL only sometimes i am getting (200) message on serial monitor

well in your code you do  myGsm.println("AT+HTTPPARA=\"URL\",http://www.drpinventions.com/get_link.php?latitude=2");// setting the httppara,I think you are missing double quotes for the URL so would need to be

  myGsm.println("AT+HTTPPARA=\"URL\",\"http://www.drpinventions.com/get_link.php?latitude=2\"");// setting the httppara,

then if you don't want to have the 2 as a static element but coming from a variable, that's easy, you just need to split the print into chucnks

int variable = 22; // the value you want to pass to your PHP script
myGsm.print("AT+HTTPPARA=\"URL\",\"http://www.drpinventions.com/get_link.php?latitude="); // this is print, not println --> No LN at the end of print !
myGsm.print(variable);// this is print, not println --> No LN at the end of print !
myGsm.println("\"");// HERE it's PRINTLN as this is the end of the command, so you want the "\r\n" sent to mark the end of the AT command

AT+CGATT=1

OK
AT+SAPBR=3,1,"CONTYPE","GPRS"

OK
AT+SAPBR=3,1,"APN","UninorGPRS"

OK
AT+SAPBR=3,1,"USER",""

OK
AT+SAPBR=3,1,"PWD",""

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

+SAPBR: 1,1,"10.100.18.45"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL", "http://www.drpinventions.com/get_link.php?lAT+HTTPACTION=0

OK
AT+HTTPREAD

OK

+HTTPACTION:0,603,0

i am getting this in serial monitor

AT+SAPBR=1,1
AT+SAPBR=2,1

AT+SAPBR=1,1 --> //Enable bearer 1
AT+SAPBR=2,1 --> //Check whether bearer 1 is open
so seems it can't enable bearer 1 (probably the error is because it's already open)

(usually one set the necessary APN through AT+SAPBR --> is that already done?)


this is definitely not well formed

AT+HTTPPARA="URL", [color=red]"[/color]http://www.drpinventions.com/get_link.php?[color=red]lAT+HTTPACTION=0[/color]

AT+HTTPPARA="URL", "http://www.drpinventions.com/get_link.php?lAT+HTTPACTION=0

it prints every time like that

kajal27:
it prints every time like that

well what are you sending?

code:

#include <SoftwareSerial.h>
//#include “test_4july.h”
SoftwareSerial myGsm(2,3);
char frame[200];
char aux_str[30];
char latitude[15];
int longitude = 2;
int altitude = 3;

//char url = “https://devanshipatel.000webhostapp.com/vts/vts/get_link.php”;
void setup()
{
myGsm.begin(9600);
Serial.begin(9600);
delay(500);

// myGsm.println(“AT+CGPSIPR=9600”);
// delay(200);
// printSerialData();
// myGsm.println(“AT+CGPSPWR=1”);
// delay(200);
// printSerialData();
//
// myGsm.println(“AT+CGATT=1”);
// delay(200);
// printSerialData();

myGsm.println(“AT+CGATT=1”);
delay(200);
printSerialData();

myGsm.println(“AT+SAPBR=3,1,“CONTYPE”,“GPRS””);//setting the SAPBR,connection type is GPRS
delay(1000);
printSerialData();

myGsm.println(“AT+SAPBR=3,1,“APN”,“UninorGPRS””);//setting the APN,2nd parameter empty works for all networks
delay(5000);
printSerialData();

myGsm.println(“AT+SAPBR=3,1,“USER”,”"");//setting the APN,2nd parameter empty works for all networks
delay(5000);
printSerialData();

myGsm.println(“AT+SAPBR=3,1,“PWD”,”"");//setting the APN,2nd parameter empty works for all networks
delay(5000);
printSerialData();

// myGsm.println(“AT+SAPBR=1,1”);
// delay(10000);
// printSerialData();

myGsm.println(“AT+SAPBR=2,1”);//setting the APN,2nd parameter empty works for all networks
delay(5000);
printSerialData();

//myGsm.println();

myGsm.println(“AT+HTTPINIT”);
delay(10000);
printSerialData();

myGsm.println(“AT+HTTPPARA=“CID”,1”);
delay(10000);
printSerialData();

myGsm.println(“AT+HTTPPARA=“URL”, “http://prashantbpatel.com/sample.txt””); // setting the httppara, the second parameter is the website from where you want to access data
// myGsm.print(latitude);
// myGsm.println(""");
delay(10000);
printSerialData();

// myGsm.println(aux_str, "AT+HTTPPARA=“URL”,"http://www.drpinventions.com/get_link.php?");
// Serial.print(aux_str);
// myGsm.println(frame, “latitude=%d&longitude=%d&altitude=%d”,latitude ,longitude, altitude);
//
//
// myGsm.println(“AT+HTTPDATA=192,10000”);
// delay(1000);
// printSerialData();

myGsm.println("");
myGsm.println(“AT+HTTPACTION=0”);//submit the GET request
delay(10000);//the delay is important if the return datas are very large, the time required longer.
printSerialData();

//delay(5000);

myGsm.println(“AT+HTTPREAD”);// read the data from the website you access
delay(10000);
printSerialData();
//
// myGsm.println("");
// delay(10000);
// myGsm.println(“AT+HTTPTERM”);// terminate HTTP service
// printSerialData();

}

void loop()
{
}

void printSerialData()
{
while(myGsm.available()!=0)
Serial.write(myGsm.read());
}

what if you try just this

//set up GPRS, connection type
myGsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
delay(1000);
printSerialData();

// Handle the APN
myGsm.println("AT+SAPBR=3,1,\"APN\",\"UninorGPRS\"");
delay(1000);
printSerialData();

//tries to connect to GPRS
myGsm.println("AT+SAPBR=1,1"); //Enable bearer 1
delay(200);
printSerialData();
myGsm.println("AT+SAPBR=2,1"); //Check whether bearer 1 is open
delay(200);
printSerialData();

// initialise embedded HTTP ruttine
myGsm.println("AT+HTTPINIT");
delay(2000);
printSerialData();

// set the HTTP session
myGsm.println("AT+HTTPPARA=\"CID\",1");
delay(1000);
printSerialData();

// set the HTTP URL
myGsm.println("AT+HTTPPARA=\"URL\",\"http://prashantbpatel.com/sample.txt\"");

// start the session
myGsm.println("AT+HTTPACTION=0");
delay(1000);
printSerialData();

// read the data from the HTTP server
myGsm.println("AT+HTTPREAD");
delay(1000);

// that's because you have a crapy way of reading the Serial line.. 
// an attempt to read for a bit longer 
for (int i=0; i<100; i++) {
   printSerialData();
   delay(1):
}


// ends the connexion with the HTTP server
myGsm.println("AT+HTTPTERM");
delay(100);
myGsm.printlnln();
printSerialData();

now i have solved this (AT+HTTPPARA=“URL”, "http://www.drpinventions.com/get_link.php?lAT+HTTPACTION=0)

AT+CGATT=1

OK
AT+SAPBR=3,1,“CONTYPE”,“GPRS”

OK
AT+SAPBR=3,1,“APN”,“UninorGPRS”

OK
AT+SAPBR=3,1,“USER”,""

OK
AT+SAPBR=3,1,“PWD”,""

OK
AT+SAPBR=2,1

+SAPBR: 1,1,“10.100.18.45”

OK
AT+HTTPINIT

ERROR
AT+HTTPPARA=“CID”,1

OK
AT+HTTPPARA=“URL”, “http://prashantbpatel.com/sample.txt

OK
AT+HTTPACTION=0

OK
AT+HTTPREAD

OK

+HTTPACTION:0,603,0

try with the following function to print out the Serial output - whilst not perfect it will at least give you a 2 second timeout and try for a while to read from the Serial line

void printSerialData()
{
  const unsigned long timeout = 2000ul;
  unsigned long startChrono = millis();

  while (millis() - startChrono <= timeout) {
    if (myGsm.available()) {
      Serial.write(myGsm.read());
      startChrono = millis(); // reset the timeOut
    }
    delayMicroseconds(10); // sometimes Sofwtare Serial does not like banging at it too fast
  }
}

in which case you don’t need the

 for (int i=0; i<100; i++) {
   printSerialData();
   delay(1):
}

at the end of my code above.

→ please tell me if you used that code… can’t find out what you are trying unless you post your code (and get rid of things commented out)

AT+HTTPACTION = 0

is not executing

AT+CGATT=1

OK
AT+SAPBR=3,1,"CONTYPE","GPRS"

OK
AT+SAPBR=3,1,"APN","UninorGPRS"

OK
AT+SAPBR=1,1

OK
AT+SAPBR=2,1

+SAPBR: 1,1,"10.102.55.40"

OK
AT+HTTPINIT

ERROR
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://prashantbpatel.com/sample.txt"
AT+HTAT+HTTPREAD

OK
AT+HTTPTERM


OK