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: 510
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: 510
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?

November 2, 2018
2:16 pm
Avatar
CuteGolem
New Member
Members
Forum Posts: 2
Member Since:
November 2, 2018
sp_UserOfflineSmall Offline

AT+CIPSTART="TCP","api.thingspeak.com",80

THIS LINE WHEN I TYPE THROUGH SERIAL MONITOR SHOWS
CONNECT
OK

BUT WHEN I PASS THE LINE TO MY PROGRAM THROUGH
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += "184.106.153.149"; // Endereco IP de api.thingspeak.com
cmd += "\",80";

IT WONT WORK
PLS HELP!!

THANKS

November 2, 2018
3:55 pm
Avatar
cstapels
Moderator
Members


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

hi CuteGolem:
Can you describe your hardware and any details about your project?
That should help us to help you debug the issue.

November 3, 2018
1:18 am
Avatar
piajola

Gold
Members
Forum Posts: 99
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

Hi CuteGolem;

Try one of this hardcoded
Serial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80");
Serial.println("AT+CIPSTART=\"TCP\",\"184.106.153.149\",80");
or better

Serial.println(F("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80"));
Serial.println(F("AT+CIPSTART=\"TCP\",\"184.106.153.149\",80"));
to use less RAM and not messing too much with the Strings (and RAM)

This is not variable this is a "string" of fixed characters

Remember Ardu has NOT a lot of RAM..

Hope this is of little helpSmile

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: SGDamiano1
32 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

petersevruk, SGDamiano1, seanoz60, Beverlytreta, MartaKah, genevievecu69

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457