• 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 =)

    var hourPulses=0
    var dayPulses=0
    For every pulse
       if hour > previous hour then hourPulses =0
       if day > previous day then dayPulses =0
       increment dayPulses
       increment hourPulses
       send NRF data
       loop
    

    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.

About

Avatar for user130485 @user130485 started