Running CURL - Post method to Thingspeak

4 Ansichten (letzte 30 Tage)
AMMAS
AMMAS am 4 Apr. 2020
Kommentiert: AMMAS am 5 Apr. 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!

Akzeptierte Antwort

Vinod
Vinod am 5 Apr. 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 Kommentar
AMMAS
AMMAS am 5 Apr. 2020
Thank you very much, that's exactly what I needed.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Communitys

Weitere Antworten in  ThingSpeak Community

Kategorien

Mehr zu ThingSpeak finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by