12 Volt Lead Acid Battery Low Voltage Cutoff

I'm trying to make a Low Voltage Cutoff for my boombox with the Arduino. My needs for this is the Arduino to disconnect the battery at 11.6 volts. How would I do this, what would I need? I am new to the analog to digital business and need help for the value to put in the code for the digital value.

Cutoff.ino (309 Bytes)

Cutoff.ino (309 Bytes)

You would need a voltage divider to convert the 0-14V (maximum) down to the 0-5V range that the Arduino can actually read.

You also need more details, like is the Arduino powered from the same battery?

The arduino will be powered by the same battery and I put the code with the first post that I made. I just need to know how to get the right digital value for the voltage out the divider going into arduino. How would I get the value? I'm new to the analog to digital.

Make an accurate voltage divider with precision resistors, and there is no need to calibrate it.

Otherwise, make a 3:1 divider with three 10K resistors (two in series to make 20K on top and one 10K in the bottom) and calibrate it with your multimeter.

It is not a good idea to power the Arduino with a "12 V" lead acid battery via the barrel jack, because the voltage can go well over 14 V during charging, and that is too high for the on board voltage regulator.

You can add a 7 to 9V regulator between the two.

I got the divider working, what would the code be for this cutoff?

What value is (or would be) returned by analogRead() when the battery voltage falls to 11.6v?

You can calculate that value by measuring the voltage with a multimeter when it is higher and noting the corresponding value from analogRead(). Do that measurement and tell us the values. Better still get two separate sets of values for two different battery voltages.

...R

what would the code be for this cutoff?

Post the code you have, with a wiring diagram (not Fritzing) and tell us how it misbehaves.

For 11.6 volts the value is 785,

// low voltage cut-off

#define RELAY 7
#define DIVIDER A0

void setup(){
pinMode(RELAY, OUTPUT);
pinMode(DIVIDER, INPUT);
}

void loop()
{
int VoltageReading;
VoltageReading=analogRead(DIVIDER);

if (VoltageReading <785)
{
digitalWrite(RELAY, HIGH);
}
else
{
digitalWrite(RELAY, LOW);
}
}

Would this be the correct code for this?

That looks reasonable - assuming HIGH causes the relay to open.

Will opening the relay also cause power to the Arduino to be disconnected? If that happens what will the relay do?

On the other hand if the Arduino continues working do you really want it to reconnect the power a few seconds later?

Maybe you don't need the ELSE. Or maybe you should have a separate IF something like

if (VoltageReading > 812) {
   digitalWrite(RELAY, LOW)
}

which should turn it on if the voltage is above 12v

I am not suggesting you follow these comments slavishly - they are just here to prompt your thoughts.

...R

Could the relay be used on the power input if the arduino so when the threshold value gets hit, then the arduino and the boombox just shut off? Like the relay is a closed circuit when arduino is powered, then when the value is hit, then the relay would shut off everything. Mabye.

coolyyz321:
Could the relay be used on the power input if the arduino so when the threshold value gets hit, then the arduino and the boombox just shut off? Like the relay is a closed circuit when arduino is powered, then when the value is hit, then the relay would shut off everything. Mabye.

That is certainly possible. But you need a relay that requires power to hold it closed. The way your code is written

if (VoltageReading <785)
  {
  digitalWrite(RELAY, HIGH);
  }

it looks like it is normally closed and that would not switch everything off.

If the relay does switch everything off you will need to hold the ON switch long enough for the Arduino to boot and take charge of the relay with a digitalWrite(make-relay-go-on) in setup()

...R

I'm relatively new to coding, so how would i write this in the code?

coolyyz321:
I'm relatively new to coding, so how would i write this in the code?

I'm not sure what you are asking. You have all the parts in the code in Reply #8.

...R

Wait, never mind, it was a stupid question, sorry.

coolyyz321:
Wait, never mind, it was a stupid question, sorry.

No problem. Come back if you have more questions.

...R