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

2 visualizaciones (últimos 30 días)
Does the device need to have a secure protocol? The Primo does not.
  7 comentarios
Dale Lamb
Dale Lamb el 17 de Mzo. de 2020
Editada: Dale Lamb el 17 de Mzo. de 2020
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 el 17 de Mzo. de 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();

Iniciar sesión para comentar.

Respuesta aceptada

Dale Lamb
Dale Lamb el 18 de Mzo. de 2020
Editada: Dale Lamb el 19 de Mzo. de 2020
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 comentario
Christopher Stapels
Christopher Stapels el 18 de Mzo. de 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!

Iniciar sesión para comentar.

Más respuestas (0)

Comunidades de usuarios

Más respuestas en  ThingSpeak Community

Categorías

Más información sobre Read Data from Channel en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by