ThingSpeak : Read & Write Multiple Field

12 次查看(过去 30 天)
Ravi Ghimire
Ravi Ghimire 2021-1-27
编辑: Vinod 2021-10-14
Hello, Could you please recommend me best method for multiple fields read & right in ThingSpeak?
  1. I want to write in MATLAB Simulink via ThingSpeak Cloud from MIT APP Inventer Application , 4 fields with ( digital write 0,1)?
  2. I want to read 3 field value and read it from MIT App inventor via ThingSpeak Cloud?
i have problem in reading and writing multiple channels , can somebody recommend be the best way.

回答(3 个)

Christopher Stapels
Can you describe the data flow a bit more?
"in MATLAB Simulink via ThingSpeak Cloud from MIT APP Inventer Application "
What is the MIT App interacting with? Is it a deployed simulink model on hardware?
The MIT app will support POST commands (I'm pretty sure), you can post to you channel using the REST API write endpoint. You can update multiple fields simultaneously.
POST https://api.thingspeak.com/update
api_key=XXXXXXXXXXXXXXXX
field1=73
field2=37
etc...
You can also use the GET command and append additional fields
Similarly, you can read the whole feed (all fields ) at once with read data. I would use the JSON format, then you can parse the response for the fields you want.
https://api.thingspeak.com/channels/<channel_id>/feeds.<format>

BEHNAM MOBARAKI .
BEHNAM MOBARAKI . 2021-5-20
Hi every body.
I am sending temperature measurement of 3 sensors to 3 fields of a channel in ThinSpeak (through NODEMCU ESP8266). What I need is that to do calculation of data from these 3 fields. For instance, I need to take the average of temperature of the 3 sensors at time n, then taking average the 3 measurements at time n+1 then at time n+2. Finaly illustrate the average curve on a single graph.
Could you please help me in this way?!
  3 个评论
BEHNAM MOBARAKI .
BEHNAM MOBARAKI . 2021-5-20
Many thanks Christopher,
I folloewd the example and it was very usefull. This example takes the average value of the measurements in a single field (lets say a single sensor). In my case, I have 3 fields (each filed is receiving temperature measuremnt from individual sensor). All the sensors have the same measurement frequency. What I need is that to read/take the temperature at time N from all the 3 sensors (in 3 fields), take the average of them and send the average value to a new channel. The second input of the new channel gonna be average value of temperature from the 3 sensors at time N+1.
I mean I wanna do calculation on the inputs of multiple fields and send it to another channel.
Thanks in advance for your help
SHUAI TAN
SHUAI TAN 2021-8-19
brother may i know your code for reading a specific timestep

请先登录,再进行评论。


Nazmi Rosly
Nazmi Rosly 2021-8-16
编辑:Vinod 2021-10-14
Hi. Im trying to send data from matlab which is the data from serial monitor from arduino. It is fine until 9th of data and then it stopped and says :
Error using Untitled (line 27)
'Values' must have a maximum of 9 elements, including the timestamp.
My coding is:
clear all
s = serial('com4');
fopen(s);
i = 1;
while(1)
data(i)= str2double(fscanf(s));
plot(data);
title('Temperature Monitoring')
xlabel('Time')
ylabel('Temperature')
pause(30);
i=i+1;
%thingSpeakWrite(1463959,data,'WriteKey','MYWRITEAPIKEY')
% Generate timestamps for the data
%tStamps = datetime('now')-minutes(9):minutes(1):datetime('now');
channelID = 1463959; % Change to your Channel ID
writeKey = 'MYWRITEAPIKEY'; % Change to your Write API Key
% Write 10 values to each field of your channel along with timestamps
tStamp = datetime('now')
thingSpeakWrite(1463959,data,'WriteKey','MYWRITEAPIKEY','TimeStamp',tStamp)
end
  1 个评论
Christopher Stapels
Christopher Stapels 2021-10-14
You've put too many values in your data array. ThingSpeak only had 8 fields. Perhaps you meant data(i) in your thingSpeakWrite command

请先登录,再进行评论。

社区

更多回答在  ThingSpeak Community

类别

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