HTTP Response with AT commands?
Posted: Tue Jan 26, 2016 3:15 am
EDIT: solved my own issue, see my first reply.
Hi All
I've been using an ESP with an Arduino to post data to emoncms using the AT command set - (mostly) all good.
What I'm trying to achieve now is reading data back from emoncms. I can achieve this when directly programming the ESP with the Arduino ISP but can't figure out how (or if it's possible) to do this using the AT command set.
When programming with the Arduino IDE I basically need to post this to emoncms after establishing a TCP connection:
GET /feed/value.json?apikey=XXXXXXXXX&id=100486 HTTP/1.1
and on a new line:
Host:emoncms.org
and in the http response is the data I'm after i.e "3715113" (filtering the HTTP header was the next challenge).
I'm doing the following using the AT command set but only get a timeout from emoncms:
admittedly I'm not sending the "Host:emoncms.org" on a new line (which the site seems to need) mainly because I don't know how to construct it.
can anyone help me out? What's the best way to read the HTTP response and then filter out the header and assign the data I'm after to a variable using the AT command set?
Reading serial responses seems to be a challenge, wish there was better firmware out there for interfacing with an Arduino.
Thanks
Hi All
I've been using an ESP with an Arduino to post data to emoncms using the AT command set - (mostly) all good.
What I'm trying to achieve now is reading data back from emoncms. I can achieve this when directly programming the ESP with the Arduino ISP but can't figure out how (or if it's possible) to do this using the AT command set.
When programming with the Arduino IDE I basically need to post this to emoncms after establishing a TCP connection:
GET /feed/value.json?apikey=XXXXXXXXX&id=100486 HTTP/1.1
and on a new line:
Host:emoncms.org
and in the http response is the data I'm after i.e "3715113" (filtering the HTTP header was the next challenge).
I'm doing the following using the AT command set but only get a timeout from emoncms:
Code: Select all
cmd3 = "GET /feed/value.json?apikey=";
cmd3 += API_KEY;
cmd3 += "&id=100486";
cmd3 += " HTTP/1.1\r\n";
//get string length
Serial1.print(F("AT+CIPSEND="));
Serial1.println(cmd3.length());
delay(1000);
if (Serial1.find(">")) {
Serial1.println(cmd3);
}
admittedly I'm not sending the "Host:emoncms.org" on a new line (which the site seems to need) mainly because I don't know how to construct it.
can anyone help me out? What's the best way to read the HTTP response and then filter out the header and assign the data I'm after to a variable using the AT command set?
Reading serial responses seems to be a challenge, wish there was better firmware out there for interfacing with an Arduino.
Thanks