# Would a 7805 5 V regulator drain a 9 V battery?

Doing some DIY as a hobby, I'm making a small humidity-temperature radio sensor.

An ATmega328 is reading from a DHT11 sensor and then transmitting data to a Raspberry Pi by an STX882 radio transmitter. It is powered by a 9 V battery using a 7805 5 V regulator with 10 µF and 100 µF capacitances.

The C code on the ATmega is reading humidity and temperature and then sending it every 30 minutes:

const unsigned long DELAY = 30*60*1000UL;    // 30 minutes
void loop() {
delay(DELAY);
send_data(); // Maybe a little overcomplicated, but I think it is not the point
}


This was working like a charm, but the battery life has been unexpectedly short. It was brand new, and I made some sporadic tests with a short delay, with no abnormal heat coming from anywhere.

When I was satisfied, I put the 30 minutes delay and leave it alone (which was maybe a bit hazardous?), but after less than 24 hours the battery was 5.4 V dead. The 30 minutes delay was approximately respected for its lifespan though.

What could explain such a short battery life? Could it be the 5 V regulator? How could I build a long-lasting circuit?

PS: I'm still trying to Fritzing some diagram, but this takes age for noobs like me...

I used a 6lp3146 generic brand alkaline 9 V battery which apparently provided 300-500 mAh at 100 mA current, which is far more than what my circuit use.

Here is all information I could gather from the datasheet:

+-----------------+-------------+----------+-----------+---------+
|                 | DHT11       | STX882   | ATmega328 | 7805reg |
+-----------------+-------------+----------+-----------+---------+
| Voltage         | 3-5.5 V     | 1.2-6 V  | 2.7-5.5 V |         |
+-----------------+-------------+----------+-----------+---------+
| Active current  | 0.5-2.5 mA  | 34 mA    | 1.5 mA    |         |
+-----------------+-------------+----------+-----------+---------+
| Standby current | 0.1-0.15 mA | <0.01 µA | 1 µA      | 4-8 mA* |
+-----------------+-------------+----------+-----------+---------+
*"bias current"


If I understand correctly, my system is active for a few seconds every 30 minutes, so the standby current is all that should matter, and it is indeed driven by the 7805 regulator.

So yes, in the worst case, with 300 mAh I should be able to keep the system alive for only 40 hours.

Is there a way I could feed my system 5 V for a much longer time without a much bigger size?

For the record, here is a very good video about LM regulators vs. buck converters: Buck converter vs. linear voltage regulator - practical comparison

• I suggest using the LowPower library or similar to put the ATmega to sleep between measurements. – calcium3000 Jun 14 '19 at 19:11
• How short is short? – Scott Seidman Jun 14 '19 at 19:34
• @Jasen According to this link, 78L05 has 3mA bias current, which is lower but far from being enough to correct my problem. – Dan Chaltiel Jun 15 '19 at 10:11
• LP2950 is <140uA. MCP1703 is 2uA. "Here is all information I could gather from the datasheet:" - don't rely on datasheets, measure the standby currents. – Bruce Abbott Jun 15 '19 at 12:55
• Are you absolutely married to the 9v battery? Why? – Harper - Reinstate Monica Jun 15 '19 at 14:35

What could explain such a short battery life? Could it be the 5v regulator?

As mentioned, the 7805 has about 4mA of quiescent current. You need to find a data sheet for the battery (Eveready has nice battery datasheets, if you're using an alkaline cell). It's probably no more than 100mAh -- 100mAh / 4mA = 25 hours, so that should say something to you.

How could I build a long-lasting circuit?

The 7805 is old technology. There are better newer linear regulators out there. You should be able to easily find something that uses 10 times less quiescent current, and with digging even less than that.

To use even less power you'd use a buck converter that's specifically designed for low quiescent current -- but I gather that you're not ready to design one into a board at the component level. There may be a module out there that'll do the job, but you'll need to shop around for it. TI does have some buck converter modules, but you'll want to pay a lot of attention to their capabilities, both for maximum current delivery and quiescent current.

To use less power yet, do everything that you can to minimize the current consumption of your circuit when it is quiescent. This will require careful use of the microprocessor's sleep function, as well as managing how the board is powered (for example, if it only comes on once every 30 minutes, you may well want to turn off power to the radio and the humidity-reading portions of the circuit).

Measure the current consumption in all modes of operation, and use this to determine which modes are the worst offenders overall, then concentrate on minimizing the currents in those modes if you can.

• The thing sitting quiet for 30 minutes then taking a measurement and sending it, then going back to sleep. So the quiescent current can't be ignored. – TimWescott Jun 14 '19 at 20:13
• I meant: in idle mode, the 7805 will still be loaded, so it is not only drawing its own quiescent current but also some load current in a inefficient way. – Huisman Jun 14 '19 at 20:30
• I googled about buck converters and I think I am indeed not ready for this! I think I'm going to try with a LM2936 (15µA of quiescent current), does it seem good to you? Turning of the current of other components when idling is very interesting too, I'm going to see if it is simple enough to implement. – Dan Chaltiel Jun 14 '19 at 21:57
• @DanChaltiel You can get buck converters marketed as "linear regulator replacements" which contain all the circuitry pre-made for you, including the inductor, and are used exactly the same as you would use a linear regulator. They're not as flexible as making your own, but very handy little things to have when you're not familiar with the design process or just can't be bothered. – Hearth Jun 15 '19 at 18:11
• @Michael it's always good to do a quick web search before saying something definitive in these ever-changing times. The very first hit I got on a search for "low quiescent current buck converter" came up with one that has a 360nA quiescent current. And a 9V to 5V conversion via a linear regulator is, by definition, 55% efficient while this thing is 90% efficient. – TimWescott Jun 16 '19 at 18:27

All those parts can run from 3 to 5V so use a battery that doesn't need a regulator, a 16500 Li-ion cell, or a 3xAAA battery pack are about the same size as the 9V and produce voltages in that range. (or even a Li-po cell)

Without the regulator the microcontroller can shut down and the circuit will only need a few microamps.

• Or three “D” cells and change them once a season... D cells are the sweetspot for durability vs cost... – Harper - Reinstate Monica Jun 15 '19 at 14:27
• @Harper: or 3x NiMH rechargeable AA batteries. You only have to buy them once, and modern low-self-discharge cells are widely available. +1 this answer: a 9V is good for a smoke detector that actually wants the voltage, and the burst power capability, but bad if you need to regulate it down. – Peter Cordes Jun 15 '19 at 15:03
• Careful using a lipo, make sure you get a protected cell or have in-circuit overdischarge protection. At least if you want to ever be able to recharge it again. Then again, if your circuit's load cuts out due to undervoltage you may be fine without it. – Hearth Jun 15 '19 at 18:12

The idle current of a 7805 regulator is around 4 mA so, armed with the ampere hour capacity of your battery, work out how long it will last with a continuous drain of 4 mA.

If you establish that is the problem, you will find that there are plenty of regulators having a significantly lower quiescent current.

Once the battery drops to about 7 volts you are on a slippery declining slope because the 7805 regulator requires a couple of volts headroom to regulate properly and I would estimate (a quick guess) that at round about 6.5 volts the circuit will fail.

Given what I’ve just mentioned, I estimate that only 50% of the battery’s stated capacity is usable before the circuit gives up. Bear that in mind.

I'm running similar sensor nodes with much better results. My setup has a few differences to yours:

• I'm running the µc directly (no regulator) from rechargable 1S LiPo batteries (3.7 V nominal) originally sold (very cheap and with a matching USB charger) for mini-drones. The whole voltage range (4.3 V - 3.5 V) is acceptable for the µc. 1
• I power the peripherals (the sensor and the transmitter in your case) from a port pin that I can turn on before measurement and turn off afterwards. (I'm using BME280 instead of DHT11 but the power draw shouldn't be a problem.)
• After transmitting the measurement and switching off the peripherals, I send the µc to deep sleep. 2

1 I'm successfully using ESP8266s, although of course I would never recommend that because their documented absolute maximum Vcc is 3.6 V I think.
2 For my ESP8266 waking up from deep sleep is a reboot, so the code will start running at the top of setup(), but with your ATmega328 this isn't an issue.

• Would you mind giving me the reference of your battery? Powering the whole sensor with a port pin is a great idea! (I'd think it would be too much current for the µc to handle). Thanks for the DeepSleep ref too, it will help a lot. – Dan Chaltiel Jun 15 '19 at 18:43
• @DanChaltiel Just search your local shopping platform for "1S LiPo" and you should find something like this (4 x 1200 mAh) or this (10000 mAh). – AndreKR Jun 15 '19 at 19:28
• @DanChaltiel The datasheets you linked say the sensor needs 2.5 mA, the transmitter 34 mA and the µc can handle 40, so no issue there. (And usually they can handle even more for short periods of time.) – AndreKR Jun 15 '19 at 19:32
• Did you consider putting a diode or something in series with your batteries to drop a fraction of a volt? Or is the current so low that even a diode doesn't drop much? – Peter Cordes Jun 16 '19 at 3:09
• One thing apart from current to consider when powering peripherals (sensors etc.) with I/O pins: Make sure the peripheral is not unintentionally powered via bus interface lines etc. We had issues where an I²C sensor was still receiving current from the I²C pull-up resistors. – Michael Jun 16 '19 at 16:13

Very similar to "how come my solar/battery/inverter system has so little range?" > because the inverter is spun up all the time. Use different loads that work on direct battery and eliminate unnecessary voltage conversion.

You've done engineering 101, you've slapped the bits together and they work. Engineering 202 is making them work efficiently enough to be useful.

As above, junk the inverte-—I mean regulator. Select batteries that can run it straight, such as three 1.5V batteries @ 4.5 volts. (Two would not suffice as they would drop below 3V too soon; or maybe; try it!)

Also think about larger batteries - - 9Vs are stupid-small capacity, especially when throwing away 2/3 of the capacity! (The electronics needs 3V, you are taking 9V and throwing the rest away as heat). Think big - D cells are your friend if you want longevity.

Deer cameras typically have two complete banks of D-cells, you can use either or both, and can run a whole season.

Also, the ATMega's sleep current draw is very impressive, but the STX882 and the sensor, not so much. See if you can find a way to have the ATMega physically shut off power to the other devices when not needed. The cheapest, scungiest way to do this is a small relay, but a power transistor should also do the trick.

One last trick. It may not be worth doing depending on what duty cycle the system is powered up, but it's worth mentioning. In recent years CPUs went from 5V to 3.3V. Why? Because they operate on current; voltage beyond minimums doesn't aid operation and just dissipates more heat. As CPUs got more powerful, thermal issues became the limiting factor, so dropping voltage to minimums allowed cooler running and more performance on the same heat sink. The same applies to your electronics.

You are aiming to run at 5V, the high side of the allowable voltage range. My 3xAA proposal puts you at 4.5V but consider making a different battery choice that goes even lower: such as Lithium batteries or three NiCd/NiMH (3.6V). NiMH has more capacity, but NiCD has truly amazing resistance to abuse and deep discharge.

• You are absolutely right, I'm heading to 202 and your answer is very instructive in this way. I always thought recommended voltage was 5V, being able to operate at 3V will simplify things a lot. Just a thing, how come "ATMega's sleep current draw is very impressive, but the STX882 not so much", when it is 100 times lower? – Dan Chaltiel Jun 15 '19 at 16:56
• Whoops, my bad. – Harper - Reinstate Monica Jun 15 '19 at 17:23
• In recent years CPUs went from 5V to 3.3V. That was a few years ago now :P These days CPUs program the voltage regulators on the mobo to run at the bare minimum voltage possible for the current frequency, barely more than the band-gap. Power scales with V^2 for CMOS logic (pumping charge into capacitive gate loads). e.g. my desktop runs its i7-6700 Skylake CPU at something like 1.25V depending on turbo vs. idle clock speed. – Peter Cordes Jun 16 '19 at 3:29
• There was a good talk at IDF2015 about Skylake power management that got into some of the tradeoffs of modern (high end desktop/laptop, not microcontroller) CPU power management. en.wikichip.org/w/images/8/83/…. There used to be audio to go with those slides (from an Intel architect), but that seems to have disappeared :( Maybe still worth flipping through the slides if you're curious about that sort of thing. – Peter Cordes Jun 16 '19 at 3:30
• Anyway, since CPUs want a programmable load-varying amount of voltage, but at high current, mobos power the CPU voltage regulars from the +12V supply. Most of the current demand on a modern PC power supply is on the 12V line, with CPU and GPU having their own DC-DC converters. (Modern DRAM runs at 1.2V for DDR4, down from 1.35V for DDR3L.) So again mobos power that from a DC-DC converter located near the DRAM. Or when you said CPUs, were you just talking about microcontrollers like the one the OP is using? If so, sorry for the tangent. :P – Peter Cordes Jun 16 '19 at 3:37

This is how I do similar projects. I use 3xAA which gives me 2.5V-4.8V this is within the operational range of atmega, I connect this to a step up converter with disable pin, when disabled the converter consumes near to nothing and passes the voltage through. When atmega wakes up and needs to make measurement it will turn the converter on, finds 5V on VCC, do measurements and transmit, disable converter, go back to sleep. It lasts years.

According to your numbers, you're getting expected behavior, between your sensor, your microcontroller, and your regulator (8ma). If you want better, sleep the controller, switch the sensor off, and get a more suitable regulator.

1. Measure what's the actual current drain in the idle and active states. Use an ammeter between the battery and the 7805 input. A typical new 9V battery has more than 300 mAh, and the 7805 quiescent current alone couldn't really consume it all - something's fishy! I've measured a lot of 9V batteries and they are typically 500-600 mAh. The caveat is that they are all alkaline, and if you're interested in getting the longest lifespan, of course you need to use alkaline batteries.

2. Is there a real reason to use disposable 9V batteries in your application? Have you considered something like 3× or 4× AA?

• I genuinely thought that 9v battery would last longer. I was apparently wrong. – Dan Chaltiel Jun 15 '19 at 16:29
• Isn't there a mistake in the sentence (alkaline twice)? "The caveat is that they are all alkaline, and if you're interested in getting the longest lifespan, of course you need to use alkaline batteries." – Dan Chaltiel Jun 15 '19 at 16:39
• It's confusing, sorry. I meant that my measurements are alkaline only, which is the one you should use if you want the longest life. Your battery might have been zinc-carbon, which could partly explain its quick death, yet I think you should first verify what the actual consumption is. – anrieff Jun 15 '19 at 19:28

From the delay and loop functions looks like you are using Arduino code. The delay function is a active loop, it will not put the microcontroller to sleep! The Arduino API doesn't have support for sleep mode.

Read the ATmega328P datasheet and see page 34 for how to put the device to sleep mode.

IMPORTANT: If you can power down the DHT11 humidity sensor between uses you MAY be able to extend the battery life by a factor of 3 or 4.

The DHT11 has a quiescent current of 100-150 uA in sleep mode. You have to design to the worst case value.
On power up it requires 1 second "to clear its head" (note 4. page 5)
and then there is interface setup time (maybe a few 10's of ms).
It is not obvious from the data sheet whether response time is affected by being powered down, but probably not .

Depending on the time between activations the powering down of the DHT11 could reduce system quiescent current from around 200 uA to around 50 uA.
Well worth looking at.

LM2936 Regulator:

The LM2936 that you mention is a superb regulator if it meets your requirements. Low dropout, low quiescent current, range of output voltages available.

I used them long ago in a product which needed their low Iq and was very pleased with them. Hmmm - that was about 1993 - 25+ years - an oldie but a goody.

Iout max is nominally 50 mA - which meets your tabulated need.
Iq is 10 uA at 100 uA load - and less at much lower loads.
Vin is 5.5 - 40V and in fact probably closer than that to Vout. You can get 5V and 3V3 versions.