Voltage divider

I am going to make a voltage divider to monitor the battery of my internet controlled tank.

But before I do anything, I want to check with the smarter heads (you people :P).

The battery is a 9.6V 2000mAh from a drill, but it is going to be connected all the time, and the charger for it says 7.2V-14V

So just to take a round number, I say 15V (or would 20 be better to be safe?). The resistors needed for that should then be 10K and 20K, to get a voltage up to 5V that I can connect to an analog pin?

If I am bumping the voltage up to 20V in the calculation, to be safe, should it then be 10K and 30K instead? Or have I completely misunderstood how it works?

Cool :)

Anything else I should know before connecting it? Oh, and how do I calculate the current going through? I expect that there will be something wasted with the two resistors between positive and negative.

Ah yes, could have been a bit more precise. It was just the current through the voltage divider, thought it would be higher than that.

For the current through the motors, I was just going to use this http://www.electrozone.dk/sensors/current/acs712.html (translated http://kortlink.dk/88zm)

It is going to be a thing that can be controlled by everyone over the internet, so I better put some safety into it so people won't destroy it.

And before anyone here getting upset for me already believing someone here would destroy it, I can tell that I had a logitech sphere, and some other TPZ webcams that could be moved around from my website, but people kept aiming them at the sun, and then destroyed the sensor in them, so now they all got a pink layer over the picture. And I won't allow someone to destroy this thing by running it into a wall (putting distance sensors on) or making it jam somewhere and then somehow overloads the motors.

agreed “people” suck

One I know had a rovio online, but had to take it offline again. Simply because people kept driving it into his computer, and kept pulling the powercord out of it with the rovio...

Stuff like that sux, because it was so fun and easy to control

Made the voltage divider, and using the map function to calculate the analog pin into the voltage.

map(analogRead(sensorPin), 0, 1023, 0, 20)

The voltage seems to be right, but would it be possible to get one decimal in too?

Edit Made a little calculation like this

double volt = (((analogRead(sensorPin)*4)/20)/10);

but would there be a better or smarter way to do it?

but would it be possible to get one decimal in too?

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

Perfect! :slight_smile:

Did it like this

map(analogRead(sensorPin), 0, 1023, 0, 196) / 10.0

Seemes to make up for my voltage divider and get a closer result.

Been tweaking and tweaking... Seems to have it right now, and they stay close together +/- 0,02V as the voltage slowly drops.

But been over two hours, and it only dropped from 9.90V to 7.76V, and that is with the WiShield 2.0 active, just uploading junk to my nas, and the 120mm fan running.

map(nowVolt, 0, 1023, 0, 1933) / 100.0

which is almost my entire annual allocation

What for the day, week, month, year, decade or century?

I am VERY pleased with the result too...

When I got the idea what I would put voltage monitor on my wifitank too, I was expecting to get something like +/- 1V, so this is beyond all expectations! I got within freaking 0,2V \o/ wohoo ;D

Another discovery...

I just tested how low it could go with the battery before it collapsed... 5.2V on the external power supply, on my seeeduino mega.