I have built an ESP8266 based optical sensor which is working fine and sending MQTT strings to EmonPi. This will be for my gas meter. EmonPi is adding the new device and strings at it should but I’m unable to get it to count upwards. My ESP is setup on interrupt and sends a 1 every time it is triggered. How do I setup Emonpi to add them together please?
I could do this in the ESP and send the new value each time but that would seem a significant weakness in the lifetime of the system should it be rebooted and revert back to zero. Using the EEProm to store it would seem overkill too for what I would expect is handled within the Emonpi.
The string I’m sending (I have tried many formats) -
That in fact is how the emonTx handles it. But the “reset to zero” is recognised and handled correctly by the “Wh accumulator” (also the kWh accumulator) in the emonCMS Input process which you’re bypassing by sending via MQTT, I believe. In fact you’re not bypassing that when you use MQTT, it’s only emonHub that you bypass.
The very latest emonTx software does store its energy values in EEPROM - not every reading every 10 s, but only when there’s a significant change in one of the values. We calculated that on the trade-off between lost energy and EEPROM life, it ended up at a projected life of 60 years.
Thank you for the prompt response and clear answer. That does make sense after all, I will give that a go. Its always nice when a seemingly straight forward question unearths hidden techniques for ensuring the products robustness.