# SparkFun Forums

### Battery Monitor and Arduino clone

For the discussion of Arduino related topics.

### Re: Battery Monitor and Arduino clone#113869

By viskr
#113869
Basically measure the voltage divider, it should be 1/2 the battery voltage. If its not then the AD input is loading down the divider too much and you'll need to decrease the resistor values.

Is your supply 5V or 3.3? If 3.3, then those analog switches don't like to be pulled above the supply.
If it is 3.3V, divide by 3, with 20M and 10M.

With resistances that high you're starting to get into the realm of very high impedance circuits. By the time you get to 100M, your circuit turns from being something useful to being an antenna picking up any stray signals. Also at those levels, just touching the resistors will leave enough perspiration to affect the values.

### Re: Battery Monitor and Arduino clone#114669

By MobileWill
#114669
This is the thread I used to build mine.

http://www.arduino.cc/cgi-bin/yabb2/YaB ... 738420/8#8

I am using that code with a simple voltage divider. My readings are little off but work. I think I need to use different resistors since I am using a different voltage power supply.

### Re: Battery Monitor and Arduino clone#114777

By cbabilotte
#114777
I got mine to work with 3 resistors of 10 M in series. If you take the attachement I previously posted you just add a new 10 M resistor and that should work. I have also a resistor from the analog pin to gnd

I think if I play with the map function I can get it to what the measurement is suppose to be. Also maybe the resistor that is from the analog to gnd might not be the right value so I can still teak it that way. With the code below I am off but it is very minimal. I will try to post a picture when I am done.

Here is the code I am using

// variables for input pin and control LED
int LEDpin = 13;
int prev = LOW;
int refresh = 1000;
float vin = 0.0;

// variable to store the value
int value = 0;

void setup(){

// declaration of pin modes
pinMode(LEDpin, OUTPUT);

// begin sending over serial port
Serial.begin(9600);
}

void loop(){
Serial.print("value=");
Serial.println(value);

if (prev == LOW) {
prev = HIGH;
} else {
prev = LOW;
}
digitalWrite(LEDpin, prev);

vin = map(value,0,1023,0,8690)/100.0;

Serial.print(vin);
Serial.println(" volt");

// sleep...
delay(refresh);
}

### Re: Battery Monitor and Arduino clone#114778

By MobileWill
#114778
Thanks that would be helpful. Even though mine works it seems to not be accurate enough to monitor battery level. I was hoping to shutdown attached systems/sensors based on battery level.
###### long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

###### Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

###### Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

###### Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]