http.GET() response -2 but data are sent properly | ESP8266 Wi-Fi Module | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
http.GET() response -2 but data are sent properly
Avatar
alcapar
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
1
December 27, 2017 - 2:14 pm
sp_Permalink sp_Print

I need to check data are correctly handled. Now I try to get httpcode and always returns -2 but data are sent properly. The code is:

if (client.connect("api.thingspeak.com",80)) {
writeAPIKey = "key=XXXXXXXXXXX";
tsfield1Name = "&field1=10";
request_string = thingSpeakAddress;
request_string += "key=";
request_string += "XXXXXXXXXXXX";
request_string += "&";
request_string += "field5";
request_string += "=";
request_string += (tempe);
http.begin(request_string);
http.GET();
int httpCode = http.GET();
Serial.println(httpCode);
String payload = http.getString(); //Get the request response payload
Serial.println(payload);
http.end();

I am sure something is wrong.

Avatar
Vinod

Forum Posts: 183
sp_UserOfflineSmall Offline
2
December 28, 2017 - 9:27 pm
sp_Permalink sp_Print

Perhaps you want to try modifying one of the many examples listed here:

https://www.mathworks.com/help/thingspeak/examples.html

Avatar
alcapar
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
3
December 31, 2017 - 12:50 pm
sp_Permalink sp_Print

Thank you, I did it and it works.

Smile

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
27 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

candacele1

WilliamBer

roxieob18

Metawatch

ozayagw

ubabeutiti

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee