Hello forum, I want to measure the voltage of lead-acid batteries (as a quick and dirty state-of-charge calculation) and came across these threads:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239635198

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1142283743

Now, battery voltage can't go much higher than a few volts above 24V so I think a simple voltage divider will do the trick just fine although if you believe I should go the opamp route please let me know.

Now, I have two questions:

1) I don't want to drain the battery with the tiny but non zero current drain of the divider. One obvious solution is to use some pretty enormous resistors but of course it is inelegant. So, I was thinking, can I do something clever with a transistor? Can't I dump a transistor in series with my resistors and switch it on with one of the Arduino's pins whenever I need to take a measurement (it won't be that often, we are talking time of the order of minutes or hours between measurements)?

If that is possible, what sort of transistor should I use?

2) Any simple way I can I "zoom" into the interesting bit of the voltage? This means the upper 4-5 Volts of the measurement. One very dirty solution I can think of is to make a voltage some 18, say, volts higher than the batteries' GND and connect the Arduino's ground there. However, this is unbelievably hideous as it will introduce a current drain for this new divider as well as making life a living hell if I want to connect other sensors which require a common ground between Arduino and batteries.

The enormous resistors won't work well by themselves. For the Atmel ADC the datasheet recommends an output impedance of less than 10K for the source you are measuring.

You could use the enormous resistors on the input to an op-amp buffer. The op-ampbuffer will have an output impedance very close to zero. Using an op-amp segues intothe answer to #2

For #2 the measurement is called a null and difference measurement. The op-amp could be configured to perform an analog subtraction. If you can alwayssubtract the same value it is easy to do with two op-amps. Otherwise you needto program the value to subtract. This would be a bit more complicated.

How much accuracy and resolution do you really need? With the ADC in 10bitmode you are probably around a few tenths of a percent. Your divider may add a little error (but could be calibrated). Do you need more accuracy than that?

Hey there, hard to get op-amps so had a go with some transistors with mixed results.

For a start, I tried measuring a DC voltage from a transformer but with a transistor in the way. I got good some results with a PNP transistor (BC640):

Connecting the Emitter to the voltage to be measured (ranging from 3.9V to 17.8V), the Collector to the voltmeter positive terminal and the Base to GND via a 12k resistor, I got a perfect match between measured voltage and voltage at the transformer terminals. A bit suspiciously perfect in fact, not much evidence of a voltage drop. Connecting the Base to the positive transformer terminal completely cut off the voltage.

Now, I tried substituting the transistor Base input with a digital pin from the Arduino and got some weirdness. At the lowest voltages the transformer provides, 3.9V, the pin succesfully switches the transistor on and off (on when it's LOW and vice versa). At the next higher voltage, 5.7V, the voltmetre correctly reads 5.7 when the pin is LOW but when the pin is HIGH, instead of turning it off, the voltmetre reads 5.92V

This behaviour is repeated for all higher voltages, with the measured voltage jumping roughly 0.2V when the pin goes HIGH. I have tried R1 values from 12K down to 1K with no apparent change.

I 'm obviously doing something very wrong but I can't figure out what. Help?

P.S. How do I upload an image? I made an award winning diagram but I can't for the life of me figure out how to upload it.

At the next higher voltage, 5.7V, the voltmetre correctly reads 5.7 when the pin is LOW but when the pin is HIGH, instead of turning it off, the voltmetre reads 5.92V

Yes that is to be expected. The base can only go up to 5V but you are putting 5.7V on the emitter, therefore you can never turn this transistor off.You have totally the wrong idea of how transistors work.Have a look at:-http://www.kpsec.freeuk.com/trancirc.htm

One more question regarding protecting the Arduino ADC. Its max voltage is 5 Volts. To be on the supersafe side, I take the line that goes to the ADC pin and branch it off to a zener that ends at GND. Then, by adding a fuse before the branching we can ensure that it will blow once a big current starts flowing (when the zener floodgates open).

Now, two questions. How much voltage can an ADC pin take before something terrible happens? My zeners have a breakdown voltage of slightly above 5V. I take it a little bit of overvoltage for a little while won't be a problem, right?

Second question, what should the fuse rating be? Exactly the size needed to protect the zener given its max power dissipation? Less?