Running CURL - Post method to Thingspeak

7 次查看(过去 30 天)
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!

采纳的回答

Vinod
Vinod 2020-4-5
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

更多回答(0 个)

社区

更多回答在  ThingSpeak Community

类别

Help CenterFile Exchange 中查找有关 ThingSpeak 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by