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

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 comentarios

It is definitely possible to plot your data, and the built in MATLAB has nearly infinite plottting configurations. You probably also can get your data to show in the live ThingSpeak field plots on your channel view in addition to using custom MATALB visualizations.
It appears there may be extra characters with your data that is making ThingSpeak interpret them as string. This will make it not possible to plot the data. I'm not totally clear about the format of your data. Can you share the result of this query in a browser address bar? (you may need to add the api key if it is a private channel, see the API keys tab of your channel view for the format.)
https://api.thingspeak.com/channels/<CHANNEL ID>/feeds.json?results=2
Paula
Paula el 30 de Abr. de 2024
Editada: Christopher Stapels el 30 de Abr. de 2024
Hello Critopher,
Thanks a lot for your answer
here it is: https://api.thingspeak.com/channels/2515826/feeds.json?api_key=xxxxxxxxxxxxxxxx&results=2
The data is received and I use a very simple code(custon no start code) to plot it with matlab but I think it only reads the first value of the data line.
readChannelID = 2515826;
% TODO - Replace the [] with the Read API Key:
readAPIKey = 'xxxxxxxxxxxxxxxx';
%% Read Data %%
[data, time] = thingSpeakRead(readChannelID, 'Fields', [1,2], 'NumPoints', 70, 'ReadKey', readAPIKey);
%% Visualize Data %%
% Ordenar los datos en función de la coordenada en el eje X
sorted_data = sortrows(data, 1);
% Graficar los datos de coordenadas en el eje Y y el eje X con una línea que sigue los puntos
plot(sorted_data(:,1), sorted_data(:,2), '-o'); % La opción '-o' traza líneas con marcadores en los puntos
xlabel('Coordenada en el eje X');
ylabel('Coordenada en el eje Y');
title('Grafico de Coordenadas');
Can you show the data? I dont want you to share your API key if possible.
Paula
Paula el 1 de Mayo de 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

Iniciar sesión para comentar.

Respuestas (2)

Christopher Stapels
Christopher Stapels el 30 de Abr. de 2024
Editada: Christopher Stapels el 30 de Abr. de 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 el 1 de Mayo de 2024
Editada: Christopher Stapels el 1 de Mayo de 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 comentarios

Paula
Paula el 2 de Mayo de 2024
Hello,
All right. I will start by sending only 3 points.
The project is to calculate a FFT and therefore I need to send all the data at once. If I send one by one (e.g. 484 by 0,73) it takes about 7 minutes to receive all the data and that is too long.
Let's say now that I send only 3 data like this:
these points do not reach the platform (I can't see them in the excel).
If I send them like this:
I receive this:
So, I don't know what separator to put between the data (postman I use it as a test, actually everything goes in a program in arduino code).
But the option of sending data to data right now I can't contemplate it because it takes too long to get the whole frame.
I also don't know what to change in my matlab code to be able to plot that data, that is to say, to read the list, in this case of 3 data.
Thanks
Christopher Stapels
Christopher Stapels el 2 de Mayo de 2024
Editada: Christopher Stapels el 2 de Mayo de 2024
Though I appreciate you taking the time to show the screen shots, its a little hard to understand exactly what you are posting in postman.
You could use the bulk update endpoint to send 484 rows at once. This is my suggestion, though it will consume more messages. You can do a bulk update every 15 seconds, would this fit your workflow?
The syntax for bulk update is a bit more tricky, but if you plan to use it I would suggest switching to it now.
We can work on the MATLAB code to read it once you get the dat in the right format.
Regarding the slash test, I was able to make it work using postman. In this image you can see what I wrote in postman (top) and what I got in the field(bottom). It looks like there was an extra slash added (probably escaping) so I might choose a different separator if you are going down this route instead of bulk update. maybe *, ( or %.
Paula
Paula el 4 de Mayo de 2024
Editada: Paula el 4 de Mayo de 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
plot(data.(1),myNums);
or
plot(data.<field1label>,myNums);

Iniciar sesión para comentar.

Comunidades de usuarios

Más respuestas en  ThingSpeak Community

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Abr. de 2024

Comentada:

el 7 de Oct. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by