0

Thank you in advance. I am beginner in Lead acid batteries.

Actually I Am using solar energy to charge my 12v sealed lead acid battery. and the thing is I need continuous monitoring of my battery voltage. I used a voltage divider to do that.

Now my Question is, Can I connect voltage divider continuously to the battery?

And the calculated voltage is fluctuating, how to reduce this fluctuations?

Thank you.

Dileep
  • 65
  • 1
  • 1
  • 8
  • 1
    This *might* be better asked on the Electronics SE site. – Wayne Werner May 05 '16 at 11:31
  • Well, if you plan to keep it always connected, a voltage divider has the disadvantage to draw a little current continuously. If the arduino is connected to the battery too, this current is negligible; if, on the other hand, you are powering the arduino from another source and you want to store the battery for long times, I suggest you to use also a transistor to detach it from the power supply. As for the fluctuations, this depends. Is the fluctiation 1V over 12V? is it 1uV over 12V? If the fluctuation is about +/- 50mV over 12V you can't do anything; if it is more you can 1) put a capacitor – frarugi87 May 05 '16 at 15:19
  • in parallel to the lower side of the voltage divider, or 2) take different measures (5-10) and then average them. This will reduce the noise.. – frarugi87 May 05 '16 at 15:20
  • Thank you Frarugi. I am taking 20 samples and Am getting +/-3mV. Is there any possibility to reduce that. Switching is very good idea, to save battery power. thank you. – Dileep May 07 '16 at 07:28
  • Thank you Wayne Werner. if you like this question Plz mark it as fav. – Dileep May 07 '16 at 07:46

3 Answers3

0

Yes you can connect your voltage divider to one of Arduino's analog pins!

In fact, I've answered the same question last night in Arduino forum.

Have a look at it and don't hesitate to ask if you have further questions.

// number of analog samples to take per reading
#define NUM_SAMPLES 20

int sum = 0;                    // sum of samples taken
unsigned char sample_count = 0; // current sample number
float voltage = 0.0;            // calculated voltage

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    // take a number of analog samples and add them up
    while (sample_count < NUM_SAMPLES) {
        sum += analogRead(A2);
        sample_count++;
        delay(10);
    }
    // calculate the voltage
    // use 5.0 for a 5.0V ADC reference voltage
    // 5.015V is the calibrated reference voltage
    voltage = ((float)sum / (float)NUM_SAMPLES * 5.0) / 1024.0;
    // send voltage for display on Serial Monitor
    // voltage multiplied by 11 when using voltage divider that
    // divides by 11. 11.132 is the calibrated voltage divide
    // value
    Serial.print(voltage * 11.002);
    Serial.println (" V");
    sample_count = 0;
    sum = 0;
}

in setup() a serial communication is being initialized. so that the output can be displayed in serial monitor.

in loop() n reading of the analog pin is taken and the sum is stored. then the voltage is calculated and the results is reported back to the user.

since we are in void loop the process will be repeated till power is disconnected from the Arduino board.

Amir
  • 101
  • 1
  • 1
  • 9
  • Arduino is using a simplified C language. Since we are working with micro controllers here the makes sure that the program never exits, Unlike normal C program which is run on OS. I'll update the code as well. – Amir May 05 '16 at 15:21
  • I mean, IMHO the question was not about "can I connect a voltage divider to the analog pins", but rather "can I connect it to the battery and leave it there forever"? And in this case the answer is "it depends"; looking at the question and the fact the OP said "I used a voltage divider to do that." I think he already knew that he could connect it... – frarugi87 May 05 '16 at 15:25
  • Yes, as I said as long as the board has power the voltage will be displayed in serial monitor. Or, the OP can modify the code to didplay the voltage on a LCD display. – Amir May 05 '16 at 15:28
  • Yes Amir, Frarugi is absolutely right. my question is about battery side. and im getting very small fluctuations. can i reduce tht? – Dileep May 07 '16 at 07:41
  • What do you mean with fluctuations? – Amir May 07 '16 at 12:17
  • The actual voltage of my battery is 12.41. But the serial port showing 12.41,12.43,12.41,12.43........ Like that. – Dileep May 07 '16 at 18:41
  • Did you read my answer in Arduino forum? Since the battery is charging such fluctuations are normal. It sounds like you're building a cell manager. Which in that case you need a over voltage cut out and if you are charging more than one cell at a time you'll need to balance charge them. – Amir May 08 '16 at 01:57
0

Yes you can connect the battery continuously to the voltage divider. Make sure you use very big resistors. Current output = V/R . so if you want I<0.1mA you want 0.1mA < 12/R. This means you must use Resistors in the Mega Ohm range.

To reduce fluctuations you can average the voltage readings. A simple scaled average would work nicely.

V[0] = 0.4V[-1] + 0.3V[-2] + 0.2[V-3] + 0.1V[-4].

this will smooth out your readings.

Makoto
  • 297
  • 1
  • 15
0

I found this useful site for my project. Have a look at it, If are interested. It's a "solar charge controller". They used best coding techniques to "calculate 12v battery" and solar panel voltage. Thank you.

http://www.instructables.com/id/ARDUINO-SOLAR-CHARGE-CONTROLLER-Version-20/?ALLSTEPS

Dileep
  • 65
  • 1
  • 1
  • 8
  • From the [Help Center](http://stackoverflow.com/help/how-to-answer): Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. – Adam Jun 07 '16 at 12:51