The following example program was complied in Arduino 1.6.7 environment using <ESP8266HTTPClient.h> library
code:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#define USE_SERIAL Serial
ESP8266WiFiMulti WiFiMulti;
void setup() {
USE_SERIAL.begin(115200);
for(uint8_t t = 4; t > 0; t--) {
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
USE_SERIAL.flush();
delay(1000);
}
WiFiMulti.addAP("FiniteSpace", "password");
}
void loop() {
// wait for WiFi connection
if((WiFiMulti.run() == WL_CONNECTED)) {
HTTPClient http;
USE_SERIAL.print("[HTTP] begin...\n");
http.begin("api.thingspeak.com", 80, "/talkbacks/7409/commands/execute?api_key=CXDELYYFS80S3AYR"); //HTTP
int httpCode = http.GET();
if(httpCode) {
// HTTP header has been send and Server response header has been handled
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
if(httpCode == 200) {
String payload = http.getString();
USE_SERIAL.println(payload);
}
}
}
delay(1000);
}
error from the complier
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp: In member function 'bool HTTPClient::beginInternal(String, const char*)':
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp:151:32: error: 'base64' has not been declared
_base64Authorization = base64::encode(auth);
^
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp: In member function 'void HTTPClient::setAuthorization(const char*, const char*)':
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp:273:32: error: 'base64' has not been declared
_base64Authorization = base64::encode(auth);
^
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp: In member function 'String HTTPClient::getString()':
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp:640:5: error: 'StreamString' was not declared in this scope
StreamString sstring;
^
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp:640:18: error: expected ';' before 'sstring'
StreamString sstring;
^
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp:644:13: error: 'sstring' was not declared in this scope
if(!sstring.reserve((_size + 1))) {
^
/home/bharu/Arduino/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp:650:20: error: 'sstring' was not declared in this scope
writeToStream(&sstring);
^
exit status 1
Error compiling.
I had installed base64 library, String stream library how to sort this problem