How to write to thingspeak channel from thinghttp?

조회 수: 2 (최근 30일)
Tobias Wagner
Tobias Wagner 2022년 11월 5일
댓글: Tobias Wagner 2022년 11월 10일
Hi everybody, I have successfully created a thinghttp that returns a number. It's running with time control. How can I write the number to a thingspeak channel?
  댓글 수: 2
Christopher Stapels
Christopher Stapels 2022년 11월 7일
Do you use a device to get the number fom ThingHTTP? If yes, you can have the device write the number to a ThingSpeak channel.
If your ThingHTTP is interacting with an external website, you can rewrite it in MATLAB analysis using webread or webwrite. Then you can add thingSpeakWrite commands in the script to write it to your channel. You can trigger MATLAB analysis with TimeControl.
Tobias Wagner
Tobias Wagner 2022년 11월 7일
Thanks for your comment. I'll check it out.

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

채택된 답변

Christopher Stapels
Christopher Stapels 2022년 11월 10일
If your ThingHTTP is interacting with an external website, you can rewrite it in MATLAB analysis using webread or webwrite. Then you can add thingSpeakWrite commands in the script to write it to your channel. You can trigger MATLAB analysis with TimeControl.
  댓글 수: 1
Tobias Wagner
Tobias Wagner 2022년 11월 10일
Works great
import matlab.io.xml.dom.*
import matlab.io.xml.xpath.*
weboptions('Timeout',60);
data=webread("http://xxx/values.xml");
doc = parseString(Parser,data);
xpExpr = "//device[@id='AI03IV']/v1";
res = evaluate(Evaluator,xpExpr,doc);
b0 = res.getTextContent()
xpExpr = "//device[@id='AI05IV']/v1";
res = evaluate(Evaluator,xpExpr,doc)
lake = res.getTextContent()
xpExpr = "//device[@id='AI04IV']/v1";
res = evaluate(Evaluator,xpExpr,doc)
filtr = res.getTextContent()
data = [str2num(b0),str2num(lake),str2num(filtr)]
response = thingSpeakWrite(xxx,data,'WriteKey','xxx')

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

추가 답변 (0개)

커뮤니티

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

카테고리

Help CenterFile Exchange에서 Act on Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by