Field Chart :problem with "sum" function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to sum up the inputs of a field varible (1 value /min) from 00:00a.m. until12:00p.m. (24 hours) and then store it as "previous day" value.
It works fine during the day, but the value at 12p.m. is not completly stored ( only 20 ...35% of the totalized value) as previous day value.
It works perfectly for hourly sums (60 data points).
Is there a limit of max. data points? one day = 1440 data points
I use the follwing parameters:
type: column
dynamic: true
days: 10
Sum: daily
Are these the right parameters?
Many thanks in advance for support
8 commentaires
David Stacer
le 19 Fév 2020
I do this on several of my channels, where I log data to one channel every minute then once a day run a timecontrol job that reads from the detail channel, counts, compute or sum's up a field and writes one record to another channel.
It took a while to figure this out so some code snipps to get you started.
EndDate = datetime('today','TimeZone','America/New_York','Format','yyyy-MM-dd''T''HH:mmZZZ') % use your TimeZone What time is it "right now" (local) when running this
StartDate = EndDate - days(1)
% Count the number of sequence number that were sent yesterday. Logging every 1 minutes produces 1440 entries per day.
[Seq, time] = thingSpeakRead(readChannelID,'Fields',SeqID,'DateRange',[StartDate,EndDate], 'ReadKey', readAPIKey); % Count the number of entries for the day
SeqCount = length(Seq); % getting the length returns the number of records read from the channel.
[RT, time] = thingSpeakRead(readChannelID,'Fields',Runtime,'DateRange',[StartDate,EndDate], 'ReadKey', readAPIKey);
sumRT = sum(RT);
sumRT
Total_Gallons = round((sumRT * 1.226) / 128,2) %measured 1.226 oz per second
Total_Gallons
%Runtime is in seconds, make it easier to read, convert to minutes
sumRT_minutes = round(sumRT / 60)
dutyCycle = round(sumRT_minutes / 1440,4) * 100 %Calculate duty cycle or precentage of time on
dutyCycle
sumRT_hours = round(sumRT / 3600,2)
sumRT_hours
dataTable = timetable(StartDate, Total_Gallons, dutyCycle, sumRT_hours, sumRT_minutes, SeqCount)
display(dataTable)
response = thingSpeakWrite(writeChannelID, dataTable, 'WriteKey',writeAPIKey);
https://thingspeak.com/channels/112973 is a public channel of what my Little Sump Pump did yesterday. The data in this channel is from the code above. It runs at 2:00 am to summarize what happened yesterday.
Réponses (0)
Communautés
Plus de réponses dans ThingSpeak Community
Voir également
Catégories
En savoir plus sur Configure Accounts and Channels dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!