11:42 am

November 20, 2018

Hi
I am new to this platform and Matlab but I have manage to get to the point where I can make a 3d bar chart of temperatures for the trailing 6 days. You can view the result at the bottom of this page:
https://thingspeak.com/channels/630872
My code is below. Can anyone help me understand why, no matter how much data I bring back (I've checked that I am getting more than 6 days worth of data), I only get a trailing 6 days of data. You can see from the code below, the 'trailingdays' variable is set to 10 but I still only get 6 days of data. Can someone help me understand why? Also any suggestions on ways / functions I could have used to make the below more simple, would be very much welcomed.
Thanks
Ben
readChannelID = 624093;
readAPIKey = 'WEA8ALITMF5CLN4N';
trailingdays = 10
[data,timestamps] = thingSpeakRead(readChannelID,'ReadKey',readAPIKey,'Fields',[1],'NumDays',trailingdays);
TT1 = array2timetable(data,'RowTimes',timestamps);
TT2 = retime(TT1,'hourly','mean');
mytime=(TT2.Time);
mydata=(TT2.data);
mytimeTZ = datetime(mytime, 'TimeZone','UTC');
mytimeTZ.TimeZone = 'America/New_York';
myhour=hour(mytimeTZ)
myday=day(mytimeTZ)
h=zeros(24,trailingdays);
t=datetime
tTZ = datetime(t, 'TimeZone','UTC');
tTZ.TimeZone = 'America/New_York';
tominus=(day(tTZ)-trailingdays-1)
for i = 1:(length(myhour))
x = int8((myhour(i))+1)
y = int8((myday(i))-tominus);
z = mydata(i);
h(x,y) = z;
end
for i = 1:trailingdays+1
[DayNumber, DayName] = weekday(t-trailingdays-1+i)
xnames{i}=DayName
end
bar3(h)
az =27.5;
el = 20;
view(az, el);
ylim([0 25])
ynames = {'00:00'; '06:00'; '12:00'; '18:00'; '24:00'};
set(gca,'ytick',[0 6 12 18 24],'yticklabel',ynames)
set(gca,'xtick',[1:trailingdays+1],'xticklabel',xnames)
xtickangle(90)
title(['Outdoor Temp - ',num2str(trailingdays),' days trailing'])
xlabel('Day')
ylabel('Time of Day')
zlabel('Temperature')
11:57 pm


Moderators
March 7, 2017

How often does your channel update? ThingSpeak has an 8000 point limit per query. If your channel updated every minute, you would only be able to get 6 days in one read.
You may be able to increase the time span using averaging of median. You can also perform multiple reads and concatenate the data. Be careful when performing too many successive reads however.
One good workaround is to create a second channel that aggregates the data from the first channel.
Please let us know if that helps.
Most Users Ever Online: 166
Currently Online:
29 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 272
Vinod: 240
piajola: 95
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 8665
Moderators: 1
Admins: 2
Forum Stats:
Groups: 3
Forums: 14
Topics: 1600
Posts: 5760
Newest Members:
Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormierModerators: cstapels: 460
Administrators: Hans: 405, lee: 457