Running CURL - Post method to Thingspeak

4 views (last 30 days)
AMMAS
AMMAS on 4 Apr 2020
Commented: AMMAS on 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!

Accepted Answer

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

Sign in to comment.

More Answers (0)

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on ThingSpeak in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!