UtilitechAS / amsreader-firmware

ESP8266 and ESP32 compatible firmware to read, interpret and publish data to MQTT from smart electrical meters, both DLMS and DSMR is supported
Other
381 stars 73 forks source link

Feature request: Add power-saving mode #315

Closed mikkel75 closed 2 years ago

mikkel75 commented 2 years ago

Some HW implementations (like e.g. this one for the Kamstrup Omnipower: https://github.com/mikkel75/KamstrupHAN) has a very limited power source.

Would it be possible to add a power-saving mode to this great SW, like

  1. deep-sleep for a configurable number of seconds
  2. wait for a frame
  3. process frame
  4. update MQTT
  5. back to 1.

I guess it could also be configurable if wifi (static IP) should be enabled when awake. Or maybe enabled over MQTT message to AmsBridge?

If there are other (easier) ways to save power - please let me know...

Thanks!

ArnieO commented 2 years ago

Power saving is indeed an interesting and important topic!

The firmware uses Auto modem sleep in between payloads to save current, which works fine on ESP32 - and in most situations on ESP8266. There is a known snag with ESP8266: It is not able to go to modem sleep if there is a device on the same Wifi access point that used Multicast or Broadcast, this would typically be Chromecast or AppleTV devices. ESP32 is immune to such "noise" on the network.

I don't see any power source issues with the HW solution shown in https://github.com/mikkel75/KamstrupHAN. The power pin inside the Kamstrup meter is specified to deliver 4.15 ± 0.25V, maximum current 75 mA. I assume there is a linear regulator in the design that drops the voltage to 3.3V. So there is almost 250 mW available at 3.3V, which is plenty to run this application.

If you are experiencing issues with that board, I think it could be related to the supercapacitor. What you need is a supercap with sufficiently low ESR (equivalent serial resistance) so that it can efficiently serve as power supply support while the ESP pulls heavy current pulses during RF activity. I cannot say for sure without the datasheet for the supercap used there, but in general, those "button cell" type supercaps have fairly large ESR and are not really suitable for this application. hey are meant for lower-current situations.

In conclusion: I have now a quite extensive experience with using both ESP8266 and ESP32-S2 on my Pow-K board. There is enough current/power available to run this firmware reliably and without issues on both ESP8266 and ESP32-S2 from that "internal" connector of a Kamstrup Omnipower. There is also enough power available to run the ESP8266 in situations where it does not drop to Auto modem sleep between payloads.

So I am not in favor of adding the feature you propose.

gskjold commented 2 years ago

The firmware ensures that ESP enters modem sleep which is very power efficient. Dropping into deep sleep for further power saving is more efficient, yes, but it is also very tricky business. Real world application for such power saving mode is very limited and not something I will prioritize at this point.

Since you are using ESP8266, make sure your device is on a low traffic (no multicast) wifi network to ensure proper modem sleep.