Field Chart :problem with "sum" function

조회 수: 1 (최근 30일)
Otto Meier
Otto Meier 2020년 2월 17일
댓글: David Stacer 2020년 2월 19일
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
Otto Meier
Otto Meier 2020년 2월 19일
Christopher,
many thanks for your explainations. Now I understand the problem: there is not 1 value stored for each day but also all "scanned "1440 values for each day!
As you recommeded I will try a Matlab program in combination with TimeControl.
I will give a feedback within the next days.
Best regards
Otto
David Stacer
David Stacer 2020년 2월 19일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by