Running CURL - Post method to Thingspeak

조회 수: 9 (최근 30일)
AMMAS
AMMAS 2020년 4월 4일
댓글: AMMAS 2020년 4월 5일
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
  댓글 수: 1
AMMAS
AMMAS 2020년 4월 5일
Thank you very much, that's exactly what I needed.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

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