Filter löschen
Filter löschen

Plot a temperature scraped (time control set to 5 minutes) off a weather service?

3 Ansichten (letzte 30 Tage)
I scrape the temperature of my town from a weather service. I set time control to do this every 5 minutes and then send it to my field 6 in my channel.
When I do a csv data dump, the data looks like this:
FIELDS--- 1 2 3 4 5 6 7 8
2023-12-06T22:12:06-05:00 600020 36
2023-12-06T22:12:29-05:00 600021 59 55 55 0 0 -0.61 0
2023-12-06T22:13:08-05:00 600022 59 55 56 0 0 -0.60 0 etc, etc...
So, every 5 minutes, field 6 gets a value. The other fields get a value twice a minute or so.
The ThingSpeak widgets (gage, chart, digital) work fine for field 6. ThingSpeak just uses the data it finds in field 6 for widgets.
But, my attempted at #6 field plot visualization is blank, because my plotting uses "points", for example, 300 points, and as such, out of 300 reads there are maybe 270 blank #6 fields and 30 filled-in #6 fields. I think that if I upgrade to a paid license, I would be able to fix this issue, but it is not important for my present needs, not having toolbox access with my license, but is is under consideration.

Akzeptierte Antwort

Shore
Shore am 8 Dez. 2023
Bearbeitet: Shore am 10 Dez. 2023
I believe that at the free license level of subscription, plotting data needs to be all written to ThingSpeak at the same time, so that all "write" fields are populated.
  1 Kommentar
Shore
Shore am 16 Dez. 2023
Comment: I realize that one way to incorporate local airport temperature into a multi field channel is to scrape the local weather channel in the microprocessor wifi code instead of Matlab analysis and related time control, then write API all ThinkSpeak fields at once including airport temperature.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 7 Dez. 2023
This is a really interesting exercise. Here is one quick but not sufficiently accurate solution to get the numerical data imported correctly and plot them. Note that the downloaded .csv is also saved in an .xlsx format to read/import field1 to field8 columns. If your time steps are uniform then it might be a quick solution.
% Original data
D0 = readtimetable('feed_TS.csv');
% Time steps are obtained
Time = discretize(diff(D0.Var1), 'second');
Time = [0; Time]; % Initial value
Time = cumsum(Time); % Time history
% To get the data
D = readmatrix('feed_TS0.xlsx', 'Range', 'C2:J101');
plot(Time, D)
grid on
xlabel('Time, [s]')
ylabel('Temp')
  2 Kommentare
Shore
Shore am 7 Dez. 2023
Bearbeitet: Shore am 10 Dez. 2023
Sulaymon,
Thank you for your keen insight. Your answer works for offline plotting.
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
thanks
Shore
Shore am 8 Dez. 2023
Bearbeitet: Shore am 10 Dez. 2023
comment:
My investigation led me to take one of my unused channels and ONLY use the 5 minute time control on my matlab analysis on only 1 field, to aquire airport temperature in another city and try to plot it.
As can be seen above, the scraped data CAN be plotted because there are no gaps in the readings.

Melden Sie sich an, um zu kommentieren.

Communitys

Weitere Antworten in  ThingSpeak Community

Kategorien

Mehr zu Write Data to Channel finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by