I am trying to build what I thought was a relatively simple system (think deadbolt detector), that will fire an event when a simple switch changes state.

Currently, I am testing with an ESP-01 and an ESP32, using deep sleep but the power consumption still seems quite high, because I have to wake the device up every 10 seconds to query the status of the "switch".

I would like to only wake from sleep when the state changes, I can "easily" do this on "close", but I would like to do this on "open" as well like in this question. I need a switch that not only detects open/close, but also sends a pulse to wake up an ESP8266 whenever the (debounced) state changes

I have read up on XOR/XNOR gates, but I am still not sure, how I would implement it.


2 Answers 2


Perhaps you could use a Schmitt trigger EXOR as specified here. enter image description here

Source: Convert a toggle switch into a momentary response

It will create a momentary high pulse whenever a regular toggle switch (deadbolt) is switch on->off or off->on. You could then wire that ouput to an external wakeup pin for said microcontroller.

As you are specifying multiple microcontrollers I suggest that you look up the external wakeup procedures for the board you are using. Many examples are available such as this one for the ESP32.

Best of luck!


This is a working prototype that I made. You can see more details about parts, modify and order your own if you want.

This is the schematic:

Here is a link to my project on jlcpcb: https://easyeda.com/jakibsgaard/low-powered-rising-and-falling-power-on-circuit

I have also a open question where I want to improve the circuit I have made. But that is not required. This has much more information about the circuit I made. Improving edge detector with latching circuit for esp8266

  • \$\begingroup\$ Your good, there really isn't a question, the first time I looked at it I thought there was. \$\endgroup\$
    – Voltage Spike
    Sep 3, 2020 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.