ESP32 deep sleep function not working after many setups

Hi guys,
before I asked you, I have struggled with the documentation, ChatGPT and Gemini to setup a deep sleep for my project. Nothing wa successful, so here I am.

I have the ESP32 WROOM DevKit V1 board.
Powering it with external power supply via micro USB.

Have the RGB LED connected through 3 resistors on all colours to pins 25, 26, 27.
Powering LED by pin 3.3V and GND from the ESP board (on breadboard).

Oled 0,96 inch monochromatic display connected to SCL pin 22 and SDA pin 21.
Powering by pin 3.3V and GND from the ESP board (on breadboard).

DHT11 temperature and humidity sensor connected to pin 18.
Powering by pin 3.3V and GND from the ESP board (on breadboard).

PIR sensor connected to pin 13.
Powering by pin 3.3V and GND from the ESP board (on breadboard).

Microswitch button 1 connected to pin 12 and GND.
Microswitch button 2 connected to pin 19 and GND.

Display is showing me the actual status of energy price (high or low) + temperature of the water in boiler.

RGB led also provides the info if the tariff is high (red) or low (green).

Everything works fine except my deep sleep try.

What I am trying to do is, that:

  • if the ESP board boots up, it stays on for 10 seconds, then go to deep sleep.
  • if the movement is registered on the PIR sensor, the ESP wakes up for 30 seconds.
  • if no movement is detected, after these 30 seconds it goes back to sleep.

I was trying, insted of using the PIR sensor, to use one of the buttons to wake up the device.
But the board does not go to sleep at all.
Here is the code with button I was trying with, but the priority is the PIR sensor to wake up the device.

esphome:
  name: esp32
  friendly_name: ESP32

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
  level: DEBUG

api:
  
ota:
  - platform: esphome
    password: XXXX

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.129
    gateway: 192.168.1.1
    subnet: 255.255.255.0
  ap:
    ssid: "Esp32 Fallback Hotspot"
    password: "YbW321Y0ClyM"

captive_portal:

bluetooth_proxy:
  active: true

deep_sleep:
  id: deep_sleep_mode
  run_duration: 10s  # Doba, po kterou bude ESP32 aktivní před vstupem do spánku
  sleep_duration: 99999999s  # Nulový čas spánku, dokud není tlačítko stisknuto (nenastaví se na čas!)
  esp32_ext1_wakeup:
    pins:
      - 12
    mode: ANY_HIGH

light:
  - platform: rgb
    name: RGB Light
    id: rgb_light
    red: red
    green: green
    blue: blue
    restore_mode: ALWAYS_OFF

    on_turn_on:
      then:
        - lambda: |-
            float brightness = 0.5;
            if (id(peak_tariff_value).state == 1) {
              id(red).set_level(brightness); 
              id(green).set_level(0.0);  
              id(blue).set_level(0.0);  
            } else {
              id(red).set_level(0.0);  
              id(green).set_level(brightness);  
              id(blue).set_level(0.0);  
            }

    on_turn_off:
      then:
        - lambda: |-
            id(red).set_level(0.0);  
            id(green).set_level(0.0);  
            id(blue).set_level(0.0);  

interval:
  - interval: 10s
    then:
      - lambda: |-
          float brightness = 0.5;  
          if (id(peak_tariff_value).state == 1) {
            id(red).set_level(brightness);  
            id(green).set_level(0.0);  
            id(blue).set_level(0.0);  
          } else {
            id(red).set_level(0.0);  
            id(green).set_level(brightness);  
            id(blue).set_level(0.0);  
          }

output:
  - platform: ledc
    id: red
    pin: GPIO25
  - platform: ledc
    id: green
    pin: GPIO26
  - platform: ledc
    id: blue
    pin: GPIO27

sensor:
  - platform: homeassistant
    id: peak_tariff_value
    entity_id: sensor.peak_tariff_value
    name: "Peak Tariff Value"
    internal: true
    on_value:
      then:
        - lambda: |-
            ESP_LOGD("custom", "Current Peak Tariff Value: %f", id(peak_tariff_value).state);

  - platform: dht
    pin: GPIO18
    model: DHT11
    temperature:
      name: "Teplota"
      id: teplota
    humidity:
      name: "Vlhkost"
      id: vlhkost
    update_interval: 60s

  - platform: homeassistant
    id: teplota_home_assistant
    entity_id: sensor.senzor_teploty_bojler_temperature
    name: "Bojler"
    unit_of_measurement: "°C"

binary_sensor:
  - platform: gpio
    pin:
      number: 19
      mode: INPUT_PULLUP
      inverted: false
    name: "Tlačitko světlo malý pokoj"
    device_class: power
    on_press:
      then:
        - switch.toggle: tlacitko_stav
        - homeassistant.event:
            event: esphome.button_pressed
            data:
              message: "Světlo malý pokoj bylo stisknuto"

  - platform: gpio
    pin:
      number: 13
      mode: INPUT_PULLUP
      inverted: True
    name: "Tlačítko pro probuzení"
    on_press:
      then:
        - lambda: |-
            id(rgb_light).turn_off();  // Vypnutí světla
            id(displej).turn_off();    // Vypnutí displeje
        - deep_sleep.enter: deep_sleep_mode

switch:
  - platform: gpio
    id: tlacitko_stav
    pin: 33
    restore_mode: ALWAYS_OFF
    name: "Stav Tlačítka 01"

  - platform: gpio
    id: tlacitko_stav_02
    pin: 32
    restore_mode: ALWAYS_OFF
    name: "Stav Tlačítka 02"

i2c:
  id: bus_i2c
  sda: 21
  scl: 22
  scan: True
  frequency: 400kHz

font:
  - file: "/config/esphome/arial.ttf"
    id: my_font
    size: 17
  - file: "/config/esphome/arial.ttf"
    id: my_font_small
    size: 16

display:
  - platform: ssd1306_i2c
    model: SSD1306 128x64
    address: 0x3C
    id: displej
    lambda: |-
      std::string text;
      if (id(peak_tariff_value).state == 1) {
        text = "VYSOKY TARIF";
      } else {
        text = "NIZKY TARIF";
      }

      int text_width = text.length() * 12;
      int x = (160 - text_width) / 2;
      int y = 10;
      it.print(x, y, id(my_font), text.c_str());
      
      char temperature_text[20];
      snprintf(temperature_text, sizeof(temperature_text), "Bojler: %.1f °C", id(teplota_home_assistant).state);
      int temp_text_width = strlen(temperature_text) * 6;
      int temp_x = (120 - temp_text_width) / 2;
      int temp_y = 45;
      it.print(temp_x, temp_y, id(my_font_small), temperature_text);

Any ideas, what am I doing wrong?

Hi
Your code tells it to sleep after 10 seconds. Which bit is meant to keep it awake for 30seconds?

1 Like

Yes, I suppose the code is wrong. After wakeup it should run for 30 secs. Then go to sleep again (if no movement detected by PIR).

Also I do not have the code for PIR sensor in the posted code as I replaced it by my try with the push button to wake up the board.

Also there is some weird problem with the WiFi connection, not connected to my WiFi even it worked before.

Anyway, logs here:

[I][logger:171]: Log initialized
[18:58:37][C][safe_mode:079]: There have been 1 suspected unsuccessful boot attempts
[18:58:37][D][esp32.preferences:114]: Saving 1 preferences to flash...
[18:58:37][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[18:58:37][I][app:029]: Running through setup()...
[18:58:37][I][i2c.arduino:218]: Performing I2C bus recovery
[18:58:37][C][switch.gpio:011]: Setting up GPIO Switch 'Stav Tlačítka 01'...
[18:58:37][D][switch:016]: 'Stav Tlačítka 01' Turning OFF.
[18:58:37][D][switch:055]: 'Stav Tlačítka 01': Sending state OFF
[18:58:37][D][switch:016]: 'Stav Tlačítka 01' Turning OFF.
[18:58:37][C][switch.gpio:011]: Setting up GPIO Switch 'Stav Tlačítka 02'...
[18:58:37][D][switch:016]: 'Stav Tlačítka 02' Turning OFF.
[18:58:37][D][switch:055]: 'Stav Tlačítka 02': Sending state OFF
[18:58:37][D][switch:016]: 'Stav Tlačítka 02' Turning OFF.
[18:58:37][D][binary_sensor:034]: 'Tlačitko světlo malý pokoj': Sending initial state ON
[18:58:37][D][binary_sensor:034]: 'Tlačítko pro probuzení': Sending initial state OFF
[18:58:37][C][light:021]: Setting up light 'RGB Light'...
[18:58:37][D][light:036]: 'RGB Light' Setting:
[18:58:37][D][light:041]:   Color mode: RGB
[18:58:37][D][light:085]:   Transition length: 1.0s
[18:58:37][C][dht:011]: Setting up DHT...
[18:58:37][C][ssd1306_i2c:010]: Setting up I2C SSD1306...
[18:58:37][C][esp32_ble:035]: Setting up BLE...
[18:58:37][C][wifi:048]: Setting up WiFi...
[18:58:37][C][wifi:061]: Starting WiFi...
[18:58:37][C][wifi:062]:   Local MAC: 3C:8A:1F:D3:B7:5C
[18:58:37][D][wifi:482]: Starting scan...
[18:58:37][D][dht:049]: Got Temperature=17.5°C Humidity=40.0%
[18:58:37][D][sensor:094]: 'Teplota': Sending state 17.50000 °C with 1 decimals of accuracy
[18:58:37][D][sensor:094]: 'Vlhkost': Sending state 40.00000 % with 0 decimals of accuracy
[18:58:37][W][component:157]: Component wifi set Warning flag: scanning for networks
[18:58:37][D][esp32_ble:295]: Enabling BLE...
[18:58:38][D][esp32_ble_tracker:282]: Starting scan...
[18:58:40][D][wifi:497]: Found networks:
[18:58:40][I][wifi:541]: - 'Misa Wlan' [redacted]▂▄▆█
[18:58:40][D][wifi:542]:     Channel: 10
[18:58:40][D][wifi:543]:     RSSI: -57 dB
[18:58:40][D][wifi:546]: - [redacted] [redacted]▂▄▆█
[18:58:40][D][wifi:546]: - [redacted] [redacted]▂▄▆█
[18:58:40][D][wifi:546]: - [redacted] [redacted]▂▄▆█
[18:58:40][D][wifi:546]: - [redacted] [redacted]▂▄▆█
[18:58:40][D][wifi:546]: - [redacted] [redacted]▂▄▆█
[18:58:40][I][wifi:313]: WiFi Connecting to 'Misa Wlan'...
[18:58:41][I][wifi:617]: WiFi Connected!
[18:58:41][C][wifi:428]:   Local MAC: 3C:8A:1F:D3:B7:5C
[18:58:41][C][wifi:433]:   SSID: [redacted]
[18:58:41][C][wifi:436]:   IP Address: 192.168.1.129
[18:58:41][C][wifi:440]:   BSSID: [redacted]
[18:58:41][C][wifi:441]:   Hostname: 'esp32'
[18:58:41][C][wifi:443]:   Signal strength: -58 dB ▂▄▆█
[18:58:41][C][wifi:447]:   Channel: 10
[18:58:41][C][wifi:448]:   Subnet: 255.255.255.0
[18:58:41][C][wifi:449]:   Gateway: 192.168.1.1
[18:58:41][C][wifi:450]:   DNS1: 0.0.0.0
[18:58:41][C][wifi:451]:   DNS2: 0.0.0.0
[18:58:41][D][wifi:626]: Disabling AP...
[18:58:41][C][api:026]: Setting up Home Assistant API server...
[18:58:41][C][deep_sleep:013]: Setting up Deep Sleep...
[18:58:41][I][deep_sleep:018]: Scheduling Deep Sleep to start in 10000 ms
[18:58:41][I][app:062]: setup() finished successfully!
[18:58:41][W][component:170]: Component wifi cleared Warning flag
[18:58:41][W][component:157]: Component api set Warning flag: unspecified
[18:58:41][I][app:100]: ESPHome version 2025.2.2 compiled on Mar 15 2025, 17:39:47
[18:58:41][C][wifi:600]: WiFi:
[18:58:41][C][wifi:428]:   Local MAC: 3C:8A:1F:D3:B7:5C
[18:58:41][C][wifi:433]:   SSID: [redacted]
[18:58:41][C][wifi:436]:   IP Address: 192.168.1.129
[18:58:41][C][wifi:440]:   BSSID: [redacted]
[18:58:41][C][wifi:441]:   Hostname: 'esp32'
[18:58:41][C][wifi:443]:   Signal strength: -58 dB ▂▄▆█
[18:58:41][C][wifi:447]:   Channel: 10
[18:58:41][C][wifi:448]:   Subnet: 255.255.255.0
[18:58:41][C][wifi:449]:   Gateway: 192.168.1.1
[18:58:41][C][wifi:450]:   DNS1: 0.0.0.0
[18:58:41][C][wifi:451]:   DNS2: 0.0.0.0
[18:58:41][C][logger:177]: Logger:
[18:58:41][C][logger:178]:   Max Level: DEBUG
[18:58:41][C][logger:179]:   Initial Level: DEBUG
[18:58:41][C][logger:181]:   Log Baud Rate: 115200
[18:58:41][C][logger:182]:   Hardware UART: UART0
[18:58:41][C][i2c.arduino:071]: I2C Bus:
[18:58:41][C][i2c.arduino:072]:   SDA Pin: GPIO21
[18:58:41][C][i2c.arduino:073]:   SCL Pin: GPIO22
[18:58:41][C][i2c.arduino:074]:   Frequency: 400000 Hz
[18:58:41][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[18:58:41][I][i2c.arduino:096]: Results from i2c bus scan:
[18:58:41][I][i2c.arduino:102]: Found i2c device at address 0x3C
[18:58:41][C][ledc.output:180]: LEDC Output:
[18:58:41][C][ledc.output:181]:   Pin GPIO25
[18:58:41][C][ledc.output:182]:   LEDC Channel: 0
[18:58:41][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[18:58:41][C][ledc.output:184]:   Phase angle: 0.0°
[18:58:41][C][ledc.output:185]:   Bit depth: 16
[18:58:41][C][ledc.output:180]: LEDC Output:
[18:58:41][C][ledc.output:181]:   Pin GPIO26
[18:58:41][C][ledc.output:182]:   LEDC Channel: 1
[18:58:41][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[18:58:41][C][ledc.output:184]:   Phase angle: 0.0°
[18:58:41][C][ledc.output:185]:   Bit depth: 16
[18:58:41][C][ledc.output:180]: LEDC Output:
[18:58:41][C][ledc.output:181]:   Pin GPIO27
[18:58:41][C][ledc.output:182]:   LEDC Channel: 2
[18:58:41][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[18:58:41][C][ledc.output:184]:   Phase angle: 0.0°
[18:58:41][C][ledc.output:185]:   Bit depth: 16
[18:58:41][C][switch.gpio:068]: GPIO Switch 'Stav Tlačítka 01'
[18:58:41][C][switch.gpio:091]:   Restore Mode: always OFF
[18:58:41][C][switch.gpio:031]:   Pin: GPIO33
[18:58:41][C][switch.gpio:068]: GPIO Switch 'Stav Tlačítka 02'
[18:58:41][C][switch.gpio:091]:   Restore Mode: always OFF
[18:58:41][C][switch.gpio:031]:   Pin: GPIO32
[18:58:41][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Tlačitko světlo malý pokoj'
[18:58:41][C][gpio.binary_sensor:015]:   Device Class: 'power'
[18:58:41][C][gpio.binary_sensor:016]:   Pin: GPIO19
[18:58:41][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Tlačítko pro probuzení'
[18:58:41][C][gpio.binary_sensor:016]:   Pin: GPIO13
[18:58:41][C][light:092]: Light 'RGB Light'
[18:58:41][C][light:094]:   Default Transition Length: 1.0s
[18:58:41][C][light:095]:   Gamma Correct: 2.80
[18:58:41][C][bluetooth_proxy:091]: Bluetooth Proxy:
[18:58:41][C][bluetooth_proxy:092]:   Active: YES
[18:58:41][C][bluetooth_proxy:093]:   Connections: 3
[18:58:41][C][bluetooth_proxy:094]:   Raw advertisements: NO
[18:58:41][C][dht:017]: DHT:
[18:58:41][C][dht:018]:   Pin: GPIO18
[18:58:41][C][dht:022]:   Model: DHT11
[18:58:41][C][dht:026]:   Internal Pull-up: ON
[18:58:41][C][dht:028]:   Update Interval: 60.0s
[18:58:41][C][dht:030]:   Temperature 'Teplota'
[18:58:41][C][dht:030]:     Device Class: 'temperature'
[18:58:41][C][dht:030]:     State Class: 'measurement'
[18:58:41][C][dht:030]:     Unit of Measurement: '°C'
[18:58:41][C][dht:030]:     Accuracy Decimals: 1
[18:58:41][C][dht:031]:   Humidity 'Vlhkost'
[18:58:41][C][dht:031]:     Device Class: 'humidity'
[18:58:41][C][dht:031]:     State Class: 'measurement'
[18:58:41][C][dht:031]:     Unit of Measurement: '%'
[18:58:41][C][dht:031]:     Accuracy Decimals: 0
[18:58:41][C][ssd1306_i2c:023]: I2C SSD1306
[18:58:41][C][ssd1306_i2c:023]:   Rotations: 0 °
[18:58:41][C][ssd1306_i2c:023]:   Dimensions: 128px x 64px
[18:58:41][C][ssd1306_i2c:024]:   Address: 0x3C
[18:58:41][C][ssd1306_i2c:025]:   Model: SSD1306 128x64
[18:58:41][C][ssd1306_i2c:027]:   External VCC: NO
[18:58:41][C][ssd1306_i2c:028]:   Flip X: YES
[18:58:41][C][ssd1306_i2c:029]:   Flip Y: YES
[18:58:41][C][ssd1306_i2c:030]:   Offset X: 0
[18:58:41][C][ssd1306_i2c:031]:   Offset Y: 0
[18:58:41][C][ssd1306_i2c:032]:   Inverted Color: NO
[18:58:41][C][ssd1306_i2c:033]:   Update Interval: 1.0s
[18:58:41][C][esp32_ble:418]: ESP32 BLE:
[18:58:41][C][esp32_ble:420]:   MAC address: 3C:8A:1F:D3:B7:5E
[18:58:41][C][esp32_ble:421]:   IO Capability: none
[18:58:41][C][esp32_ble_tracker:677]: BLE Tracker:
[18:58:41][C][esp32_ble_tracker:678]:   Scan Duration: 300 s
[18:58:41][C][esp32_ble_tracker:679]:   Scan Interval: 320.0 ms
[18:58:41][C][esp32_ble_tracker:680]:   Scan Window: 30.0 ms
[18:58:41][C][esp32_ble_tracker:681]:   Scan Type: ACTIVE
[18:58:42][C][esp32_ble_tracker:682]:   Continuous Scanning: YES
[18:58:42][C][esp32_ble_tracker:683]:   Scanner Idle: NO
[18:58:42][C][esp32_ble_tracker:684]:   Scan End: NO
[18:58:42][C][esp32_ble_tracker:686]:   Connecting: 0, discovered: 0, searching: 0, disconnecting: 0
[18:58:42][D][api:103]: Accepted 192.168.1.117
[18:58:42][W][component:170]: Component api cleared Warning flag
[18:58:42][W][component:237]: Component api took a long time for an operation (59 ms).
[18:58:42][W][component:238]: Components should block for at most 30 ms.
[18:58:42][C][bluetooth_proxy.connection:017]: BLE Connection:
[18:58:42][C][esp32_ble_client:048]:   Address: 
[18:58:42][C][esp32_ble_client:049]:   Auto-Connect: FALSE
[18:58:42][C][esp32_ble_client:083]:   State: IDLE
[18:58:42][C][bluetooth_proxy.connection:017]: BLE Connection:
[18:58:42][C][esp32_ble_client:048]:   Address: 
[18:58:42][C][esp32_ble_client:049]:   Auto-Connect: FALSE
[18:58:42][C][esp32_ble_client:083]:   State: IDLE
[18:58:42][C][bluetooth_proxy.connection:017]: BLE Connection:
[18:58:42][C][esp32_ble_client:048]:   Address: 
[18:58:42][C][esp32_ble_client:049]:   Auto-Connect: FALSE
[18:58:42][C][esp32_ble_client:083]:   State: IDLE
[18:58:42][D][api.connection:1446]: Home Assistant 2025.3.2 (192.168.1.117): Connected successfully
[18:58:42][C][captive_portal:089]: Captive Portal:
[18:58:42][C][mdns:116]: mDNS:
[18:58:42][C][mdns:117]:   Hostname: esp32
[18:58:42][C][esphome.ota:073]: Over-The-Air updates:
[18:58:42][C][esphome.ota:074]:   Address: 192.168.1.129:3232
[18:58:42][C][esphome.ota:075]:   Version: 2
[18:58:42][C][esphome.ota:078]:   Password configured
[18:58:42][C][safe_mode:018]: Safe Mode:
[18:58:42][C][safe_mode:020]:   Boot considered successful after 60 seconds
[18:58:42][C][safe_mode:021]:   Invoke after 10 boot attempts
[18:58:42][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[18:58:42][C][api:140]: API Server:
[18:58:42][C][api:141]:   Address: 192.168.1.129:6053
[18:58:42][C][api:143]:   Using noise encryption: YES
[18:58:42][C][homeassistant.sensor:030]: Homeassistant Sensor 'Peak Tariff Value'
[18:58:42][C][homeassistant.sensor:030]:   State Class: ''
[18:58:42][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[18:58:42][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[18:58:42][C][homeassistant.sensor:031]:   Entity ID: 'sensor.peak_tariff_value'
[18:58:42][C][homeassistant.sensor:030]: Homeassistant Sensor 'Bojler'
[18:58:42][C][homeassistant.sensor:030]:   State Class: ''
[18:58:42][C][homeassistant.sensor:030]:   Unit of Measurement: '°C'
[18:58:42][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[18:58:42][C][homeassistant.sensor:031]:   Entity ID: 'sensor.senzor_teploty_bojler_temperature'
[18:58:42][C][deep_sleep:026]: Setting up Deep Sleep...
[18:58:42][C][deep_sleep:029]:   Sleep Duration: 1215751192 ms
[18:58:42][C][deep_sleep:032]:   Run Duration: 10000 ms
[18:58:42][D][homeassistant.sensor:024]: 'sensor.peak_tariff_value': Got state 0.00
[18:58:42][D][sensor:094]: 'Peak Tariff Value': Sending state 0.00000  with 1 decimals of accuracy
[18:58:42][D][custom:111]: Current Peak Tariff Value: 0.000000
[18:58:42][D][homeassistant.sensor:024]: 'sensor.senzor_teploty_bojler_temperature': Got state 58.60
[18:58:42][D][sensor:094]: 'Bojler': Sending state 58.60000 °C with 1 decimals of accuracy
[18:58:51][I][deep_sleep:060]: Beginning Deep Sleep
[18:58:51][I][deep_sleep:062]: Sleeping for 1215751192000us
[18:58:51][D][esp32.preferences:114]: Saving 1 preferences to flash...
[18:58:51][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[18:58:51]ets Jun  8 2016 00:22:57
[18:58:51]
[18:58:51]rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[18:58:51]configsip: 0, SPIWP:0xee
[18:58:51]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[18:58:51]mode:DIO, clock div:2
[18:58:51]load:0x3fff0030,len:1184
[18:58:51]load:0x40078000,len:13132
[18:58:51]load:0x40080400,len:3036
[18:58:51]entry 0x400805e4
[18:58:51][I][logger:171]: Log initialized

Doesn’t match very well.
You have low side button but high side wake up.

Also, why tou want to use ext1_wakeup?
Also, read the documentation, in automations you want to use deep_sleep.enter
action, not the run_duration.

And 12 is strapping pin, boot fails if pulled high. Use another pin when you go with your pir.

1 Like

Hi,
thanks for your answer. I just tried so many codes and so many ChatGPT and Gemini made codes, that I am a bit lost right now, because nothing was working.

I do not know why the AI at the end recommended ext1_wakeup. It was trying the deep_sleep.enter many times, but there was something wrong in the code.

Documentation read, but I still can not made it working.

How would you solve this issue from scratch?
Not taking care about my code at all, just your code?

Thank you

Abandoning CGPT code and reading the documentation.

Make just a test setup, one pushbutton wired to 3.3V for wake-up on non strapping pin.

deep_sleep:
  id: deepsleep1
  wakeup_pin: 18

And on code make a switch to enter in sleep

switch:
  - platform: template
    name: "Sleep Switch"
    id: ssw
    turn_on_action:
      - deep_sleep.enter:
          id: deepsleep1
          sleep_duration: 300min

When you have sleep/wake working start adding your automations…

3 Likes

I am trying, I do not like asking AI, but I tried that maybe it could kick me and give me at least some points.

Had to change the pin to 14 as pin 18 does not support wake up.

Only pins 0, 2, 4, 12, 13, 14, 15, 25, 26, 27, 32, 33, 34, 35, 36, 37, 38, 39 support wakeup.
  wakeup_pin: 18

So, after compiling the code the device is still ON.
No sleep at all, no wake up needed by the switch.
RGB light ON, display ON, 2nd switch working.
This should be fine as we are only testing the setup.
But the device does not go to sleep.

INFO ESPHome 2025.2.2
INFO Reading configuration /config/esphome/esphome-web-552c50.yaml...
INFO Starting log output from 192.168.1.129 using esphome API
INFO Successfully connected to esp32 @ 192.168.1.129 in 0.149s
INFO Successful handshake with esp32 @ 192.168.1.129 in 0.083s
[21:39:43][I][app:100]: ESPHome version 2025.2.2 compiled on Mar 15 2025, 21:32:03
[21:39:43][C][wifi:600]: WiFi:
[21:39:43][C][wifi:428]:   Local MAC: 3C:8A:1F:D3:B7:5C
[21:39:43][C][wifi:433]:   SSID: [redacted]
[21:39:43][C][wifi:436]:   IP Address: 192.168.1.129
[21:39:43][C][wifi:440]:   BSSID: [redacted]
[21:39:43][C][wifi:441]:   Hostname: 'esp32'
[21:39:43][C][wifi:443]:   Signal strength: -61 dB ▂▄▆█
[21:39:43][C][wifi:447]:   Channel: 10
[21:39:43][C][wifi:448]:   Subnet: 255.255.255.0
[21:39:43][C][wifi:449]:   Gateway: 192.168.1.1
[21:39:43][C][wifi:450]:   DNS1: 0.0.0.0
[21:39:43][C][wifi:451]:   DNS2: 0.0.0.0
[21:39:43][C][logger:177]: Logger:
[21:39:43][C][logger:178]:   Max Level: DEBUG
[21:39:43][C][logger:179]:   Initial Level: DEBUG
[21:39:43][C][logger:181]:   Log Baud Rate: 115200
[21:39:43][C][logger:182]:   Hardware UART: UART0
[21:39:43][C][i2c.arduino:071]: I2C Bus:
[21:39:43][C][i2c.arduino:072]:   SDA Pin: GPIO21
[21:39:43][C][i2c.arduino:073]:   SCL Pin: GPIO22
[21:39:43][C][i2c.arduino:074]:   Frequency: 400000 Hz
[21:39:43][C][i2c.arduino:092]:   Recovery: failed, SDA is held low on the bus
[21:39:43][I][i2c.arduino:096]: Results from i2c bus scan:
[21:39:43][I][i2c.arduino:102]: Found i2c device at address 0x3C
[21:39:43][C][ledc.output:180]: LEDC Output:
[21:39:43][C][ledc.output:181]:   Pin GPIO25
[21:39:43][C][ledc.output:182]:   LEDC Channel: 0
[21:39:43][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[21:39:43][C][ledc.output:184]:   Phase angle: 0.0°
[21:39:43][C][ledc.output:185]:   Bit depth: 16
[21:39:43][C][ledc.output:180]: LEDC Output:
[21:39:43][C][ledc.output:181]:   Pin GPIO26
[21:39:43][C][ledc.output:182]:   LEDC Channel: 1
[21:39:43][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[21:39:43][C][ledc.output:184]:   Phase angle: 0.0°
[21:39:43][C][ledc.output:185]:   Bit depth: 16
[21:39:43][C][ledc.output:180]: LEDC Output:
[21:39:43][C][ledc.output:181]:   Pin GPIO27
[21:39:43][C][ledc.output:182]:   LEDC Channel: 2
[21:39:43][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[21:39:43][C][ledc.output:184]:   Phase angle: 0.0°
[21:39:43][C][ledc.output:185]:   Bit depth: 16
[21:39:43][C][switch.gpio:068]: GPIO Switch 'Stav Tlačítka 01'
[21:39:43][C][switch.gpio:091]:   Restore Mode: always OFF
[21:39:43][C][switch.gpio:031]:   Pin: GPIO33
[21:39:43][C][switch.gpio:068]: GPIO Switch 'Stav Tlačítka 02'
[21:39:43][C][switch.gpio:091]:   Restore Mode: always OFF
[21:39:43][C][switch.gpio:031]:   Pin: GPIO32
[21:39:43][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Tlačitko světlo malý pokoj'
[21:39:43][C][gpio.binary_sensor:015]:   Device Class: 'power'
[21:39:43][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Tlačítko LED pásek počítač'
[21:39:43][C][gpio.binary_sensor:015]:   Device Class: 'power'
[21:39:43][C][gpio.binary_sensor:016]:   Pin: GPIO13
[21:39:43][C][light:092]: Light 'RGB Light'
[21:39:43][C][light:094]:   Default Transition Length: 1.0s
[21:39:43][C][light:095]:   Gamma Correct: 2.80
[21:39:43][C][template.switch:068]: Template Switch 'Sleep Switch'
[21:39:43][C][template.switch:091]:   Restore Mode: always OFF
[21:39:43][C][template.switch:057]:   Optimistic: NO
[21:39:44][C][dht:017]: DHT:
[21:39:44][C][dht:018]:   Pin: GPIO23
[21:39:44][C][dht:022]:   Model: DHT11
[21:39:44][C][dht:026]:   Internal Pull-up: ON
[21:39:44][C][dht:028]:   Update Interval: 60.0s
[21:39:44][C][dht:030]:   Temperature 'Teplota'
[21:39:44][C][dht:030]:     Device Class: 'temperature'
[21:39:44][C][dht:030]:     State Class: 'measurement'
[21:39:44][C][dht:030]:     Unit of Measurement: '°C'
[21:39:44][C][dht:030]:     Accuracy Decimals: 1
[21:39:44][C][dht:031]:   Humidity 'Vlhkost'
[21:39:44][C][dht:031]:     Device Class: 'humidity'
[21:39:44][C][dht:031]:     State Class: 'measurement'
[21:39:44][C][dht:031]:     Unit of Measurement: '%'
[21:39:44][C][dht:031]:     Accuracy Decimals: 0
[21:39:44][C][ssd1306_i2c:023]: I2C SSD1306
[21:39:44][C][ssd1306_i2c:023]:   Rotations: 0 °
[21:39:44][C][ssd1306_i2c:023]:   Dimensions: 128px x 64px
[21:39:44][C][ssd1306_i2c:024]:   Address: 0x3C
[21:39:44][C][ssd1306_i2c:025]:   Model: SSD1306 128x64
[21:39:44][C][ssd1306_i2c:027]:   External VCC: NO
[21:39:44][C][ssd1306_i2c:028]:   Flip X: YES
[21:39:44][C][ssd1306_i2c:029]:   Flip Y: YES
[21:39:44][C][ssd1306_i2c:030]:   Offset X: 0
[21:39:44][C][ssd1306_i2c:031]:   Offset Y: 0
[21:39:44][C][ssd1306_i2c:032]:   Inverted Color: NO
[21:39:44][C][ssd1306_i2c:033]:   Update Interval: 1.0s
[21:39:44][C][captive_portal:089]: Captive Portal:
[21:39:44][C][mdns:116]: mDNS:
[21:39:44][C][mdns:117]:   Hostname: esp32
[21:39:44][C][esphome.ota:073]: Over-The-Air updates:
[21:39:44][C][esphome.ota:074]:   Address: 192.168.1.129:3232
[21:39:44][C][esphome.ota:075]:   Version: 2
[21:39:44][C][esphome.ota:078]:   Password configured
[21:39:44][C][safe_mode:018]: Safe Mode:
[21:39:44][C][safe_mode:020]:   Boot considered successful after 60 seconds
[21:39:44][C][safe_mode:021]:   Invoke after 10 boot attempts
[21:39:44][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[21:39:44][C][api:140]: API Server:
[21:39:44][C][api:141]:   Address: 192.168.1.129:6053
[21:39:44][C][api:143]:   Using noise encryption: YES
[21:39:44][C][homeassistant.sensor:030]: Homeassistant Sensor 'Peak Tariff Value'
[21:39:44][C][homeassistant.sensor:030]:   State Class: ''
[21:39:44][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[21:39:44][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[21:39:44][C][homeassistant.sensor:031]:   Entity ID: 'sensor.peak_tariff_value'
[21:39:44][C][homeassistant.sensor:030]: Homeassistant Sensor 'Bojler'
[21:39:44][C][homeassistant.sensor:030]:   State Class: ''
[21:39:44][C][homeassistant.sensor:030]:   Unit of Measurement: '°C'
[21:39:44][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[21:39:44][C][homeassistant.sensor:031]:   Entity ID: 'sensor.senzor_teploty_bojler_temperature'
[21:39:44][C][deep_sleep:026]: Setting up Deep Sleep...
[21:39:44][C][deep_sleep:043]:   Wakeup Pin: GPIO14
[21:39:55][D][binary_sensor:036]: 'Tlačitko světlo malý pokoj': Sending state OFF
[21:39:55][D][binary_sensor:036]: 'Tlačitko světlo malý pokoj': Sending state ON
[21:39:55][D][switch:020]: 'Stav Tlačítka 01' Toggling ON.
[21:39:55][D][switch:055]: 'Stav Tlačítka 01': Sending state ON
[21:39:58][D][binary_sensor:036]: 'Tlačitko světlo malý pokoj': Sending state OFF
[21:39:58][D][binary_sensor:036]: 'Tlačitko světlo malý pokoj': Sending state ON
[21:39:58][D][switch:020]: 'Stav Tlačítka 01' Toggling OFF.
[21:39:58][D][switch:055]: 'Stav Tlačítka 01': Sending state OFF
[21:40:26][D][dht:049]: Got Temperature=15.6°C Humidity=43.0%
[21:40:26][D][sensor:094]: 'Teplota': Sending state 15.60000 °C with 1 decimals of accuracy
[21:40:26][D][sensor:094]: 'Vlhkost': Sending state 43.00000 % with 0 decimals of accuracy

Sorry for that. My mistake.

Post your complete yaml.

1 Like

No problem man…yaml below:

esphome:
  name: esp32
  friendly_name: ESP32

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  
ota:
  - platform: esphome
    password: "ac40de9194d0715a77419b262ad2cecd"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.129  # Statická IP adresa
    gateway: 192.168.1.1     # Výchozí brána (router)
    subnet: 255.255.255.0    # Síťová maska

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

captive_portal:

deep_sleep:
  id: deepsleep1
  wakeup_pin: 14

light:
  - platform: rgb
    name: RGB Light
    id: rgb_light
    red: red
    green: green
    blue: blue
    restore_mode: ALWAYS_OFF

    on_turn_on:
      then:
        - lambda: |-
            float brightness = 0.5; 
            if (id(peak_tariff_value).state == 1) {
              id(red).set_level(brightness); 
              id(green).set_level(0.0);  
              id(blue).set_level(0.0);  
            } else {
              id(red).set_level(0.0);  
              id(green).set_level(brightness);  
              id(blue).set_level(0.0);  
            }

    on_turn_off:
      then:
        - lambda: |-
            id(red).set_level(0.0);  
            id(green).set_level(0.0);  
            id(blue).set_level(0.0);  

interval:
  - interval: 10s
    then:
      - lambda: |-
          float brightness = 0.5;  
          if (id(peak_tariff_value).state == 1) {
            id(red).set_level(brightness);  
            id(green).set_level(0.0);  
            id(blue).set_level(0.0);  
          } else {
            id(red).set_level(0.0);  
            id(green).set_level(brightness);  
            id(blue).set_level(0.0);  
          }



output:
  - platform: ledc
    id: red
    pin: GPIO25
  - platform: ledc
    id: green
    pin: GPIO26
  - platform: ledc
    id: blue
    pin: GPIO27

# Sloučení všech senzorů do jednoho bloku
sensor:
  - platform: homeassistant
    id: peak_tariff_value
    entity_id: sensor.peak_tariff_value
    name: "Peak Tariff Value"
    internal: true
    on_value:
      then:
        - lambda: |-
            ESP_LOGD("custom", "Current Peak Tariff Value: %f", id(peak_tariff_value).state);

  - platform: dht
    pin: GPIO18  # Ujisti se, že senzor je připojen na správný pin
    model: DHT11  # Nastavení modelu na DHT11
    temperature:
      name: "Teplota"
      id: teplota
    humidity:
      name: "Vlhkost"
      id: vlhkost
    update_interval: 60s  # Interval pro čtení dat ze senzoru

  - platform: homeassistant
    id: teplota_home_assistant
    entity_id: sensor.senzor_teploty_bojler_temperature
    name: "Bojler"
    unit_of_measurement: "°C"

binary_sensor:
  # Původní tlačítko na pin 19
  - platform: gpio
    pin:
      number: 19
      mode: INPUT_PULLUP
      inverted: false
    name: "Tlačitko světlo malý pokoj"
    device_class: power
    on_press:
      then:
        - switch.toggle: tlacitko_stav  # Přepíná stav tlačítka
        - homeassistant.event:
            event: esphome.button_pressed
            data:
              message: "Světlo malý pokoj bylo stisknuto"

  # Nové tlačítko na pin 13 pro ovládání jiné funkce přes Home Assistant
  - platform: gpio
    pin:
      number: 13  # Pin 13 pro nové tlačítko
      mode: INPUT_PULLUP
      inverted: false
    name: "Tlačítko LED pásek počítač"
    device_class: power
    on_press:
      then:
        - switch.toggle: tlacitko_stav_02  # Přepíná stav tlačítka

# Výstup pro přepínání tlačítka (nové ID pro stav tlačítka)
switch:
  - platform: gpio
    id: tlacitko_stav
    pin: 33  # Pin pro indikaci stavu
    restore_mode: ALWAYS_OFF  # Nezůstane zapnuté po restartu
    name: "Stav Tlačítka 01"

  # Pokud potřebuješ přepínač pro ovládání jiného zařízení, přidej nový přepínač
  - platform: gpio
    id: tlacitko_stav_02  # Nové ID pro přepínač pro nové tlačítko
    pin: 32  # Můžeš změnit na jiný pin podle potřeby
    restore_mode: ALWAYS_OFF
    name: "Stav Tlačítka 02"

  - platform: template
    name: "Sleep Switch"
    id: ssw
    turn_on_action:
      - deep_sleep.enter:
          id: deepsleep1
          sleep_duration: 300min

i2c:
  id: bus_i2c
  sda: 21
  scl: 22
  scan: True
  frequency: 400kHz

font:
  - file: "/config/esphome/arial.ttf"  # nebo použij jiný font
    id: my_font
    size: 17
  - file: "/config/esphome/arial.ttf"  # nebo jiný menší font
    id: my_font_small
    size: 16  # Zmenšený font pro teplotu

display:
  - platform: ssd1306_i2c
    model: SSD1306 128x64
    address: 0x3C
    lambda: |-
      std::string text;
      if (id(peak_tariff_value).state == 1) {
        text = "VYSOKY TARIF";
      } else {
        text = "NIZKY TARIF";
      }

      // Pevně stanovené šířky písma (můžete upravit podle potřeby)
      int text_width = text.length() * 12;  // Odhad šířky písma (12 px na písmeno)
      
      // Dynamické zarovnání textu na střed
      int x = (160 - text_width) / 2;  // Výpočet pozice pro střed
      int y = 10;  // Vertikální pozice pro hlavní text
      it.print(x, y, id(my_font), text.c_str());  // Tisk textu na displej
      
      // Zobrazení teploty z Home Assistant s menším písmem
      char temperature_text[20];  // Pole pro teplotu (formátovaný text)
      snprintf(temperature_text, sizeof(temperature_text), "Bojler: %.1f °C", id(teplota_home_assistant).state);  // Formátovaná teplota
      int temp_text_width = strlen(temperature_text) * 6;  // Odhad šířky písma pro menší písmo
      int temp_x = (120 - temp_text_width) / 2;  // Zarovnání teploty na střed
      int temp_y = 45;  // Vertikální pozice pro teplotu (blízko dolního okraje)
      it.print(temp_x, temp_y, id(my_font_small), temperature_text);  // Tisk teploty na displej
    

So you press the Sleep Switch on HA (not the wakeup button) and it doesn’t do anything?

1 Like

You mean that I should see the Sleep Switch in ESPHome entity in HA?
Or what does this have to do with HA?
Should the board itself turn off / on by switch via the firmware code?

Switch is virtual (just code). Push button is physical.
If you don’t use HA and you don’t setup esphome Web Server, what are you trying to accomplish? Blind setup without any interface?

Nothing wrong with that, but quite unusual on this forum.

1 Like

I use ESPHome in my Home Assistant setup.
Seeing all connected devices to ESP board - RGB light, buttons 1 and 2, temperature and humidity DHT11 sensor, PIR sensor (not used right now, but tried and working fine).

I need the board to go to deep sleep after 10secs after boot - when connected to power supply.
Then I need to wake up the board when PIR detects the movement.
So the RGB light will turn on and switch color according to the peak_tariff entity from HA (red-high or ON or 1, green-low or OFF or 0).
Also the display will turn on and display the peak_tariff entity (NIZKY TARIF-low/OFF/0, VYSOKY TARIF-high/ON/1).
After no movement detected by PIR sensor, the ESP board goes to sleep after 30 secs.

From my perspective this sleep / wake up actions can not be done by automations from HA because when the EPS goes to sleep, it does not react to the HA, only phycisal pin where the wake up selected device is connected - in this case it should be the PIR sensor / or in our case for testing the switch button.

Am I right or do I miss something? Really not sure, thanks very much in advance for explaining.

That’s correct.
And the setup I suggested was just to test that your automation based sleep switch and hardware button wake-up is working. Because that’s what it will be in “final setup”. And if you don’t use web server, HA is the only UI you have.
When you have that verified, you can go forward.
Do you follow me?
Do you see “sleep switch” on HA or not?

1 Like

Sure, I got you and your remarks.
We are only testing, then we can go forward with other thigs.
Using just ESPHome, no MQTT.
Can not see the sleep switch in HA.
As it is platform:template - where should it show in HA?
In the ESPHome integration?

I’m not very familiar with HA setups.
Try to add this to the template switch code
optimistic: true

 - platform: template
    name: "Sleep Switch"
    id: ssw
    optimistic: true
    turn_on_action:
      - deep_sleep.enter:
          id: deepsleep1
          sleep_duration: 300min
1 Like

Now I can see the sleep switch entinty in HA.
But pushing the button makes nothing.
Is it right connected? One output to PIN 14, 2nd output to GND?
When I switch the button “digitally” in HA, it actually does something.
Logs below

INFO ESPHome 2025.2.2
INFO Reading configuration /config/esphome/esphome-web-552c50.yaml...
INFO Starting log output from 192.168.1.129 using esphome API
INFO Successfully connected to esp32 @ 192.168.1.129 in 0.071s
INFO Successful handshake with esp32 @ 192.168.1.129 in 0.103s
[11:34:24][I][app:100]: ESPHome version 2025.2.2 compiled on Mar 16 2025, 11:23:43
[11:34:24][C][wifi:600]: WiFi:
[11:34:24][C][wifi:428]:   Local MAC: 3C:8A:1F:D3:B7:5C
[11:34:24][C][wifi:433]:   SSID: [redacted]
[11:34:24][C][wifi:436]:   IP Address: 192.168.1.129
[11:34:24][C][wifi:440]:   BSSID: [redacted]
[11:34:24][C][wifi:441]:   Hostname: 'esp32'
[11:34:24][C][wifi:443]:   Signal strength: -59 dB ▂▄▆█
[11:34:24][C][wifi:447]:   Channel: 10
[11:34:24][C][wifi:448]:   Subnet: 255.255.255.0
[11:34:24][C][wifi:449]:   Gateway: 192.168.1.1
[11:34:24][C][wifi:450]:   DNS1: 0.0.0.0
[11:34:24][C][wifi:451]:   DNS2: 0.0.0.0
[11:34:24][C][logger:177]: Logger:
[11:34:24][C][logger:178]:   Max Level: DEBUG
[11:34:24][C][logger:179]:   Initial Level: DEBUG
[11:34:24][C][logger:181]:   Log Baud Rate: 115200
[11:34:24][C][logger:182]:   Hardware UART: UART0
[11:34:24][C][i2c.arduino:071]: I2C Bus:
[11:34:24][C][i2c.arduino:072]:   SDA Pin: GPIO21
[11:34:24][C][i2c.arduino:073]:   SCL Pin: GPIO22
[11:34:24][C][i2c.arduino:074]:   Frequency: 400000 Hz
[11:34:24][C][i2c.arduino:086]:   Recovery: bus successfully recovered
[11:34:24][I][i2c.arduino:096]: Results from i2c bus scan:
[11:34:24][I][i2c.arduino:102]: Found i2c device at address 0x3C
[11:34:24][C][ledc.output:180]: LEDC Output:
[11:34:24][C][ledc.output:181]:   Pin GPIO25
[11:34:24][C][ledc.output:182]:   LEDC Channel: 0
[11:34:24][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[11:34:24][C][ledc.output:184]:   Phase angle: 0.0°
[11:34:24][C][ledc.output:185]:   Bit depth: 16
[11:34:24][C][ledc.output:180]: LEDC Output:
[11:34:24][C][ledc.output:181]:   Pin GPIO26
[11:34:24][C][ledc.output:182]:   LEDC Channel: 1
[11:34:24][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[11:34:24][C][ledc.output:184]:   Phase angle: 0.0°
[11:34:24][C][ledc.output:185]:   Bit depth: 16
[11:34:24][C][ledc.output:180]: LEDC Output:
[11:34:24][C][ledc.output:181]:   Pin GPIO27
[11:34:24][C][ledc.output:182]:   LEDC Channel: 2
[11:34:24][C][ledc.output:183]:   PWM Frequency: 1000.0 Hz
[11:34:24][C][ledc.output:184]:   Phase angle: 0.0°
[11:34:24][C][ledc.output:185]:   Bit depth: 16
[11:34:24][C][switch.gpio:068]: GPIO Switch 'Stav Tlačítka 01'
[11:34:24][C][switch.gpio:091]:   Restore Mode: always OFF
[11:34:24][C][switch.gpio:031]:   Pin: GPIO33
[11:34:24][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Tlačitko světlo malý pokoj'
[11:34:24][C][gpio.binary_sensor:015]:   Device Class: 'power'
[11:34:24][C][gpio.binary_sensor:016]:   Pin: GPIO19
[11:34:24][C][light:092]: Light 'RGB Light'
[11:34:24][C][light:094]:   Default Transition Length: 1.0s
[11:34:24][C][light:095]:   Gamma Correct: 2.80
[11:34:24][C][template.switch:068]: Template Switch 'Sleep Switch'
[11:34:24][C][template.switch:091]:   Restore Mode: always OFF
[11:34:24][C][template.switch:057]:   Optimistic: YES
[11:34:24][C][dht:017]: DHT:
[11:34:24][C][dht:018]:   Pin: GPIO18
[11:34:24][C][dht:022]:   Model: DHT11
[11:34:24][C][dht:026]:   Internal Pull-up: ON
[11:34:24][C][dht:028]:   Update Interval: 60.0s
[11:34:24][C][dht:030]:   Temperature 'Teplota'
[11:34:24][C][dht:030]:     Device Class: 'temperature'
[11:34:24][C][dht:030]:     State Class: 'measurement'
[11:34:24][C][dht:030]:     Unit of Measurement: '°C'
[11:34:24][C][dht:030]:     Accuracy Decimals: 1
[11:34:24][C][dht:031]:   Humidity 'Vlhkost'
[11:34:24][C][dht:031]:     Device Class: 'humidity'
[11:34:24][C][dht:031]:     State Class: 'measurement'
[11:34:24][C][dht:031]:     Unit of Measurement: '%'
[11:34:24][C][dht:031]:     Accuracy Decimals: 0
[11:34:24][C][ssd1306_i2c:023]: I2C SSD1306
[11:34:24][C][ssd1306_i2c:023]:   Rotations: 0 °
[11:34:24][C][ssd1306_i2c:023]:   Dimensions: 128px x 64px
[11:34:24][C][ssd1306_i2c:024]:   Address: 0x3C
[11:34:24][C][ssd1306_i2c:025]:   Model: SSD1306 128x64
[11:34:24][C][ssd1306_i2c:027]:   External VCC: NO
[11:34:24][C][ssd1306_i2c:028]:   Flip X: YES
[11:34:24][C][ssd1306_i2c:029]:   Flip Y: YES
[11:34:24][C][ssd1306_i2c:030]:   Offset X: 0
[11:34:24][C][ssd1306_i2c:031]:   Offset Y: 0
[11:34:24][C][ssd1306_i2c:032]:   Inverted Color: NO
[11:34:24][C][ssd1306_i2c:033]:   Update Interval: 1.0s
[11:34:24][C][captive_portal:089]: Captive Portal:
[11:34:24][C][mdns:116]: mDNS:
[11:34:24][C][mdns:117]:   Hostname: esp32
[11:34:24][C][esphome.ota:073]: Over-The-Air updates:
[11:34:24][C][esphome.ota:074]:   Address: 192.168.1.129:3232
[11:34:24][C][esphome.ota:075]:   Version: 2
[11:34:24][C][esphome.ota:078]:   Password configured
[11:34:24][C][safe_mode:018]: Safe Mode:
[11:34:24][C][safe_mode:020]:   Boot considered successful after 60 seconds
[11:34:24][C][safe_mode:021]:   Invoke after 10 boot attempts
[11:34:24][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[11:34:24][C][api:140]: API Server:
[11:34:24][C][api:141]:   Address: 192.168.1.129:6053
[11:34:24][C][api:143]:   Using noise encryption: YES
[11:34:24][C][homeassistant.sensor:030]: Homeassistant Sensor 'Peak Tariff Value'
[11:34:24][C][homeassistant.sensor:030]:   State Class: ''
[11:34:24][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[11:34:24][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[11:34:24][C][homeassistant.sensor:031]:   Entity ID: 'sensor.peak_tariff_value'
[11:34:24][C][homeassistant.sensor:030]: Homeassistant Sensor 'Bojler'
[11:34:24][C][homeassistant.sensor:030]:   State Class: ''
[11:34:24][C][homeassistant.sensor:030]:   Unit of Measurement: '°C'
[11:34:24][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[11:34:24][C][homeassistant.sensor:031]:   Entity ID: 'sensor.senzor_teploty_bojler_temperature'
[11:34:24][C][deep_sleep:026]: Setting up Deep Sleep...
[11:34:24][C][deep_sleep:043]:   Wakeup Pin: GPIO14
[11:34:42][D][dht:049]: Got Temperature=19.0°C Humidity=39.0%
[11:34:42][D][sensor:094]: 'Teplota': Sending state 19.00000 °C with 1 decimals of accuracy
[11:34:42][D][sensor:094]: 'Vlhkost': Sending state 39.00000 % with 0 decimals of accuracy
[11:35:02][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[11:35:02][D][esp32.preferences:114]: Saving 1 preferences to flash...
[11:35:02][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[11:35:42][D][dht:049]: Got Temperature=19.0°C Humidity=38.0%
[11:35:42][D][sensor:094]: 'Teplota': Sending state 19.00000 °C with 1 decimals of accuracy
[11:35:42][D][sensor:094]: 'Vlhkost': Sending state 38.00000 % with 0 decimals of accuracy
[11:36:12][D][switch:012]: 'Sleep Switch' Turning ON.
[11:36:12][I][deep_sleep:060]: Beginning Deep Sleep
[11:36:12][I][deep_sleep:062]: Sleeping for 18000000000us
[11:36:12][D][esp32.preferences:114]: Saving 1 preferences to flash...
[11:36:12][D][esp32.preferences:143]: Saving 1 preferences to flash: 1 cached, 0 written, 0 failed
INFO Processing expected disconnect from ESPHome API for esp32 @ 192.168.1.129
WARNING Disconnected from API
WARNING Can't connect to ESPHome API for esp32 @ 192.168.1.129: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.1.129', port=6053))]: [Errno 111] Connect call failed ('192.168.1.129', 6053) (SocketAPIError)
INFO Trying to connect to esp32 @ 192.168.1.129 in the background
INFO Successfully connected to esp32 @ 192.168.1.129 in 0.008s
INFO Successful handshake with esp32 @ 192.168.1.129 in 0.095s
[11:36:31][D][homeassistant.sensor:024]: 'sensor.peak_tariff_value': Got state 1.00
[11:36:31][D][sensor:094]: 'Peak Tariff Value': Sending state 1.00000  with 1 decimals of accuracy
[11:36:31][D][custom:109]: Current Peak Tariff Value: 1.000000
[11:36:31][D][homeassistant.sensor:024]: 'sensor.senzor_teploty_bojler_temperature': Got state 55.30
[11:36:31][D][sensor:094]: 'Bojler': Sending state 55.30000 °C with 1 decimals of accuracy

it’s configured to be high trigger

1 Like

I´m lost…

one pushbutton wired to 3.3V for wake-up on non strapping pin

One wire from the pushbutton goes to PIN14.
2nd wire to GND.
Correct?

No.
to gpio14 and 3.3V

1 Like