Motion sensor / Battery drain

Hello,

I started a small project, I want to make a motion sensor that is battery powered and connected to the HA.
I have used so far:

On ESP8266 I currently have this:

esphome:
  name: motion_1
  platform: ESP8266
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "x"

wifi:
  ssid: "MikroTik-2"
  password: "z&f!uS9t*$7HKN"
  manual_ip:
    static_ip: 192.x.x.x
    gateway: 192.x.x.x
    subnet: 255.255.255.0
    dns1: 192.x.x.x
    dns2: 192.x.x.x

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Motion_1"
    password: "x"

captive_portal:

binary_sensor:
  - platform: gpio
    pin: GPIO12
    name: "Motion 1"
    device_class: motion
    
sensor:
  - platform: adc
    pin: VCC
    id: "VCC"
    internal: true
    
  - platform: template
    name: "esp.2.battery_level"
    unit_of_measurement: '%'
    update_interval: 5s
    lambda: |-
      return ((id(VCC).state /3.70) * 100.00);

Now my problem is the high power consumption, the battery lasts only a few hours.
I found Deep Sleep Component — ESPHome but for me is not clear how I can wake up the ESP8266 from deep sleep on the moment when an event is detected using the motion detector.

Any help will be appreciated.

Thank you!

Check the wakeup pin in deepsleep

You can’t on esp8266. That is clear from the deep sleep page.

If you want to wake up on a pin, use an esp32.

esp32 only.

1 Like

I did some research… although esphome help page says that it’s impossible i wonder if it’s really so… since ESP8266 DOES have GPIO16 as wake-up defined… i’ll have to do some testing about this. But i’d appreciate any additional info, if anyone have some experience about this.

4.3 of this suggests it is so. But esp32 are cheap.

1 Like

Sure, they are cheap, but 8266 are even cheaper, smaller… esp32 is kinda overkill just for, say, one button for doorbell…
I did some reading and testing. It works quite well - low state on rst pin wakes up device and sends state to HA.
BUT… of course there are “but’s”:

  • it’s a good idea to define one pin as high output and connect it to rst in order to prevent multiple resets. Say, if you press “wakeup” button three times in a row esp will reset 3 times and thus maybe not be able connect to HA (if you have, say, PIR connected to rst and it sends multiple signals out). There are samples on internet how to do it, there are diodes and resistors involved, in some cases even transistor.
  • you don’t have to connect gpio16 to rst if you don’t use timer wakeup. Gpio16 is nothing else but output from RTC timer and it resets esp if it’s connected. If not, then only wakeup option is button. But, i guess that occasional connection to HA is a good idea, just to know that sensor is ok, available and to send battery state.
  • delay is in the range of 3 to 5 seconds when using fast connect, which is logical since esp must connect to wifi. I guess that delay somewhat depends on router also.
1 Like