Is there any reason an Arduino Primo cannot send data to my ThingSpeak field?

2 ビュー (過去 30 日間)
Dale Lamb
Dale Lamb 2020 年 3 月 13 日
編集済み: Dale Lamb 2020 年 3 月 19 日
Does the device need to have a secure protocol? The Primo does not.
  7 件のコメント
Dale Lamb
Dale Lamb 2020 年 3 月 17 日
編集済み: Dale Lamb 2020 年 3 月 17 日
I included the avr/dtostrf.h to my script, compiler accepted it, but I still get the same error message on the dtostrf line in the ThingSpeak file. I also tried adding delays in the "Wireless Network Signal Strength" code (as suggested above) at several points but still get no update. Where does the delay go and how much delay is enough? Could the Primo's 32 bit "int" be causing problems?
Christopher Stapels
Christopher Stapels 2020 年 3 月 17 日
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();

サインインしてコメントする。

採用された回答

Dale Lamb
Dale Lamb 2020 年 3 月 18 日
編集済み: Dale Lamb 2020 年 3 月 19 日
It Worked!!!! I got it to work with a delay as low as 40 msec, but set it to 80 msec for margin.
Thank you Christopher Stapels for seeing me through this!
Recap: Send data to ThingSpeak using Arduino Primo
Two approaches were reccommended, approach 2 worked
1). The approach shown in https://github.com/mathworks/thingspeak-arduino did not work for my Primo, the error suggesting a problem with dtostrf, even when the library was added. Was unable to resolve due to my limited experience/time availability.
2). I modified Arduino IDE's Example/WifiLink/WifiWebClient.ino by swapping in the POST commands found in the ThingSpeak example "Wireless Network Signal Strength" with a delay added as per Christopher Stapels previous comment. Success was achieved. :)
  1 件のコメント
Christopher Stapels
Christopher Stapels 2020 年 3 月 18 日
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!

サインインしてコメントする。

その他の回答 (0 件)

コミュニティ

その他の回答  ThingSpeak コミュニティ

カテゴリ

Help Center および File ExchangeRead Data from Channel についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by