ThingSpeak Channel stopped receiving data since April 13th 2022

6 views (last 30 days)
My channel had been working fine for over a year until April 13 arrived. I've actually just noticed that the channel has not been updating for the past 4 months.
I have read a few topics on this issue and tried to fix the problem myself but not being a coder I have failed misarably. It seems the issue is related to an update done on ThingSpeak and is related to how spaces are encoded (%20). So here is the code that I presume needs fixing:
// code block for uploading data to Thingspeak website
if (App2 == "THINGSPEAK") {
// Send data to ThingSpeak
WiFiClient client;
if (client.connect(server,80)) {
Serial.println("Connect to ThingSpeak - OK");
String postStr = "";
postStr+="GET /update?api_key=";
postStr+=api_key;
postStr+="&field1=";
postStr+=String(rel_pressure_rounded);
postStr+="&field2=";
postStr+=String(measured_temp);
postStr+="&field3=";
postStr+=String(measured_humi);
postStr+="&field4=";
postStr+=String(volt);
postStr+="&field5=";
postStr+=String(measured_pres);
postStr+="&field6=";
postStr+=String(DewpointTemperature);
postStr+="&field7=";
postStr+=String(HeatIndex);
postStr+="&status=";
postStr+=String(forecast_in_words + ": " + ZambrettisWords + ". " + pressure_in_words + " " + trend_in_words + ". " + accuracy_in_words + " " + accuracy_in_percent + "%25.");// Percentage sign needs to be URL-encoded
postStr+=" HTTP/1.1\r\nHost: a.c.d\r\nConnection: close\r\n\r\n";
postStr+="";
client.print(postStr);
Serial.println("Data written to Thingspeak ...");
}
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
}
Can anyone help me fix this? Thank you.

Answers (2)

Christopher Stapels
Christopher Stapels on 29 Aug 2022
We strongly reccomend using the thingSpeak library for arduino and esp if possible.
I dont see the problem directly. I would reccomend you try removing things one at a time.
For example, you could comment after field 1 and try just writing a set number to ThingSpeak. (here I used 123)
String postStr = "";
postStr+="GET /update?api_key=";
postStr+=api_key;
postStr+="&field1=123";
//postStr+=String(rel_pressure_rounded);
//postStr+="&field2=";
...
client.print(postStr);
Then add each line back in one at a time to make sure it works.
This line also looks a bit odd
postStr+=String(forecast_in_words + ": " + ZambrettisWords + ". " + pressure_in_words + " " + trend_in_words + ". " + accuracy_in_words + " " + accuracy_in_percent + "%25.");// Percentage sign needs to be URL-encoded
Let us know if you figure out the offending line.
  1 Comment
Paul Lefevre
Paul Lefevre on 29 Aug 2022
I tried as suggested the following. I still can't see any data written in my channel.
if (App2 == "THINGSPEAK") {
// Send data to ThingSpeak
WiFiClient client;
if (client.connect(server,80)) {
Serial.println("Connect to ThingSpeak - OK");
String postStr = "";
postStr+="GET /update?api_key=";
postStr+=api_key;
postStr+="&field1=32";
//postStr+=String(rel_pressure_rounded);
//postStr+="&field2=";
//postStr+=String(measured_temp);
//postStr+="&field3=";
//postStr+=String(measured_humi);
//postStr+="&field4=";
//postStr+=String(volt);
//postStr+="&field5=";
//postStr+=String(measured_pres);
//postStr+="&field6=";
//postStr+=String(DewpointTemperature);
//postStr+="&field7=";
//postStr+=String(HeatIndex);
//postStr+="&status=";
//postStr+=String(forecast_in_words + ": " + ZambrettisWords + ". " + pressure_in_words + " " + trend_in_words + ". " + accuracy_in_words + " " + accuracy_in_percent + "%25.");// Percentage sign needs to be URL-encoded
//postStr+=" HTTP/1.1\r\nHost: a.c.d\r\nConnection: close\r\n\r\n";
//postStr+="";
client.print(postStr);
Serial.println("Data written to Thingspeak ...");
}
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
}
For what it's worth here is the full code of that project. I only pasted earlier what seemed relevant to me: https://github.com/3KUdelta/Solar_WiFi_Weather_Station/blob/master/Solar-WiFi-Weather-Station-V2.3.ino

Sign in to comment.


Paul Lefevre
Paul Lefevre on 30 Aug 2022
The author of the code updated it and used the ThinkSpeak library now. It's all working nicely now.

Communities

More Answers in the  ThingSpeak Community

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!