Field Chart :problem with "sum" function

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 Commenti

Could you provide a minimal working example that recreates the problem?
The problem is not explained well but an example may be sufficient to understand the problem.
Otto Meier's answer moved here as a comment.
Adam,
many thanks for your fast response.
To make the issue more clear ,I will send 2 screen shoots of the chart one before midnight and one after midnight to hopefully show the problem in detail.
Best regards
Otto
Screenshots might be helpful but if the images are of code, it's much more useful to copy-paste the code directly.
Also, please use the comment section for comments and reserve the answer section for answers. You could attach the additional information to your original question, as well.
How frequently are you writing to your channel? There is a limit of 8000 data points in a single read that might casue the problem you are seeing.
I am afraid there is a slight misunderstanding. I am not using Matlab code but the functionalty of the ThingSpeak "Field charts" with following parameters:
type: column
dynamic: false
days: 10 ( indication of the daily sums over 10 days)
Sum: daily ( summing up 1440 values per day : 1/minute over 24 h)
The problem: The sum function works fine during the day , at 00:00a.m. the totalizer properly restarts by 0 for the next day and a new column is indicated . But the column and the sum of the day before is suddenly less than the original value at 11:59:59 p.m. (about 40 - 60% less).
My question: Do I use the wrong parameters or is the Field chart functionality at all suitable for this task? Or to use a Matlab Analysis program?
You can only read 8000 values at once from any ThingSpeak Read API. When you try to sum over 10 days for 1440 values per day, you are exceeding the maximum read number. This is why you observe less than the appropriate sum.
We generally suggest using an additional derived channel that is a summation channel to overcome this issue. Each day, or on a regular interval, the target channel is read and summed or averaged and written to the derived channel. You can use timeControl and MATLAB analysis to acheive this operation.
Alternatively, you could use a MATLAB analysis to do multiple reads of the target channel and sum them in a single script. If you do this route, be sure to add a small delay between reads so as not to upset the server.
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
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.

Accedi per commentare.

Risposte (0)

Community

Più risposte nel  ThingSpeak Community

Categorie

Prodotti

Richiesto:

il 17 Feb 2020

Commentato:

il 19 Feb 2020

Community Treasure Hunt

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

Start Hunting!

Translated by