Hi viiartz,
As rw950431 says look at the internet of people for a second and get the canonical hours Mr Sun visit us
I saw your channel (I think) where lux is overloading half-day. See the code below, please copy/paste and blindily run it; see the output box, copy results to Excel to see if that make sense, now erase/change at your pleasure all/any pzrt
% MATLAB Code below
readChannelID = 312667;
disp(['Working in channel number ',num2str(readChannelID)]); % you compose the text
%% Read Data - your choice on what you want %%
% one way to Read %
%lux = thingSpeakRead(readChannelID, 'OutputFormat','table' , 'NumDays', 1)
lux = thingSpeakRead(readChannelID, 'OutputFormat','table' , 'Numpoints', 5); % without ; ending to display
disp(lux.Lux); % case sensitive
% another way %
[luxx,timestamps] = thingSpeakRead(readChannelID, 'fields',[2] , 'Numpoints', 5);
disp(luxx);
%% selecting time lapse %%
t = datetime('now','TimeZone','local','Format','HH:mm:ss');
disp(['right now ' datestr(t)]);
lorita = datetime('now','TimeZone','America/Lima'); % datestr(datetime('now'),30)
yy=year(lorita); % it is "the today" every time this runs
mm=month(lorita);
dd=day(lorita);
% ho=hour(lorita); you will put your time
% mi=minute(lorita);
% se=second(lorita);
%% Mr.sun is coming ... Mr.sun is coming ... Mr.sun is coming ... Mr.sun is coming ...
tini1=datetime([yy,mm,dd,5,30,0]); %,'TimeZone','UTC') whatever you estimate/wish
tfin1=datetime([yy,mm,dd,6,30,0]); %,'TimeZone','UTC') here hour 6 min 30 secs 0 [06:30:00]
disp(['Mr.sun coming from ' datestr(tini1) ' to ' datestr(tfin1)]);
%% Mr.sun is leaving ... Mr.sun is leaving ... Mr.sun is leaving ... Mr.sun is leaving ...
tini2=datetime([yy,mm,dd,17,30,0]); %,'TimeZone','UTC') whatever you estimate/wish
tfin2=datetime([yy,mm,dd,18,30,0]); %,'TimeZone','UTC') here hour 6 min 30 secs 0 [06:30:00]
disp(['Mr.sun leaving from ' datestr(tini2) ' to ' datestr(tfin2)]);
[lux1,timestamp1] = thingSpeakRead(readChannelID, 'fields',[2] , 'DateRange',[tini1,tfin1]);
[lin1,col1]=size(lux1);
[lux2,timestamp2] = thingSpeakRead(readChannelID, 'fields',[2] , 'DateRange',[tini2,tfin2]);
[lin2,col2]=size(lux2);
disp(['coming ' num2str(lin1) 'x' num2str(col1) ' leaving ' num2str(lin2) 'x' num2str(col2)]);
%% nuclear/fision/fusion intergalactic calculations %%
[maxLux1, maxLuxIdx] = max(lux1);
[minLux1, minLuxIdx] = min(lux1);
[maxLux2, maxLux2Idx] = max(lux2);
[minLux2, minLux2Idx] = min(lux2);
% Choose the timestamp at which the maximum/minimum lux was measured
timeLuxTemp1 = timestamp1(maxLuxIdx);
timeLuxTemp2 = timestamp1(minLuxIdx);
timeLux2Temp1 = timestamp2(maxLux2Idx);
timeLux2Temp2 = timestamp2(minLux2Idx);
display(['Maximum lux Mr.sun coming is ' num2str(maxLux1) '->' datestr(timestamp1(maxLuxIdx))]);
display(['Minimum lux Mr.sun coming is ' num2str(minLux1) '->' datestr(timestamp1(minLuxIdx))]);
display(['Maximum lux Mr.sun leaving is ' num2str(maxLux2) '->' datestr(timestamp2(maxLux2Idx))]);
display(['Minimum lux Mr.sun leaving is ' num2str(minLux2) '->' datestr(timestamp2(minLux2Idx))]);
display('- - - - - - - - - - - -')
for c = 1:length(timestamp1)
disp([num2str(lux1(c)) '--' datestr(timestamp1(c),'HH:MM:SS')])
end
display('- - - - - - - - - - - -')
for c = 1:length(timestamp2)
disp([num2str(lux2(c)) '--' datestr(timestamp2(c),'HH:MM:SS')])
end
If it is of some help and you solve your issue post your code so others can use it