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?


  • To answer your question, yes, you can use a transistor to stop excess power draw. Or do you want to know how to do it?
    – Avamander
    Aug 23, 2017 at 11:14

1 Answer 1


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:

Power management

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:

Full schematic

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

  • Nick, excellent and detailed information. A couple of years would be nice but I am shooting for at least 6 months and am using a 2500mAh LiPo battery pack. The reason only six months? I am using a wifi (ESP8266) device to connect and send on wakeups and the sensors draw a fair amount when awake. I am okay with 6 months though. Do you think I can use a PNP (2N3906) instead of the FET to switch on and off? Aug 22, 2017 at 22:51
  • The FET has much greater capacity to handle larger currents (47A compared to 200 mA). When you say the sensors draw "a fair amount" I would take that into consideration. I had another project that powered a transmitter just using solar power.
    – Nick Gammon
    Aug 22, 2017 at 23:10
  • you don't have to send each wakeup; w/o wifi, the esp only uses about 15ma...
    – dandavis
    Aug 23, 2017 at 19:20
  • @NickGammon, is there anything specific about FQP47P06 transistor you used? I'm looking for something more common (and perhaps cheaper)? Nov 7, 2019 at 20:00
  • @TomekCejner Not particularly, that just happened to be one I was able to get at the time, or already had to hand.
    – Nick Gammon
    Nov 10, 2019 at 7:02

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.