Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Paula
Paula le 28 Avr 2024
Modifié(e) : Paula le 4 Mai 2024
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 commentaires
Christopher Stapels
Christopher Stapels le 30 Avr 2024
Can you show the data? I dont want you to share your API key if possible.
Paula
Paula le 1 Mai 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

Connectez-vous pour commenter.

Réponses (2)

Christopher Stapels
Christopher Stapels le 30 Avr 2024
Modifié(e) : Christopher Stapels le 30 Avr 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 le 1 Mai 2024
Modifié(e) : Christopher Stapels le 1 Mai 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.
  3 commentaires
Christopher Stapels
Christopher Stapels le 2 Mai 2024
Modifié(e) : Christopher Stapels le 2 Mai 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 le 4 Mai 2024
Modifié(e) : Paula le 4 Mai 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

Connectez-vous pour commenter.

Communautés

Plus de réponses dans  ThingSpeak Community

Catégories

En savoir plus sur Act on Data dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by