Deepsleep-Mode

I am happy that my first ESP32 project will work, but now I want add in my code a deepsleep mode. Goal: send automatic the temperature every hour and then fall into a deep sleep :wink:

because I am a newbie, so it’s not so easy to follow the tutorial…so I would ask for some support what code I have to add for the deep sleep mode

esphome:
  name: officetemp
  platform: ESP32
  board: esp32dev

wifi:
  ssid: "mySSID"
  password: "myPass"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Officetemp Fallback Hotspot"
    password: "myPass"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "myPass"

ota:
  password: "myPass"

sensor:
  - platform: dht
    pin: GPIO5
    temperature:
      name: "Living Room Temperature"
    humidity:
      name: "Living Room Humidity"
    update_interval: 30s
    model: DHT22

While I am a newbie like you, I have found this snippet to work. However, deep sleep also causes you to no longer be able to update your FW over wifi, unless you have fairly long wake modes. I ended up removing it because of this. Would be much more useful I think when powering devices from batteries.

deep_sleep:
  run_duration: 6s
  sleep_duration: 1min

This will sleep for one minute, wake up, send data then back to sleep for one minute.

1 Like

To use deep sleep you need to use MQTT and you need to remove API. Then you need to create the MQTT sensors in HA manually.

Check this post for information.