Running CURL - Post method to Thingspeak

9 visualizaciones (últimos 30 días)
AMMAS
AMMAS el 4 de Abr. de 2020
Comentada: AMMAS el 5 de Abr. de 2020
Hey guys, I have been researching and I am trying to build a function that posts the output of a sensor to thingspeak on the Arduino Yun.
Here is my code so far, but I am getting no success, unfortunately. After looking up on the internet, everywhere I can, this is what I came up with.
void postToThingSpeak(int value) {
Process p;
String cmd = "curl -d 'key=XXXXXXXXXXXXXXXXX&field1=";
cmd = cmd + value;
cmd = cmd + "' -k http://api.thingspeak.com/update";
p.runShellCommand(cmd);
Serial.println(cmd);
// do nothing until the process finishes, so you get the whole output:
while(p.running());
}
PS: I took the cmd after it was printed, and ran it in terminal and it worked perfectly. For some reason it's not working on the Arduino Yun though.
Any assistance would be appreciated, thank you very much!

Respuesta aceptada

Vinod
Vinod el 5 de Abr. de 2020
Have you tried starting from the examples in the ThingSpeak library? There are specific examples for the Yun that you can start from: https://github.com/mathworks/thingspeak-arduino/tree/master/examples/ArduinoYun
  1 comentario
AMMAS
AMMAS el 5 de Abr. de 2020
Thank you very much, that's exactly what I needed.

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 ThingSpeak en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by