Using a binary sensor to sleep and wake an ESP32 rather than time

The title says it all really.

From my reading of the docs it seems that I can only make it sleep based on time.

Is that correct?

I need it to wake up when a binary sensor state changes and then sleep when a binary sensor changes. This can be the same or a different binary sensor.

Any ideas if this is possible?

Are they GPIO binary sensors? Or something else?

Yes, GPIO.

I’ve been plyaing around with it this morning and this seems to work without any time constraints.

deep_sleep:
  wakeup_pin: GPIO4 
  wakeup_pin_mode: INVERT_WAKEUP
  id: enter_deep_sleep

binary_sensor:
  - name: "my_binary"
    platform: gpio
    id: my_binary
    pin: GPIO6
    filters:
      invert:
    on_release:
      - deep_sleep.enter:
          id: enter_deep_sleep

The problem I have now is that the RFID board and/or uart doesn’t seem to work without a power cycle after the ESP32 comes out of sleep.

uart:
  tx_pin: GPIO16
  rx_pin: GPIO17
  baud_rate: 9600

rdm6300:

Are you using a cheap esp clone by chance?

How are you powering it? Try the best supply and cables you have. Are you connections soldered? How long are your wires?

You could try adding a on_boot delay (and wire begin if using I2C).

You could also try this.

Thank you.

Cheap clone of which, the ESP32 S3 or the RDM6300?

Well, I just tried this:


rdm6300:
  setup_priority: -100

It compiled! I will test it later.

Thank you.

1 Like

Only the first is an esp.

If you’re using an S3 your issue could also lie there.

Do you have a spare board you can test on?

I have plenty of boards to test with. The S3 is not a clone.

What is it about the S3 that may be the problem?

I was using an ESP32 D1 mini but ran short of resources so swapped to the S3. However, I’ve since dropped some BT scanning so could go back the the D1.

I’m not sure if S3’s are fully supported yet.

When I have this kind of issue, trying another board is a generic trouble shooting step relatively early on my list.

If you have a decent quality esp32 I would try with that. Just my 2 cents.

Why are you always so quick to blame the “cheap clones”?

Expressif provides Schematic, PCB Layout, Gerber files and a BOM for all of the development boards. Anyone may use these files to manufacture development boards. Wemos, Mainko, Teylen, SparkFun, Adafruit all manufacture boards using the Expressif design files. Expressif does sell DevKits from these designs but the price is high and includes more than just a board, like engineering support. The DevKit is used by device manufacturers to design the ESP chips into their products. So since Expressif does not sell development boards directly to the consumer or hobbyist, does this mean that all development boards are “cheap clones”?

Because of some bad experiences.

I use cheap clones for basic projects, but if I experience any issues I upgrade to something better quality pretty quickly. It’s resolved things numerous times.

Clones typically use cheaper parts.

Most of those manufacturers are reputable and probably followed the design guidelines for component selection (I say most as I am unfamiliar with Mainko and Teylen). These are not considered “clones” and I would have no issue with recommending any of their products.

In the race to make the cheapest available ESP dev boards the same can not be said for other no name Chinese imitation manufacturers that substitute inferior components to reduce cost. These are the poor quality clones being referenced.

2 Likes