hi there, my name is Joe
i am fairly new at arduino and this forum. i do have good knowledge on electronics though.
what i am working on is a backup charger for my battery bank, it runs 5 cabins for a remote fishing/hunting resort. what i need is to have something monitor the voltage in the batteries, and when they fall below a certain point ( 10.5 volts ) it will power down the inverter, then power up the generator, and then switch the cabins from the inverter to the generator.
then when the batteries have been charged up to 14.5 volts, it will kill the gen, switch from gen to inverter, and then power up the inverter.
this is what i have for code ( i copied some parts to here and some i wrote myself )
const int referenceVolts = 5; // the default reference on a 5-volt board
const int R1 = 3000; // value for a maximum voltage of 20 volts
const int R2 = 1000; // determine by voltage divider resistors, see text
const int resistorFactor = 255 / (R2/(R1 + R2));
const int batteryPin = 0; // +V from battery is connected to analog pin 0
int outPin0 = 13; // power to generator starter
int outPin1 = 11; // power to switch inverter off
int outPin2 = 9; // power to switch from inverter to A/C generator
void setup()
{
Serial.begin(9600);
pinMode(outPin0, OUTPUT);
pinMode(outPin1, OUTPUT);
pinMode(outPin2, OUTPUT);
}
void loop()
{
int val = analogRead(batteryPin); // read the value from the sensor
float volts = (val / resistorFactor) * referenceVolts ; // calculate the ratio
Serial.println(volts); // print the value in volts
if (volts <= 10.5)
{
digitalWrite(outPin1, HIGH); // turns inverter off
delay(2000);
digitalWrite(outPin0, HIGH); // starts generator
delay(2000);
digitalWrite(outPin2, HIGH); // switches from inverter to A/C
}
else (volts = 14.5);
{
digitalWrite(outPin0, LOW); // kills generator
delay(2000);
digitalWrite(outPin2, LOW); // switches from A/C to inverter
delay(2000);
digitalWrite(outPin1, LOW); // powers on inverter
}
}
I think it should work...like i said i dont have much experience with arduino but i think its pretty cool
thanks for looking