If you are a father like me, you are used to your kids forgetting things. Mine constantly forget to close the garage door. That’s why it was open for several nights. Nothing was stolen yet, but I wanted do tinker something that reminds me of the open garage door.

I had some projects with esp32s in which I made the controller send notifications over the wifi. So that was set, but an esp32 in wifi mode can consume a lot of energy. So I figured out following plan:

The esp shall be woken up, if the garage door was opened. It shall got to sleep immediately and wake up again after let’s say, 5 minutes and check if the door is still open again. If the door is closed, the esp shall enter a energy safe mode. If the door is still open, the esp shall enter sleep mode for another, let’s say 30 minutes. If the door is still open, once the esp woke up again, it shall send a notification to me.

The best energy safe mode would be if the esp was not even powered. So, I needed a mechanism to switch the power supply. I had a IRF9540N laying around, which is a p channel MOSFET that is able to handle more than 10 Amps. More than enough for me. In addition I had a Reed switch, I salvaged from a old washing machine, and two BC547 transistors.

A p channel MOSEFT switches on, if the difference between gate voltage and source voltage is negativ, i.e. in my case I wanted to set the gate voltage to 0 V to keep the drain voltage high. So, I need to be able to switch the gate voltage (high –> no drain voltage, 0V –> drain voltage. This could be done with a BJT transistor (Q3 in the picture below).

If the garage door closes, it closes a Reed switch. The closed Reed switch makes Q3 conductive, which sets the gate voltage of the MOSFET to 0 V. Hence the MOSFET conducts and the drain voltage is equal to the source voltage. Q3 will be conductive even the Reed switch opens, because Q3 will be keept active with the help of R7 and C1.

If the esp has finished its tasks it can shut off itself by outputting a high signal (CTRL_SIG). This signal makes Q1 conductive. Hence the base voltage of Q3 will be 0V, which makes Q3 not conductive. And this results in a high gate voltage at the MOSFET.

You can replace the Reed switch by any switch, e.g. push button or maybe a light barrier.