ESP32C3-with-door-sensor-and-deepsleep

Hi everyone, hope everyone’s doing well.

I am a beginner in hassio. Pardon me for silly mistakes.

My setup:
I am integrating seeed-studio xiao esp32c3 with door sensor in esphome.
The esp32c3 should wake up whenever there is change in state, else go to sleep.
That is, if door opens, wakeup, report to hassio, sleep. Same goes for door close.

Current Project status:
I have written the configuration file for esphome yaml file. The integration of door sensor with esp32c3 is working fine(without deep sleep).

I seek help in:

I am trying to integrate deep sleep in the above system. The pin to wakeup is same as door pin.
When defining that in deep sleep mode, I am getting an error saying that pin used multiple times.

Below is my yaml file.

esphome:
  name: door-sensor
  friendly_name: Door_Sensor

esp32:
  board: seeed_xiao_esp32c3
  variant: esp32c3
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "EncryptionKey"

ota:
  password: "OtaKey"

wifi:
  ssid: Potato
  password: Password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Door-Sensor Fallback Hotspot"
    password: "dnKbTZUUHNwj"

captive_portal:

# Define your door sensor pin and setup
binary_sensor:
  - platform: gpio
    name: "Main Door"
    pin:
      number: GPIO2
      mode: INPUT_PULLUP
    device_class: door

deep_sleep:
  run_duration: 30s
  wakeup_pin: GPIO2
  wakeup_pin_mode: IGNORE

Any suggestions or input will be really helpful.
Thanks.

You need to add allow_other_uses: true to your binary sensor.

This was just recently added:

1 Like

Thanks for the input Daryl, I will try this let you know the status.

Hi, I tried adding the parameter to the yaml file, and I could successfully flash it.

But now, my door sensor is showing unavailable on dashboard (even if I am changing the state of door sensor). Where am I going wrong here?

My yaml file:

esphome:
  name: door-sensor
  friendly_name: Door_Sensor

esp32:
  board: seeed_xiao_esp32c3
  variant: esp32c3
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "api key"

ota:
  password: "ota password"

wifi:
  ssid: Potato
  password: Password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Door-Sensor Fallback Hotspot"
    password: "dnKbTZUUHNwj"

captive_portal:

# Define your door sensor pin and setup
binary_sensor:
  - platform: gpio
    name: "Main Door"
    pin:
      number: GPIO2
      mode: INPUT_PULLUP
      allow_other_uses: true
    device_class: door

# Configure deep sleep
deep_sleep:
  id: deep_sleep_1
  run_duration: 5s  # Adjust as needed
  wakeup_pin: 
    number: GPIO2  # Replace with the actual GPIO pin where your door sensor is connected
    allow_other_uses: true
  wakeup_pin_mode: IGNORE
    

Here is the dashboard screenshot attached:

image

Ah - can’t help you there. I have the same issue with one of my deep sleep sensors - still trying to solve it.

Appreciate your insights Daryl, maybe I will create a new topic and see if someone has done it already.

I wonder if we can use a on_boot to prevent deep sleep for maybe 30 seconds to allow the first read