Is there any reason an Arduino Primo cannot send data to my ThingSpeak field?
2 views (last 30 days)
Show older comments
Does the device need to have a secure protocol? The Primo does not.
7 Comments
Christopher Stapels
on 17 Mar 2020
in the http request function, add some delay after the post is sent. 200 ms should do, but I suggest you start with 500 and work down.
// POST data to ThingSpeak.
if (client.connect(server, 80)) {
client.println("POST /update HTTP/1.1");
client.println("Host: api.thingspeak.com");
client.println("Connection: close");
client.println("User-Agent: Primo");
client.println("X-THINGSPEAKAPIKEY: "+writeAPIKey);
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.print(data.length());
client.print("\n\n");
client.print(data);
% ADD DELAY HERE
delay(500);
Serial.println("RSSI = " + String(field1Data));
lastConnectionTime = millis();
}
}
client.stop();
Accepted Answer
Dale Lamb
on 18 Mar 2020
Edited: Dale Lamb
on 19 Mar 2020
1 Comment
Christopher Stapels
on 18 Mar 2020
The bad example was my fault, so the least I can do is to see you through it. Thanks for letting me know it worked! I would still reccomend a bit more than 80 just to be safe. Unless you are really power strapped, 200 ms shouldnt hurt. The best thing to do is to actually poll for a response from the server, then you dont have to wait an arbitrary time. The ThingSpeak library does this, but I am sorry it wont compile for you. I read that you can also add a version of the dtostr function in the code yourself if you wish. Anyway, happy thingpseaking!
More Answers (0)
Communities
More Answers in the ThingSpeak Community
See Also
Categories
Find more on Read Data from Channel in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!