Daily max and min | ThingSpeak Apps | Forum


Please consider registering


— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Daily max and min

Forum Posts: 13
sp_UserOfflineSmall Offline
September 13, 2016 - 6:33 am
sp_Permalink sp_Print

Dear all

I looked long and hard for code that would calculate daily maxima and minima for temperature and humidity (i.e since midnight) but I couldn't find any.

I eventually managed to work it out, so I'm posting it here in case it helps others. The max & min graphs by themselves are not very interesting, but I use these data in Google Gauge to display the last value. I also found that creating a React app for running the code on each new temperature insertion is better than using the Time Control app. In the Time control app (which only runs every 5min), the current temperature can often be higher than the max temperature in the morning - this doesn't look cool!


% My implementation of daily max and min temperature and humidity, written to another channel (fields 2 to 5) for later display in Google Gauge using the standard plug-in. This code assumes a public channel to read the original data from.

readChannelID= 'xxxxxxxxxxxx';



% Define date range (i.e. since midnight)
end = datetime('now')

% Read the Temp data from Field1 since midnight
[Temp, time] = thingSpeakRead(readChannelID,'DateRange', [start,end], 'Fields', [1]);
Tmax = max(Temp); % Get daily Max
Tmin = min(Temp); % Get daily Min
% Read the Humidity data from Field2 since midnight
[Humidity, time] = thingSpeakRead(readChannelID, 'DateRange', [start, end], 'Fields', [2]);
Hmax = max(Humidity); % Get daily Max
Hmin = min(Humidity); % Get daily Min

% display results to test
display(Tmax, 'T_max'), display(Tmin, 'T_min')
display(Hmax, 'H_max'), display(Hmin, 'H_max')

% Write data to a new channel
thingSpeakWrite(writeNewChannelID,'Fields',[2,3,4,5],'Values',{Tmax,Tmin,Hmax,Hmin}, 'Writekey', writeAPIKey);

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:







Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565


Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee