user34759: I am looking to work with deep sleeping, particularly with the ESP8266 but this question applies to most all micros. I am interested in running the device off of battery power for as long as possible. My solution would be something like a weather station where you know you only want to take a measurement every x minutes. So, I would like to sleep as much as possible in between measurements to extend battery life as much as possible. However, sleeping the microcontroller is one thing. How about when you have some sensors that piggyback off of the battery too. No need for those to be powered while the micro is sleeping and not taking a measurement. 
Similar to this, I was thinking about reading the battery level. There are plenty of examples on how to do this online using a voltage divider (if necessary) and running the battery into analog input. This also draws from the battery while sleeping.
So, is there a way I can run all of these external sensors/devices through a transistor or something with low power draw when off and turn it all one when the device wakes up from sleep?
Thanks!

user10794: I made a temperature and humidity sensor which runs off 3 x AA batteries. It lasts a couple of years without changing the batteries, and writes to an SD card.
The power-control part of the circuit is here:

The general idea is that Q1 is used to turn on/off a "switched 5V" rail (5V_SW) to which are attached most of the peripherals. This is done in conjunction with power-down sleep mode on the processor. A watchdog timer wakes the processor every 8 seconds to check to see if it is time to take another reading.

The full schematic is:


I think I've changed the batteries once since making it in 2013.

34759: <p>I am looking to work with deep sleeping, particularly with the ESP8266 but this question applies to most all micros. I am interested in running the device off of battery power for as long as possible. My solution would be something like a weather station where you know you only want to take a measurement every x minutes. So, I would like to sleep as much as possible in between measurements to extend battery life as much as possible. However, sleeping the microcontroller is one thing. How about when you have some sensors that piggyback off of the battery too. No need for those to be powered while the micro is sleeping and not taking a measurement. </p>

<p>Similar to this, I was thinking about reading the battery level. There are plenty of examples on how to do this online using a voltage divider (if necessary) and running the battery into analog input. This also draws from the battery while sleeping.</p>

<p>So, is there a way I can run all of these external sensors/devices through a transistor or something with low power draw when off and turn it all one when the device wakes up from sleep?</p>

<p>Thanks!</p>
 10794: <p>I made a <a href="http://www.gammon.com.au/forum/?id=12106" rel="nofollow noreferrer">temperature and humidity sensor</a> which runs off 3 x AA batteries. It lasts a couple of years without changing the batteries, and writes to an SD card.</p>

<p>The power-control part of the circuit is here:</p>

<p><a href="https://i.stack.imgur.com/IkEbk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IkEbk.png" alt="Power management"></a></p>

<p>The general idea is that Q1 is used to turn on/off a "switched 5V" rail (5V_SW) to which are attached most of the peripherals. This is done in conjunction with power-down sleep mode on the processor. A watchdog timer wakes the processor every 8 seconds to check to see if it is time to take another reading.</p>

<hr>

<p>The full schematic is:</p>

<p><a href="https://i.stack.imgur.com/v8SCY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v8SCY.png" alt="Full schematic"></a></p>

<hr>

<p>I think I've changed the batteries once since making it in 2013.</p>
