Electronic – How to turn on module like ESP8266 only when switch is activated

battery-operatedesp8266low-powerreed

I'm looking for a way that the ESP8266 (or alternative, like an Attiny85 with an RF module) is only turned on once a reed switch (or similar sensor) has been triggered.

The problem is that the ESP8266 should have just enough time to power on and send a message over the Wi-fi network. The reed switch could close too fast for the device to send a signal.

Are there any components I can use to add a minimum power time before the reed switch (or power, somehow) is closed again?

The purpose is to keep the batteries for a long time while also notifying when the reed switch is activated.

Best Answer

Dampmaskin has the right idea, but his design is overly simplistic, for the reasons I outlined in my comments.

A more robust circuit would look like this:

schematic

simulate this circuit – Schematic created using CircuitLab

R1 and R3 make sure that leakage currents in either transistor won't cause unwanted activation of the circuit.

Obviously, the micro must set the GPIO pin high as soon as possible after it comes out of reset, before C1 discharges too far (make C1 larger if necessary). Then, it can set the pin low (or tristate it) when the task it is doing is complete.

You can substitute MOSFETs for the BJTs if you like, in which case, R2 and R4 are not needed (but they cause no harm, either).