I’ve setup one esp8266 with his code but, connected to a 20000mAh battery, barely keeps alive 5 days… I’ve been reading bout deep sleep elements but I don’t really where to begin with Peter’s code to introduce deep sleep nor it will work for this específic piece of work.
I don’t have a technical answer to your question, but given the WiFi power draw I don’t think a decent battery life will be achievable; there are plenty on posts on the subject.
I would think the way forward would be a BLE or ZigBee solution. The ESP32 already supports BLE, I guess it would just need WiFi disabling. There are plans to release a ZigBee ESP too. Although range and interference may be an issue.
Obviously then there’s some coding involved to send the data.
I did try already with one spare aqara door sensor and didn’t get it to work without any further wiring (I think my water meter magnetic field is not strong enough). I already order some reed from aliexpress to try “the external version”.
I also order a ESP32 to try the deep sleep + BLE concept from Aliexpress… 10 days… I’ll keep you posted!
I checked the location of my meter, and it’s on the sidewalk down a 60cm hole. I could maybe envisage getting a battery operated radio thing there, but I can’t see how I would ever be able to install a sensor all that way down.
The only feasible option I can see now, for my user case, is to have a second meter installed in the home, negating the need to have a battery powered sensor.
I had a second meter installed in my home just for this. I originally tied it in to a door sensor so it was still battery powered. The meter I got had around 70 pulses per gallon and I was watering the lawn. Basically the battery only lasted 3 days when trying to transmit every pulse. I ended up having to run a wire to the meter and hook it to an ESP32 that was plugged in.
Hi, I finally received my ESP32 unit and I’m making progress with deep sleep state. I’ve been trying combinations of configuration and so far I always have the same problem: when unit is going deep sleep, all “counter” and “meter” states go 0 again. Any clue?
So basically once you use GPIO34 for wake up, it won’t be available for the pulse_counter anymore.
AFAIK the code you’re using doesn’t work in the recent ESPhome (> 2022.5.0) precisely for the same issue.
I think globals do. So you might need to build a DIY counter using globals.
You might be about to reuse parts of this which does a delta sensor across deep sleep cycles.
globals:
- id: previous_value
type: float
restore_value: yes
initial_value: '0.0'
sensor:
#Track end of day battery (manually updates at the end of the day before sleeping for the night)
- platform: template
name: End of Day Battery ${friendly_name}
id: end_of_day_battery_percent
update_interval: never
icon: "mdi:solar-power"
unit_of_measurement: '%'
on_value:
then:
- lambda: id(change_in_end_of_day_battery_percent).publish_state(x - id(previous_value));
- lambda: |-
id(previous_value) = x;
#Track daily changes in battery
- platform: template
# source_id: end_of_day_battery_percent
id: change_in_end_of_day_battery_percent
icon: mdi:trending-up
internal: false
name: Change in End of Day Battery ${friendly_name}
unit_of_measurement: '%'
accuracy_decimals: 1
Or maybe just send the pulse to HA to do the counting?
I do have a water meter set-up as well, using an ESP32.
In my case it is powered by wire, so I don’t need the Deep Sleep function.
However, to have a preserved water meter counter value, I am using a global variable and some on_boot and on_shutdown actions. Here it is stated about on_shutdown that:
on_shutdown
This automation will be triggered when the ESP is about to shut down. Shutting down is usually caused by too many WiFi/MQTT connection attempts, Over-The-Air updates being applied or through the Deep Sleep Component.
So it looks like this could help as well with Deep Sleep enabled?
It is not mentioned that on_boot is also triggered by coming out of Deep Sleep, but it is worth a try.
To ensure that the value is preserved during a power failure I also have an interval option to write the value to flash every 30 seconds (globals.set).
To my understanding this does not wear-out the flash because writing to flash only really happens when the value is really changed.