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

i have changed this as below:

#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();
//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://www.drpinventions.com/get_link.php?latitude=2\"");
printSerialData();


// start the session
myGsm.println("AT+HTTPACTION=0");
delay(10000);
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.println();
printSerialData();



}

void loop()
{
}



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
  }
}

and serial monitor output is as below:
still not getting anything on webpage....

AT+CGATT=1

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

OK
AT+SAPBR=1,1

OK
AT+SAPBR=2,1

+SAPBR: 1,1,"10.84.2.242"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://www.drpinventions.com/get_link.php?latitude=2"

OK
AT+HTTPACTION=0

OK
AT+HTTPREAD

OK

+HTTPACTION:0,200,2226
AT+HTTPTERM


OK

when i am running same code again
this problem comes in picture

continues undefined values

every time getting new error and response

trial 1

AT+CGATT=1

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

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

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

+SAPBR: 1,1,"10.100.39.27"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

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

OK
AT+HTTPACTION=0

OK

+HTTPACTION:0,603,0
AT+HTTPREAD

OK
AT+HTTPTERM


OK

trial2

AT+CGATT=1

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

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

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

+SAPBR: 1,1,"10.100.39.27"

OK
AT+HTTPINIT

ERROR
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://www.drpinventions.com/get_link.php?latitude=6"

OK
AT+HTTPDATA=192,10000

DOWNLOAD

ERROR
AT+HTTPACTION=1

OK

+HTTPACTION:1,603,0
AT+HTTPREAD

OK
AT+HTTPTERM


OK

trial3

AT+CGATT=1

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

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

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

+SAPBR: 1,1,"10.100.39.27"

OK
AT+HTTPINIT

ERROR
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://www.drpinventions.com/get_link.php?latitude=6"

OK
AT+HTTPACTION=1

OK

+HTTPACTION:1,603,0
AT+HTTPDATA=192,10000

DOWNLOAD

i am doing this program from 28 days
please help me
can't understand what is the problem?
could not found any thing on google...

two things to verify

1/ can you confirm your GSM is powered directly from a wall outlet with a 5V 2Amps power supply. don't power from your Arduino

2/ test with that code with your arduino console set at 115200 bauds (not tested on my side but to get a sense of the answers form your modem)

#include <SoftwareSerial.h>
SoftwareSerial myGsm(2, 3);

// --------------------------------------------------------
// reads & prints what's coming from the GSM with a timeout default
// of 500ms after last char or whatever you preovide
// and an initial timout to wait for the  command to execute
// --------------------------------------------------------
void printSerialData(const unsigned long initialWait = 500ul, const unsigned long timeOut = 500ul)
{
  unsigned long startChrono;

  startChrono = millis();
  while (millis() - startChrono <= initialWait) {
    if (myGsm.available()) break;
    delayMicroseconds(20);
  }

  if (myGsm.available()) {
    while (millis() - startChrono <= timeOut) {
      if (myGsm.available()) {
        Serial.write(myGsm.read());
        startChrono = millis(); // reset the timeOut
      }
      delayMicroseconds(20);
    }
  }
}

// --------------------------------------------------------

void setup()
{
  Serial.begin(115200);
  myGsm.begin(9600);

  // Check the Network Registration
  myGsm.println(F("AT+CREG?"));
  printSerialData(1000,1000);

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

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

  // Defining the user - no login necessary ??
  myGsm.println("AT+SAPBR=3,1,\"USER\",\"\"");
  myGsm.println("AT+SAPBR=3,1,\"PWD\",\"\"");
  printSerialData();

  //Check whether bearer 1 is open (Get current bearer)
  myGsm.println(F("AT+SAPBR=2,1"));
  printSerialData();

  //If bearer == 0,0,0,0 (not assigned) get a new bearer Enable bearer 1
  // here we force it anyway... can return error
  myGsm.println(F("AT+SAPBR=1,1"));
  printSerialData();

  // initialise embedded HTTP ruttine
  myGsm.println(F("AT+HTTPINIT"));
  printSerialData(1000,1000);

  // Set the context ID
  myGsm.println(F("AT+HTTPPARA=\"CID\",1"));
  printSerialData();

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

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

  // read the data from the HTTP server
  myGsm.println(F("AT+HTTPREAD"));
  printSerialData(5000,1000);

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

}

void loop() {}

1/ yes i am giving external power source with 2Amps current

2/ it returns as below

AT+CREG?

+CREG: 0,1

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

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

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

OK
AT+SAPBR=2,1

+SAPBR: 1,1,"10.80.17.197"

OK
AT+SAPBR=1,1

ERROR
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

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

OK
AT+HTTPREAD

OK
AT+HTTPTERM

OK

no URL content printed on serial monitor and not (200) success message and no error message

i have tested this code two times and it gives this

code:

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


//char url[] = "https://devanshipatel.000webhostapp.com/vts/vts/get_link.php";
void setup()
{
 myGsm.begin(9600);  
 Serial.begin(115200);  
 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();
//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://www.drpinventions.com/get_link.php?latitude=6\"");
printSerialData();

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

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

//   myGsm.println("AT+HTTPDATA=192,10000");
// 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.println();
printSerialData();



}

void loop()
{
}



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
  }
}

serial monitor result:

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.82.38.178"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://www.drpinventions.com/get_link.php?latitude=6"

OK
AT+HTTPACTION=1

OK
AT+HTTPREAD

OK
AT+HTTPTERM


ERROR

+HTTPACTION:1,200,806
AT+CGATT=1

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

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

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

+SAPBR: 1,1,"10.82.38.178"

OK
AT+HTTPINIT

ERROR
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://www.drpinventions.com/get_link.php?latitude=6"

OK
AT+HTTPACTION=1

OK
AT+HTTPREAD

OK
AT+HTTPTERM


ERROR

1st time it prints success message and second time not

Is your answer in #24 with my code ? You keep showing yours

If so maybe it does not wait long enough

Try adding printSerialData(1000,1000); after sending the URL - I forgot it there and we should see the OK first

Then Try extending the wait time with printSerialData(10000,2000); after sending the HTTPREAD request and similar after sending the HTTPACTION. The fact that you don't receive a +HTTPACTION:0,200,806 (whatever the 806 number) immediately but after means that it's probably confused in timing.

If all was working fine you would see after sending

[color=blue]AT+HTTPACTION=0[/color]
[color=red]OK
 
+HTTPACTION:0,200,806[/color]

The output indicates it has read 806 bytes of data and the response of the HTTP GET request is 200, which means success

only then can we send the command to ask the module to give us the received data

[color=blue]AT+HTTPREAD[/color]
[color=red]
+HTTPREAD:806
.......
[/color]

Which should be the 806 bytes of data

You should also Use my new printSerialData function which has two parameters and remove the delays in your code, that's a better way (not ideal, should wait for OK or timeout) to await incoming data rather that's wait a random fixed delay without checking what's coming at the risk of loosing input

yes in ans no 24 result is your code's result

and i have changed printSerialData(10000,2000); as you say
and here is result

AT+CREG?

+CREG: 0,1

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

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

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

OK
AT+SAPBR=2,1

+SAPBR: 1,1,"10.102.15.243"

OK
AT+SAPBR=1,1

ERROR
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

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

OK

AT+HTTPACTION=0

OK
AT+HTTPREAD

OK
AT+HTTPTERM

ERROR

Did you add all the wait - including after HTTPACTION ?

i.e. try with this code

#include <SoftwareSerial.h>
SoftwareSerial myGsm(2, 3);

// --------------------------------------------------------
// reads & prints what's coming from the GSM with a timeout default
// of 500ms after last char or whatever you preovide
// and an initial timout to wait for the  command to execute
// --------------------------------------------------------
void printSerialData(const unsigned long initialWait = 500ul, const unsigned long timeOut = 500ul)
{
  unsigned long startChrono;

  startChrono = millis();
  while (millis() - startChrono <= initialWait) {
    if (myGsm.available()) break;
    delayMicroseconds(20);
  }

  if (myGsm.available()) {
    while (millis() - startChrono <= timeOut) {
      if (myGsm.available()) {
        Serial.write(myGsm.read());
        startChrono = millis(); // reset the timeOut
      }
      delayMicroseconds(20);
    }
  }
}

// --------------------------------------------------------

void setup()
{
  Serial.begin(115200);
  myGsm.begin(9600);

  // Check the Network Registration
  myGsm.println(F("AT+CREG?"));
  printSerialData(1000, 1000);

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

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

  // Defining the user - no login necessary ??
  myGsm.println("AT+SAPBR=3,1,\"USER\",\"\"");
  printSerialData();
  
  myGsm.println("AT+SAPBR=3,1,\"PWD\",\"\"");
  printSerialData();

  //Check whether bearer 1 is open (Get current bearer)
  myGsm.println(F("AT+SAPBR=2,1"));
  printSerialData();

  //If bearer == 0,0,0,0 (not assigned) get a new bearer Enable bearer 1
  // here we force it anyway... can return error that's fine
  myGsm.println(F("AT+SAPBR=1,1"));
  printSerialData();

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

  // Set the context ID
  myGsm.println(F("AT+HTTPPARA=\"CID\",1"));
  printSerialData();

  // set the HTTP URL
  myGsm.println(F("AT+HTTPPARA=\"URL\",\"http://prashantbpatel.com/sample.txt\""));
  printSerialData(10000, 5000);
  
  // start the session
  myGsm.println(F("AT+HTTPACTION=0"));
  printSerialData(10000, 5000);

  // read the data from the HTTP server
  myGsm.println(F("AT+HTTPREAD"));
  printSerialData(10000, 5000);

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

}

void loop() {}

You could also try a small program where you can type the commands manually in the console and see what's coming back.. read Serial, send to GSM, listen to GSM and send to Serial

that would let you play as well with \r or \r\n at end of AT command for example and see what's going on as you can wait until you see the OK and the message

have you done that already?

BTW just noticed you are using a SIM900A

the SIM900A is only a dual band GSM modem (operate only in 900,1800 MHz bands) and can only be used in India or Asia, as it is region locked to Asian markets.

--> is that where you are based?

(if I remember correctly Uninor is for India so you should be fine but asking just in case)

yes I am in India

and your printserial data loop is working and prints web page data with success

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
  }
AT+CGATT=1

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

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

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

+SAPBR: 1,1,"10.102.15.243"

OK
AT+HTTPINIT

ERROR
AT+HTTPPARA="CID",1

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

OK
AT+HTTPACTION=0

OK

+HTTPACTION:0,200,19
AT+HTTPREAD

+HTTPREAD:19
Hellowmalaypandya

OK
AT+HTTPTERM


OK

code is like this

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


//char url[] = "https://devanshipatel.000webhostapp.com/vts/vts/get_link.php";
void setup()
{
 myGsm.begin(9600);  
 Serial.begin(115200);  
 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();
//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\"");
printSerialData();

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

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

//   myGsm.println("AT+HTTPDATA=192,10000");
// 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.println();
printSerialData();



}

void loop()
{
}



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
  }
}

when uploading data not getting anything on webpage

Good so if my code is working, why don't you move to that code structure? (with a better Serial Handling than the first one accommodating for non blocking wait while reading Serial)

still some times it gives problem when i wanted to send more than one variable data

thank you so much

now this code is working
i am putting both code and serial monitor response for future help

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


//char url[] = "https://devanshipatel.000webhostapp.com/vts/vts/get_link.php";
void setup()
{
 myGsm.begin(9600);  
 Serial.begin(115200);  
 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();
//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.print("AT+HTTPPARA=\"URL\",\"http://www.drpinventions.com/add.php?latitude=");
myGsm.print(latitude);
myGsm.print("&longitude=");
myGsm.print(longitude);
myGsm.print("&altitude=");
myGsm.print(altitude);
myGsm.println("\"");
printSerialData();

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

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

//   myGsm.println("AT+HTTPDATA=192,10000");
// 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.println();
printSerialData();



}

void loop()
{
}



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
  }
}

serial output

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


//char url[] = "https://devanshipatel.000webhostapp.com/vts/vts/get_link.php";
void setup()
{
 myGsm.begin(9600);  
 Serial.begin(115200);  
 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();
//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.print("AT+HTTPPARA=\"URL\",\"http://www.drpinventions.com/add.php?latitude=");
myGsm.print(latitude);
myGsm.print("&longitude=");
myGsm.print(longitude);
myGsm.print("&altitude=");
myGsm.print(altitude);
myGsm.println("\"");
printSerialData();

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

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

//   myGsm.println("AT+HTTPDATA=192,10000");
// 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.println();
printSerialData();



}

void loop()
{
}



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
  }
}

now i am trying to send gps location on web page
and update you soon

serial output

That is NOT the serial output produced by the code you posted.

That is NOT the serial output produced by the code you posted.

sorry by mistake i have sent only program

here is serial output
only latitude, longitude and altitude int value is changed

AT+CGATT=1

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

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

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

+SAPBR: 1,1,"10.80.90.184"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://www.drpinventions.com/add.php?latitude=1123456768.00&longitude=2654321.00&altitude=3789123.00"

OK
AT+HTTPACTION=0

OK
AT+HTTPREAD

OK
AT+HTTPTERM


ERROR

+HTTPACTION:0,302,0
AT+CGATT=1

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

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

OK
AT+SAPBR=1,1

ERROR
AT+SAPBR=2,1

+SAPBR: 1,1,"10.80.90.184"

OK
AT+HTTPINIT

ERROR
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://www.drpinventions.com/add.php?latitude=1123456768.00&longitude=2654321.00&altitude=3789123.00"

OK
AT+HTTPACTION=0

OK

+HTTPACTION:0,302,0
AT+HTTPREAD

OK
AT+HTTPTERM


OK

successfully received data on my php web page

what part don't you understand when I suggest

  • get rid of the delays in the code
  • use the new printSerialData() function
// --------------------------------------------------------
// reads & prints what's coming from the GSM with a timeout default
// of 500ms after last char or whatever you preovide
// and an initial timout to wait for the  command to execute
// --------------------------------------------------------
void printSerialData(const unsigned long initialWait = 500ul, const unsigned long timeOut = 500ul)
{
  unsigned long startChrono;

  startChrono = millis();
  while (millis() - startChrono <= initialWait) {
    if (myGsm.available()) break;
    delayMicroseconds(20);
  }

  if (myGsm.available()) {
    while (millis() - startChrono <= timeOut) {
      if (myGsm.available()) {
        Serial.write(myGsm.read());
        startChrono = millis(); // reset the timeOut
      }
      delayMicroseconds(20);
    }
  }
}

that will give you more stability for handling the Serial port

this print error
printSerialData() was not declared

2/ The problem, however, is that the commands are only sent when I open the Serial Monitor.

I want to know how to send the AT commands when the Arduino is hooked up to a battery and not to a PC

as well as read data from serial when arduino uno is not connected to PC

as well as read data from serial when arduino uno is not connected to PC

What is going to be providing serial data when the Arduino is not connected to the PC?

That's like wanting to continue breathing when you open your spaceship door half way to the moon.