# Why doesn't this battery voltage measurement circuit work? [closed]

So, I built this simple circuit for measuring voltage from a battery pack to an Arduino.

The thing is, I want to measure the first cell and then the voltage from the whole battery pack: using two transistors for changing the voltage divider input (check the image so that you know what I mean.)

I do not want to apply a constant load to the battery, that's why I'm using transistors to turn on and off the voltage divider circuit.

Here's the circuit:

I'm using a simple calculation when reading from pin A0: 0-1023 (analog range) reading to 0-25 volts (as the voltage divider is at a 5:1 ratio.)

My question isn't about the code. Here's the situation:

When both transistors are off, I get a 0 Volts reading (as it should).

When the first transistor is on, and the second is off, I get a ~4.2v reading (as it should.)

The problem is when the second transistor is on (and the first is off). I get the SAME reading (~4.2v) instead of 8.4v (the whole battery pack voltage.)

Adding diodes between each collector and the voltage divider for protection didn't alter my results.

UPDATE Note: Each battery cell is rated at 4.2v.

Real Schematic:

## closed as unclear what you're asking by Elliot Alderson, Voltage Spike, Finbarr, Bimpelrekkie, Dmitry GrigoryevApr 11 at 9:06

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Please add a schematic. A wiring diagram doesn't count and is nigh-impossible to understand. That said, you seem to be using BJTs for this. BJTs are not suited for this use due to their saturation voltage. – Hearth Apr 6 at 22:21
• Also... can the arduino survive 18V input? even if it can survive it why are you using it? It doesn't need more than a little above 5V, say 7V. – Hearth Apr 6 at 22:33
• It's not 18v, i know in the image i'm using 9v batteries but in reality it's a Li-po battery pack. (As i said above the 9v batteries). – John Sockert Apr 6 at 22:38
• Is there any way i can make that circuit work? Maybe changing those bjts for power transistors like a MOSFET? – John Sockert Apr 6 at 22:39
• What you want to do can be done with MOSFET's. But you have to post a real schematic so we can figure out what you actually did without looking up everything, including whether BC548 is NPN or PNP, etc. Then someone should be able to suggest a minimal change that will work. You might also try googling this. It is a common problem, how to use a divider to sample a high voltage but disable the divider when you don't want to load the voltage. Usually I use an NMOS to switch the gate of a PMOS which is pulled up to the high voltage (battery or whatever). – mkeith Apr 6 at 22:43

The issue is that you're using a low-side switch configuration in a high-side switch application. You can keep most of what you have if you just change to a high-side switch using PNP instead of NPN transistors. Something like this:

simulate this circuit – Schematic created using CircuitLab

• Thank you for your help Heath! I really appreciated it! – John Sockert Apr 8 at 5:36
• At first glance I think this will work. But if good accuracy is required, Q1 and Q2 could be replaced with MOSFET's to avoid the collector-emitter drop. And those diodes will drop voltage, too. It might be best to reconsider a few parts of the circuit unless great accuracy is not required. – mkeith Apr 8 at 7:46

Your problem is that the emitter voltage on the transistor can't go higher than the base voltage.

You're measuring the base voltage, minus two diode drops, not the collector voltage.

You could try using an "analog switch" or "analog mux" IC instead of a single transistor. Pay attention to the allowed voltage range for the signal pins.

Figure 1. Circuit from OP.

This won't work. Your transistors are wired as voltage followers. The emitter voltages will be about 0.7 V below the base voltage. This is confirmed by

When the first transistor is on, and the second is off, i get a ~4.2v reading (as it should.) The problem is when the second transistor is on (and the first is off). I get the SAME reading (~4.2v) instead of 8.4v (the whole bpack voltage).

The emitter of either transistor can't go above about 4.3 V.

simulate this circuit – Schematic created using CircuitLab