How To Make Arduino Turn Itself Off After Toggle Switch On?

Can anyone suggest a simple circuit with which you could use a standard single-pole toggle switch to turn power on to an Arduino, but then the Arduino would be able to turn off its own supply power after 10 seconds even if the toggle switch was still on?


Here’s a little background on this project.

I’m building a bunch of tiny cheap IoT sensors for all over the house, cars, yard, etc. using the ESP8266-12 with the Arduino IDE. It works great and each sensor unit is under $5 all-in with the battery and holder, and a tiny 3D printed enclosure.

I have it all working, but there is one puzzlement I am having.

The way the door sensor version works is this:

The base circuit has a NO reed switch (NO means open when the magnet is in proximity) . The reed switch controls battery power to the entire board. By the way, NO reed switches are a little tricky to find, because home alarm systems typically use NC reed switches so the entire perimeter of switches are closed in a big loop, and if anything breaks the loop, then the alarm sounds. But I found some cheap bulk magnetic reed switches on eBay from a guy in San Francisco that have both NO and NC output leads and a common lead on the other end.

So when the door is closed, the magnet is holding the NO reed switch open, and power to the PCB is completely off. There is no power consumption at all. (Well, OK, probably some.)

When the door is opened, the magnetic reed switch and the PCB moves away from the magnet, and the reed switch closes (turns on) and applies power to the PCB. The Arduino (ESP8266) boots up, connects to the WiFi network, and hits a server at a specific URL (something like “http://www.fubar.com/readsensor.php?door=1”). Then the Arduino goes into deep sleep. When the door closes again, the magnet turns the reed switch off, which cuts power to the Arduino and PCB.

I made a needed modification by adding a MOSFET so when the Arduino boots up, it uses a digital pin to turn the MOSFET on, which supplies the Arduino with power even if the reed switch turns power off too early (if someone opens the door and closes it really fast). This is so the Arduino can finish phoning home even if the reed switch turns off power too soon. When the Arduino is all done phoning home, it uses one of its digital pins to turn off the MOSFET, which kills power to the PCB.

Here’s the issue:

There is a power consumption issue in the case where someone opens the door because it is a nice day and leaves the door open. The reed switch is closed, and is supplying power to the Arduino and PCB. I want to find a way to power down the Arduino completely even though the reed switch is providing power.

I can put the Arduino into deep sleep after it phones home, which I will do, but this still uses a relatively large amount of power compared to the reed switch cutting power completely, especially if the door is open all day. I would like to find a way to put some simple circuitry in with the reed switch to accomplish this.

Any ideas?

Thanks!

Maybe a one shot timer based on the CMOS version of the 555 timer would do what you want.

Use a cap to allow the toggle switch to trigger the a power-on circuit similar to uC reset cap ,the processor then kicks in to hold the circuit on as long as needed.
Example - toggle switch/cap pulls P-MOSFET gate low to turn on power, uC output then holds the gate low.

I asked a very similar question a few weeks ago. See this thread: