How to get the response of
myGsm.println("AT+HTTPREAD=0,20");// read the data from the website you access
delay(3000);
printSerialData();
in a variable ? As i need to take this value for further processing, i have to store the value in a variable.
Code for reference,
#include <SoftwareSerial.h>
SoftwareSerial myGsm(7,8);
void setup()
{
myGsm.begin(9600);
Serial.begin(9600);
delay(500);
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,\"www.airtelgprs.com\",\"\"");//setting the APN,2nd parameter empty works for all networks
delay(5000);
printSerialData();
myGsm.println();
myGsm.println("AT+SAPBR=1,1");
delay(10000);
printSerialData();
myGsm.println("AT+HTTPINIT"); //init the HTTP request
delay(2000);
printSerialData();
//myGsm.println("AT+HTTPPARA=\"URL\",\"http://api.thingspeak.com/apps/thinghttp/send_request?api_key=VV7WQ9DS19E2BNNI\"");// setting the httppara,
myGsm.println("AT+HTTPPARA=\"URL\",\"http://api.thingspeak.com/apps/thinghttp/send_request?api_key=AP6AK0Z3APH3RDNY\"");// setting the httppara,
//the second parameter is the website from where you want to access data
delay(1000);
printSerialData();
myGsm.println();
myGsm.println("AT+HTTPACTION=0");//submit the GET request
delay(8000);//the delay is important if the return datas are very large, the time required longer.
printSerialData();
myGsm.println("AT+HTTPREAD=0,20");// read the data from the website you access
delay(3000);
printSerialData();
//val=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());
}
Following are the response of my code,
AT+HTTPPARA="URL","http://api.thingspeak.com/apps/thinghttp/sen
AT+HTTPACTION=0
OK
+HTTPACTION:0,200,14
AT+HTTPREAD=0,20
+HTTPREAD:14
1,208,047 hits
OK
How can i save the value (1,208,047 hits) in a variable i.e., the response of myGsm.println("AT+HTTPREAD=0,20"). Can you please help me out?