How to write to thingspeak channel from thinghttp?

3 visualizaciones (últimos 30 días)
Tobias Wagner
Tobias Wagner el 5 de Nov. de 2022
Comentada: Tobias Wagner el 10 de Nov. de 2022
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 comentarios
Christopher Stapels
Christopher Stapels el 7 de Nov. de 2022
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 el 7 de Nov. de 2022
Thanks for your comment. I'll check it out.

Iniciar sesión para comentar.

Respuesta aceptada

Christopher Stapels
Christopher Stapels el 10 de Nov. de 2022
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 comentario
Tobias Wagner
Tobias Wagner el 10 de Nov. de 2022
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')

Iniciar sesión para comentar.

Más respuestas (0)

Comunidades de usuarios

Más respuestas en  ThingSpeak Community

Categorías

Más información sobre Read Data from Channel en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by