Project: PIR Sensor with DFR Firebeetle and LiIon-Battery

Hello everyone,

Although I´m sure still an ESPhome amateur, I flashed dozens of (mostly nodeMCU) ESP32 and ESP8266 devices via ESPhome command line tool. Now I tried to set up my first battery powered device: a simple HC-SR501 PIR-motion-sensor connected to a DFR Firebeetle using deepsleep and a 10000 mAh Li-Ion-Battery-Pack:

This is the actually working yet simple yaml-code:

substitutions:
  device_name: "th_og_bewegungsmelder"
  friendly_name: "Treppenhaus OG Bewegungsmelder"
  mqtt_prefix: "th_og_bewegungsmelder"

esphome:
  name: "${device_name}"
  friendly_name: "${friendly_name}"
  platformio_options:
    upload_speed: 921600

  on_boot:
    priority: 190
    then:
      - mqtt.publish:
          topic: th_og_bewegungsmelder/binary_sensor/pir_sensor/state
          payload: "ON"
  on_shutdown:
    priority: 590
    then:
      - mqtt.publish:
          topic: th_og_bewegungsmelder/binary_sensor/pir_sensor/state
          payload: "OFF"

esp32:
  board: firebeetle32
  framework:
    type: arduino

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 0.0.0.0
    gateway: 0.0.0.0
    subnet: 0.0.0.0
  reboot_timeout: 0s
  ap:
    ap_timeout: 24h
    ssid: “${friendly_name}"
    password: !secret ap_password
  fast_connect: true

logger:
  level: NONE

mqtt:
  broker: 0.0.0.0
  port: 1883
  username: !secret mqtt_username
  password: !secret mqtt_password
  will_message:
    topic: th_og_bewegungsmelder/status
    payload: online

ota:

deep_sleep:
  run_duration:
    default: 30s
    gpio_wakeup_reason: 30s
  sleep_duration: 24h
  wakeup_pin:
    number: GPIO15
    mode: INPUT_PULLUP
  id: deep_sleep_1
  wakeup_pin_mode: KEEP_AWAKE

binary_sensor:
  - platform: gpio
    name: PIR Sensor
    id: pir_detection
    pin:
      number: GPIO15
    filters:
      - delayed_off: 5s

Now, although it works and battery keeps it going now for over a month due to esp32´s deep-sleep functions there remain some questions:

  1. It takes about 3-4s for the lights to turn on. Any idea how to get ESP32s or this boards boot process faster? Tune the yaml? Change the wiring or parts? Climbing the stairs to first floor takes about 6s: it makes no sense for the lights to turn on after more than half of the stairs have been climbed in the dark…

  2. Firebeetle has the capability to charge the JST-connected li-ion-battery when the micro-USB is connected to an AC-plug which makes is fairly convenient to recharge without changing the battery itself. Now in my setup there is the PIR-sensor also connected to Firebeetles JST-battery-connector: will that be a problem during the charging? I did not try to charge it this way yet…

  3. Last but not least: as Firebeetle comes with such built-in battery and charge-connectors: does anyone know if there is a kind of “fuel-gauge” (like this MAX17043) somehow integrated into this board? Acuatlly I could not find any information about it in the docs…

Any help is very appreciated!

Kay

Hello again!

If I have expressed myself wrongly or unclearly, disregarded rules or otherwise done something wrong, I’m sorry and I would be happy if you let me know briefly, so I can do better…

Kay

1 Like

I am working on a similar problem. For one, you are not using the deep sleep mechanism ESPHome has as defined here - Deep Sleep Component — ESPHome
These boards do a good job charging but I lost multiple days till I figured out all hobby batteries wire the connectors the opposite way of these boards. Not sure on a fuel gauge of what that would do.

I suspect you won’t be able to get latencies better than the 3-4 secs you are getting.

I could be wrong but I don’t think deep sleep is a good fit for a project that needs low lag.

This may give you some pointers for measuring battery level.

I think your post was fine, you probably were just unlucky and didn’t attract responses somehow.