I am trying to record my gas usage in Watts from my pulse-based gas feed. I used a mod to the firmware in the Arduino from an example sketch on github that tracks the time of each detected pulse in the ISR, and uses that to derive the watts value from the duration since the previous pulse, and writes it into emonPi.power2, as this isn't otherwise in use, and it gets sent to emoncms in the usual manner, and the Input is logged to a feed using phpFina engine.
Once sent, the Arduino clears emonPi.power2 to zero, until the next pulse is detected.
The point is that the calculation has to wait until the current pulse is detected, but in the meantime, 0-Watts are being constantly written to the feed except at the time of a pulse detection. That gets me a non-zero watts value that gets written to the feed, and then we are back to a stream of zeros again. It makes no sense to me to keep streaming the last Watts value after the last pulse, because that value was only relevant to the time prior to the pulse. In fact it is relevant to all the previous datapoints in the feed going back to the previous pulse, and not to any future datapoints beyond the current pulse.
So I want to take that watts value and write it into all the relevant prior datapoints, going back all the way to the previous pulse, or only as far back as, say, 15 minutes ago, which ever period is shorter.
But I don't know how to do it.
I think I want to have a modified log to feed process that takes the zero watts and writes them into current time slots as normal, but if it gets a non-zero reading it writes that as normal, then calculates how far back the reading was relevant for, and writes it retrospectively into all the earlier slots within that period.
It sounds perfectly doable, but I am struggling to work out how to achieve it. Can anyone help? I'd rather have advice than have someone do it for me, my main limitation is I am unaccustomed to php and the interactions with the feeds at low level, especially checking what the feed's sampling interval is.
Need help with pulsed-based gas feed.
Submitted by MikeSims on Wed, 27/04/2016 - 13:46I am trying to record my gas usage in Watts from my pulse-based gas feed. I used a mod to the firmware in the Arduino from an example sketch on github that tracks the time of each detected pulse in the ISR, and uses that to derive the watts value from the duration since the previous pulse, and writes it into emonPi.power2, as this isn't otherwise in use, and it gets sent to emoncms in the usual manner, and the Input is logged to a feed using phpFina engine.
Once sent, the Arduino clears emonPi.power2 to zero, until the next pulse is detected.
The point is that the calculation has to wait until the current pulse is detected, but in the meantime, 0-Watts are being constantly written to the feed except at the time of a pulse detection. That gets me a non-zero watts value that gets written to the feed, and then we are back to a stream of zeros again. It makes no sense to me to keep streaming the last Watts value after the last pulse, because that value was only relevant to the time prior to the pulse. In fact it is relevant to all the previous datapoints in the feed going back to the previous pulse, and not to any future datapoints beyond the current pulse.
So I want to take that watts value and write it into all the relevant prior datapoints, going back all the way to the previous pulse, or only as far back as, say, 15 minutes ago, which ever period is shorter.
But I don't know how to do it.
I think I want to have a modified log to feed process that takes the zero watts and writes them into current time slots as normal, but if it gets a non-zero reading it writes that as normal, then calculates how far back the reading was relevant for, and writes it retrospectively into all the earlier slots within that period.
It sounds perfectly doable, but I am struggling to work out how to achieve it. Can anyone help? I'd rather have advice than have someone do it for me, my main limitation is I am unaccustomed to php and the interactions with the feeds at low level, especially checking what the feed's sampling interval is.