I'm planning to monitor voltage of a 12V battery with an Arduino's ADC pin connected via a voltage divider. Since I don't want the circuit itself to drain the battery when not in use, I want to use a transistor to "enable" it via an Arduino DIO pin like:

voltage divider

Is this a safe circuit to use?

If I set EN low to disable the divider, will that risk putting 12V directly on the ADC pin and burn it out? I've found alternative designs, but they seem overly complicated.

Edit: The battery is a Lipo which is also powering the Arduino through a step-down DC converter.

  • 1
    No, that will not accomplish your goal. The top resistor may be large enough that the Arduino MCU's protection diode may be able to handle the current sourced from the battery, however you will still be draining the battery, which is what you were trying to avoid. What is the capacity and chemistry of your battery? I'd expect something like a car battery may have a self discharge rate that hides the load of your voltage divider. Oct 11, 2015 at 3:38
  • The "Controllable Voltage Divider" on the page you linked seems more sensible to me. Plus I chuckled at the "NdN" transistor you were using. ;)
    – Nick Gammon
    Oct 11, 2015 at 4:07
  • @ChrisStratton, How is it still draining the battery? Would it be different if I relocated the transistor to the high-side?
    – Cerin
    Oct 11, 2015 at 15:25
  • 1
    It is still draining the battery because there is a protection diode from the input to the ATMEGA's power supply, which clamps the input voltage at around .6v above the supply voltage, and that will be fed by the top resistor in your circuit. Potentially (with a smaller resistance) this could even end up powering the ATMEGA from an input, though doing so is out of specification as the diodes are tiny and easily damaged. Oct 11, 2015 at 15:29
  • @ChrisStratton, Right, so wouldn't moving the transistor to the high side should fix that? With EN pulled low, there won't be a circuit connecting 12V to the ADC input.
    – Cerin
    Oct 11, 2015 at 16:08

2 Answers 2


I use a similar system on a product I recently worked on to monitor the battery voltage - and of course I didn't want it on all the time to drain the battery.

The trick, though, is to do the exact opposite of what you are doing. Instead of isolating the ground (which leaves the battery then directly connected to the Arduino) you need to completely isolate the battery from the divider.

This can be accomplished by using a P-channel MOSFET which you can then drive with an N-channel MOSFET:

enter image description here

The theory is, when the Arduino DOUT is either LOW or not connected (pulled low by 10K resistor) the N channel MOSFET is turned off. That means the gate of the P channel MOSFET is being pulled up to the battery voltage by the other 10K resistor, so the P channel MOSFET is off, which isolates the whole divider from the battery.

When DOUT goes HIGH it turns on the N channel MOSFET which then pulls the gate of the P channel MOSFET down to ground which then turns it on, thus connecting the divider to the battery.

When the P channel is OFF the only circuit connected to the ADC is the connection between the ADC input and ground through a 10K resistor, so everything is happy and safe.

You should not use resistors greater than around 10K in size on the input to the ADC because the ADC itself has a resistance (the impedance) which is placed in parallel to the lower resistor of the divider. If the divider's resistors are too large that impedance will affect the accuracy of your readings because the total resistance of the lower resistor will be skewed slightly. Yes, it's possible to compensate in software, but as long as you keep to a limit of 10K or so for the resistors you won't need to worry about doing such things.

Note that it is important to use a P-channel MOSFET for this, not a PNP transistor. A P-channel MOSFET, when on, looks like a very small resistor. A PNP transistor is seen as a fixed voltage drop skewing your results. The N-channel MOSFET can be replaced by an NPN transistor if you wish, it makes no real difference. I nearly always use MOSFETS these days instead of BJTs though as a matter of course.

As an aside, the only other way of achieving this whilst maintaining the isolation of the ADC from the battery would be to replace the P channel MOSFET with a small relay (say a reed relay), but then you still have to build a relay driving circuit which is just about as complex as this one.

  • Interesting analysis. That's a good point about MOSFET vs BJT, however, I'm still not sure how the overall design fundamentally differs from my approach. If I relocated my transistor to the high side, and turned it off, wouldn't the ADC be similarly disconnected from the battery? Also, why can't you wire the DOUT directly to the P-MOSFET's gate? Will the P-MOSFET only activate with 12V?
    – Cerin
    Oct 11, 2015 at 15:02
  • The P mosfet's gate has to be pulled up to the source potential to turn it off - i.e., 12V. Wiring it to 5V it will never turn off. You can't just move your transistor, you have to change the transistor's polarity (PNP instead of NPN or P channel instead of N channel) which then also means driving it properly with an N channel or NPN.
    – Majenko
    Oct 11, 2015 at 15:04
  • It appears you have the Drain and Source mixed up on the P-FET. I created your circuit in tinkercad and was having an issue until I switched them. Thanks for the circuit design - I'll try building it for real now. Here's the Tinkercad link if you're curious. Jan 31, 2023 at 6:57

I'd use some very large resistors (e.g. 1 and 2 Mega Ohm), and add a small capacitor to the center, to stabilize the value during sampling. Using 1 and 2 MOhm would result in 10uA of current loss, which is probably negligible in your cases.

enter image description here

  • No, don't do that. Think about the input impedance of the ADC and what affect such large resistors would have...
    – Majenko
    Oct 11, 2015 at 9:42
  • 1
    @Majenko That's what the capacitor is for. Just make sure there is some time between measurements for the capacitor remain charged at the right voltage. But I might be wrong here!
    – Gerben
    Oct 11, 2015 at 12:41
  • Oh, and I wouldn't call 10µA negligible. My last project idled at 50µA total - adding another 10µA on top of that would have been an increase of 20% current consumption.
    – Majenko
    Oct 11, 2015 at 12:47
  • 1
    10uA would take about 2 years to discharge a CR2032 coin cell. Since this is a 12V battery I assume it's more that 240mAh. Indeed 10uA isn't always negligible.
    – Gerben
    Oct 11, 2015 at 12:58
  • Keep in mind that an ADC of the type used here is typically not a steady-state load, but rather a pulsed one. If you go with this route, it would be a good idea to evaluate the readings for various resistor and capacitor sizes. I do expect you will see some distortion of reading, but I also expect it will be possible to get a decent reading with a circuit whose load is dwarfed by the self-discharge rate of a larger lead-acid battery if that is indeed what is being monitored. Oct 11, 2015 at 15:14

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.