Device not waking up from sleep if binary sensor (E18-D80NK) is high

I have a script that reads a binary sensor, which works fine.
But if I send the device into deep sleep it only wakes up if the binary sensor is “low”. If the sensor is triggered (high) while the device is in sleep, it will not wake up.
If it is not triggered, it wakes up and continues as intendend, wifi and mqtt connect, all is fine.

The sensor is a E18-D80NK connected to 5v on the board, GND and GPIO2.
RST and WAKE (GPIO16) is connected by a wire.

Any clues? would switching to a ESP32-s help?

 esphome:
  name: postfoler
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: -200
    then:
      - wait_until:
          mqtt.connected:
      - delay: 3s
      - lambda: |-
          id(postfoler).state;

# Wifi Information
 wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: LIGHT
  fast_connect: true
  manual_ip:
    static_ip: XX
    gateway: XX
    subnet: XX
    dns1: XX

 mqtt:
  broker: XX
  port: 1883
  username: !secret mqtt_user
  password: !secret mqtt_password
  birth_message:
  will_message:

 logger:
  level: DEBUG

 ota:
  password: !secret esp_password

 binary_sensor:
  - platform: gpio
    pin: 
      number: 2
    id: "postfoler"
    name: "postfoler"

 deep_sleep:
  id: deep_sleep1
  sleep_duration: 3000ms
  run_duration: 10000ms

That’s weird. It should be the other way round. Scroll down to the table on this page and see the notes for GPIO2. “…boot fails if pulled LOW”.

Thanks for the quick reply. I should mention that I have tried other GPIOs as well. 0 and 1 I believe… Same issue.

I started trying to use an output to turn the sensor on, just for the reading, then off again. But I did not have enough hours in the day :frowning:

I can try again tonight.

Hang on. What do you mean by this?

Only GPIO16 must be connected to the RST pin for the device to wake from sleep.

Ah, sorry. My mistake. Wa missing a “full stop”. Corrected now. Wake is GPIO16 and that is the one connected to RST.
#multitasking

1 Like

Wow you’re good at picking the wrong GPIOs. :rofl: Both those are bad choices as well. See the table in the link I posted.

1 Like

Several strokes of bad luck. Cheers. I’ll re-try tonight and report back.

You’re very limited for GPIO choices with the ESP8266-01 board. For only a couple of bucks more the Wemos D1 mini or one of the NodeMCU boards have more i/o.

This is on the D1 Mini (pro)… The one with external antenna. Maybe I need to update the header of the code as well… I thought this was auto-populated on first setup in esphome.

I don’t think this is correct then:

Use:

  platform: ESP8266
  board: d1_mini
1 Like

Changed board and pin to d1_mini and GPIO4. All works perfectly… Could have saved quite a few hours there… Putting that on my learnings-account. Thanks!

1 Like