How to write to thingspeak channel from thinghttp?

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

请先登录,再进行评论。

采纳的回答

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 Community

类别

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