Send more than one value in Field 1. Buffer of values.
5 views (last 30 days)
Show older comments
Hello! I would like to know if any of you know how I could send a list of values all as field1.
From postman it would look something like this:
The data is sent because I can see it by downloading the excel but not graphed. Do you know if it is possible to send them all together and graph them?
Thanks
4 Comments
Christopher Stapels
on 30 Apr 2024
Can you show the data? I dont want you to share your API key if possible.
Answers (2)
Christopher Stapels
on 30 Apr 2024
Edited: Christopher Stapels
on 30 Apr 2024
ThingSpeak cannot parse the data you have in your field since it has string characters in it. MATLAB can though.
First you need to tell ThingSpeak you want to read string data. The easiest way to do this is with a timetable.
data = thingSpeakRead(readChannelID, 'Fields', [1,2], 'NumPoints', 70, 'ReadKey', readAPIKey,'outputformat','timetable');
Now you will need to split you data. The format in your channel changes wildly for the most recent points. I would probably reconsider the current format you are writing in.
But, lets say you want to plot the most recent point.
splitData=split(data.FieldLabel1(end),newline);
myNums=str2double(splitData);
plot(myNums);
0 Comments
Christopher Stapels
on 1 May 2024
Edited: Christopher Stapels
on 1 May 2024
We definitely need to change he way you are sending data to ThingSpeak. (I would clear the data and start over)
Do you intend to have a large number of plots, such as one per feed entry?
Otherwise you should send the data as 70 individual points. Then you will have one live graph.
i.e.
https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=<X1>&field2=<y1>
wait
https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=<X2>&field2=<y2>
...
or using thingSpeakWrite and a table. (see the doc) thingSpeakWrite
If you need to have a different x axis, I would reccomend you use a custom MATLAB visualization.
In the case where you want each feed point to be a seperate plot:
If field1 is the x data and field2 is the y data, you will need to compress the data further.
In one point you have 484.00 by 0.,73 (im not sure why you are using comma and decimal as a seperator.)
The x data has 6 characters, so if you write them with a seperator, they will take up (6+1)*70 characters, which is more than the 255 you can fit in one field. In this case you could reduce the accuracy of the data(to reduce the number of characters), or reduce the number of data points from 70 , or use multiple feeds to hold the whole dataset. If you take this route, I would reccoend a different data seperator, perhaps a '\' character.
4 Comments
Communities
More Answers in the ThingSpeak Community
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!