Puck.js as power meter logger - how do you keep track of pulses per hour and day? #1560
Replies: 3 comments
-
Posted at 2021-07-12 by Robin Mon 2021.07.12 Hi @user130485
While the collection and conversion of pulses code/concept is not shown, and knowing that the Javascript Date() function constructor is based on the number of milliseconds since 1 January 1970 UTC, it would make sense just to return the current time in msec and remain using msec, then extract the hours and minutes individually as needed, rather than a more obtuse method of trying to detect rollover.
Interactive live playground:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-07-13 by user130485 I have another reading that shows current watts based on time between the pulses. Does the time sync happen during the code upload? Guess it would break then when doing battery replacement |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-07-13 by user130485 ok, got it sorted |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-07-12 by user130485
Hi
I have started with this example as a base to modify for my needs:
https://www.espruino.com/Smart+Meter
I am measuring time between pulses to calculate current power use. But I also want to keep track of pulses per hour and per day. I am lost at math that is used in the example to modify. I dont need an array to store, as data will be picked up but another device and stored elsewhere.
Can someone point me in the right direction/assist with javascript to detect a day/hour rollover, so that counters can be reset?
Some pseudo-code =)
Something like that. I just dont know how it will work when moving into a next day.
The example in the link above somehow magically sets it into an array. But I just want one value to be sent for the current hour and day.
Beta Was this translation helpful? Give feedback.
All reactions