Can´t send temperature values to thingspeak since two weeks | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Can´t send temperature values to thingspeak since two weeks
No permission to create posts
October 10, 2018
6:12 pm
Avatar
schwemmer
New Member
Members
Forum Posts: 2
Member Since:
October 10, 2018
sp_UserOfflineSmall Offline

Hi. My name is Jorge and nice to meet in this community.
I need help because my Wemos D1 Pro cant send temp values since two weeks. THe code is the same. In the serial monitor i can show temp values and i can see the message when Wemos connect to router, but the values never post.

The code is the same when temperature values was post two weeks ago, but now, nothing.

Code:

#include
#include
#include

const char* ssid = "SSID";
const char* password = "pass";

const char* server = "api.thingspeak.com";
String apiKey = "write api key";

float t;
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

WiFiClient client;
void setup()
{

Serial.begin(115200);
delay(10);
mlx.begin();

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED){
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}//cierre void setup

void loop()
{

Serial.print("Temperatura °C: ");
Serial.println(mlx.readObjectTempC());
t = mlx.readObjectTempC();
delay(200);

//Now, the ploblem:

if (client.connect(server,80)) {
String postStr = apiKey;
postStr +="&field1=";
postStr += String(t);
postStr += "

";;

client.print("POST /update HTTP/1.1
");
client.print("Host: api.thingspeak.com
");
client.print("Connection: close
");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"
");
client.print("Content-Type: application/x-www-form-urlencoded
");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("

");
client.print(postStr);

}
client.stop();

ESP.deepSleep( 300e6, WAKE_RF_DISABLED ); //300e6 son 5 min - 1800 media hora

}//cierre void loop

please, i need help because i have 15 temperature sensor waiting to colect data to my tesis.
thnks a lot and best regards
Jorge

October 11, 2018
2:02 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 442
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Does your channel update using the REST API from a browser?
Correct the Write API Key and paste this into the address window on the browser:
https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=54321

Next, I reccomend parseing the response from your device.
See the getRespone() function in this example:
https://www.mathworks.com/help/thingspeak/MoistureMonitor.html
?You should expect a 200 or 202 response.

or you can switch to using the ThingSpeak communication library as in this example.
https://www.mathworks.com/help/thingspeak/read-and-post-temperature-data.html

October 12, 2018
7:39 am
Avatar
schwemmer
New Member
Members
Forum Posts: 2
Member Since:
October 10, 2018
sp_UserOfflineSmall Offline

cstapels said

Does your channel update using the REST API from a browser?
Correct the Write API Key and paste this into the address window on the browser:
https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=54321

Next, I reccomend parsing the response from your device.
See the getRespone() function in this example:
https://www.mathworks.com/help/thingspeak/MoistureMonitor.html
?You should expect a 200 or 202 response.

or you can switch to using the ThingSpeak communication library as in this example.
https://www.mathworks.com/help/thingspeak/read-and-post-temperature-data.html  

Thanks for your help.
Tomorrow im going to try the last two options (the first works) because now im in the job. But i cant understand why my code doesn't work. When i upload to my Wemos, this was works 2 month but now, nothing (with the same code ) :/
x day, my Wemos stop send to Thingspeak but can see the temperature value in the serial monitor.

*Only to try i was create another channel with another account in thingspeak and the same code. The result is the same. Cry

October 15, 2018
3:53 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 442
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

I would also replace this

client.print(postStr.length());
client.print("

");

with

client.println(postStr.length());
client.println(); //need blank line to terminate request

Just in case the library you are using doesn't understand the line endings. Perhaps you ungraded the library and something changed?

Were you able to parse for a response from the server?

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
40 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

Williampes, esmeraldagx11, lilacs16, loriexo60, ThomasHut, WernerDernnida

Administrators: Hans: 387, lee: 457