1.) no deepsleep for the esp8266 with esphome.
2.) no additonal data send by the esp (rssi, temp. maybe)
3.) a CR2302 battery will last for about 20times in his case
dunno how often you close/open your door but 20 times sounds not that good for me…
compared to a 18650 rechargable battery that lasts in my case for more than 2 months…
I find this very interesting. I could have a use case for a PIR that would trigger a light. Would it be possible to hookup a charger to the battery so it will recharge while light in on and runs on battery when light is off (considering light would be on for 4 minutes maybe 4 to 5 time a day)? That could make the sensor running for months.
I have made a change deep sleep config on my setup. The run_duration timer only starts after MQTT is connected, so if there is a network issue you will use a lot of battery power. My sensor is in a not easily accessed location so I want to minimise the times I need to recharge it, So I added this:
esphome:
name: bedford
platform: ESP32
board: esp32dev
on_boot:
# If MQTT cant connect in 30s will deep sleep
priority: 500
then:
- delay: 30s
- if:
condition:
binary_sensor.is_off: bedford_status
then:
- deep_sleep.enter: deep_sleep_1
jfyi, in the UK you have everything to power your device in the ceiling rose
I know it was long time ago but in case you’re still interested, I saw here a topic where a guy did exactly the same. Basically he attached two conductive pads (foil squares) to the fridge and one long strip of foil to the inside of the fridge door so when it closes it would connect the square pads. then connect one square to the ground and the other one to GPIO and configure it as for a switch.
Well, in Canada, in my house, for that specific lamp I do have only 2 wires and no neutral. So if the switch is open, there is no power going through the wires to the ceiling lamp.
I just finished a build for a mailbox sensor, I could not find an ESP32 that supported external antenna and had good low currrent draw in deep sleep.
I ended up getting an ESP32Thing which also has the advantage of a built in LIPO charger, then mounting the electronics in a waterproof(ish) box in the junk mail section of the mailbox, with the reed switch plugged in using cable and an audio jack (to make it easy to remove the electronics without disturbing the sensor, for recharging).
The back of the junk mail portion is open and I get a reasonable wifi connection from the nearest AP in the house, about 60 - 70 feet away. The disadvantage is if someone looked hard enoungh they could find it and steal it.
Been going a month now on initial charge.
That said, every other reed switch device in the house is 433Mhz, connected via multiple Sonoff bridges. I could have gone down that route and it would have been a lot cheaper.
Great Project!
I was wondering…how long does it take for the device to wake from sleep when the door opens? I mean, is the whole process fast enough so that you get the notifications within seconds? I mean the device has to wake, then connect to the wifi then post the notifications so I’m afraid the delay would be too important.
esphome:
name: bedford
platform: ESP32
board: esp32dev
on_boot:
# If MQTT cant connect in 30s will deep sleep
priority: 500
then:
- delay: 30s
- if:
condition:
binary_sensor.is_off: bedford_status
then:
- deep_sleep.enter: deep_sleep_1
wifi:
ssid: 'OpenWrt'
password: **********
fast_connect: true
mqtt:
broker: hass
port: 1883
username: scott
password: **********
discovery: false
birth_message:
will_message:
on_message:
# Prevent deep sleep for OTA
- topic: bedford/ota_mode
payload: 'ON'
then:
- deep_sleep.prevent: deep_sleep_1
# Home Assistant Automation Puts to sleep after measurements
- topic: bedford/sleep_mode
payload: 'ON'
then:
- deep_sleep.enter: deep_sleep_1
logger:
level: NONE
ota:
password: *******
i2c:
sda: 16
scl: 17
binary_sensor:
- platform: status
name: "bedford_status"
id: bedford_status
sensor:
- platform: uptime
name: uptime
update_interval: 6s
- platform: bme280
temperature:
name: "bford temp"
id: bford_temp
oversampling: 2x
# pressure:
# name: "bford pres"
# id: bford_pres
# oversampling: 2x
humidity:
name: "bford humi"
id: bford_humi
oversampling: 2x
address: 0x76
update_interval: 6s
deep_sleep:
id: deep_sleep_1
# If MQTT is connected but Home Assistant is down this will be reached
run_duration: 10s
sleep_duration: 60min
The automation that runs when sensors readings that get received by HA. Its a while since I did this, I think the second mqtt.publish cancels any retained message:
For a door with reed switch you need to have esp32 wake up when reed is triggered and send state to HA. Much of what I did was because my esp was on another network and accessed over internet so I wanted to cover instances where connection failed and esp stayed awake wasting battery. To do an OTA flash I just send a manual bedford/ota_mode message and esp does not sleep. Empty birth and will config stops the sensors from being not available when its sleeping, not sure if that is needed with a reed switch.