Clear Filters
Clear Filters

Send more than one value in Field 1. Buffer of values.

11 views (last 30 days)
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
Christopher Stapels on 30 Apr 2024
Can you show the data? I dont want you to share your API key if possible.
Paula
Paula on 1 May 2024
Hi, this are the values that I send to thigspeak
And these are the values that arrive at the platform (I can see from the downloadable excel):
Field1 represents the abscissa axis and field2 the ordinate axis, something like this.
with the matlab code I provide only the first value of each field is represented and not all the characters.
Thanks

Sign in to comment.

Answers (2)

Christopher Stapels
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);

Christopher Stapels
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
Paula
Paula on 4 May 2024
Edited: Paula on 4 May 2024
Hello,
After several unsuccessful attempts to send data with different separators. I finally seem to be getting closer to my goal thanks to your help.
I only have one problem.
The graph should be plotted with the values of field2 on the ordinate axis and field1 on the abscissa axis.
Using the last one you provided and entering the field2, I only get the field2 on the ordinate axis:
readChannelID = 2515826;
% TODO - Replace the [] with the Read API Key:
readAPIKey = 'XXXXXXXXXXXXXXXXXXXX';
%% Read Data %%
data = thingSpeakRead(readChannelID, 'Fields', [1,2], 'NumPoints', 70, 'ReadKey', readAPIKey,'outputformat','timetable');
%% Visualize Data %%
% Ordenar los datos en función de la coordenada en el eje X
splitData=split(data.FieldLabel2(end),newline);
myNums=str2double(splitData);
plot(myNums);
Do you know what change I have to make to represent field1 on the ordinate axis?
Thank you very much
Christopher Stapels
Christopher Stapels on 7 Oct 2024 at 13:44
plot(data.(1),myNums);
or
plot(data.<field1label>,myNums);

Sign in to comment.

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on ThingSpeak in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!