I am trying to do a get request on my server but length of url sent to serial monitor is always random. The URL gets truncated at random locations.
#include <SoftwareSerial.h>
//SIM 880L
#define SIM_RX 3
#define SIM_TX 4
//#define SIM_RT 5
SoftwareSerial gprsSerial(SIM_RX, SIM_TX);
void setup() {
Serial.begin(9600);
//Sim800L
gprsconfig();
}
void loop() {
//Sim800L
pushToServer();
}
//SIM800L
void gprsconfig() {
gprsSerial.begin(9600);
Serial.println("Config SIM900...");
delay(2000);
Serial.println("Done!...");
gprsSerial.flush();
Serial.flush();
gprsSerial.println("AT+CGATT?");
delay(100);
toSerial();
gprsSerial.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
delay(2000);
toSerial();
gprsSerial.println("AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"");
delay(2000);
toSerial();
gprsSerial.println("AT+SAPBR=0,1");
delay(2000);
gprsSerial.println("AT+SAPBR=1,1");
delay(2000);
toSerial();
delay(2000);
}
void pushToServer()
{
gprsSerial.println("AT+HTTPINIT");
delay(2000);
gprsSerial.println("AT+HTTPPARA=\"URL\",\"https://google.com\"");
delay(20000);
toSerial();
gprsSerial.println("AT+HTTPACTION=0");
delay(6000);
toSerial();
gprsSerial.println("AT+HTTPREAD");
delay(10000);
toSerial();
gprsSerial.println("");
gprsSerial.println("AT+HTTPTERM");
toSerial();
delay(300);
gprsSerial.println("");
delay(10000);
}
void toSerial()
{
while (gprsSerial.available() != 0)
{
Serial.write(gprsSerial.read());
}
}
I am using https://google.com as a demo. This is the output
AT+HTTPTERM
OK
AT+HTTPINIT
OK
AT+HTTPPARA="URL","https:AT+HTTPACTION=0
OK
+HTTPACTION: 0,601,0
AT+HTTPREAD
OK
HELLO
AT+HTTPTERM
OK
AT+HTTPINIT
OK
AT+HTTPPARA="URL","https:AT+HTTPACTION=0
OK
+HTTPACTION: 0,601,0
AT+HTTPREAD
OK
Can I get help what is wrong with this code?