Solar/ mains changeover switch

Hi everyone,
I am trying to build a device that can sense the volts of my battery bank and send to the analogue input of arduino and switch the digital 5v output on the arduino open and closed based on the volts the voltage sensor sees across the battery bank.
Need some guidance where to find information about how to set something like this up
Hope I'm clear in my explanation
Mike

That should be straigthforward.

You will probably need a voltage divider to match the battery voltage to the Arduino's 5v max.

The code could be as simple as

analogVal = analogRead(batteryPin);
if (analogVal < threshold) {
      digitalWrite(outputPin, HIGH);
}
else {
      digitalWrite(outputPin, LOW);
}

You will probably want to make it a little more complex so include a small gap between the HIGH and LOW changes.

...R

Wow robin that's awesome!
Should I buy a voltage sensor and a arduino uno?
My battery bank is 24 volts, so want the digital output to close when volts is 24 and open at 22 then close again at 24.
I haven't written any code yet what's the best way to learn it?
Cheers!,

The digital output will control a small relay coil which contacts in turn will pull in a contractor to close and open my solar wiring circuit wiring to the house wiring. When the volts are lower than 22 on the bank the contractor won't be energised and the mains will run thru a normal open set of contacts on the big contractor.
Ps I'm an electrician so it will all comply with wiring standards etc

do you expect any voltage dip when you make the change ?

you will need a way to provide a voltage to the Arduino.
the arduino UNO is a great unit to start with, however.... it does not offer screw terminals. since your wires are just pushed in, there is the possibility of them not staying in tight forever, or with any vibration.
I would expect that a loose terminal, and having your mains relay bouncing in and out for a few minutes could wreak havoc on your nerves.

you can get a screw terminal board :
http://www.ebay.com/itm/331607598951

that will work with a NANO, the NANO is a shrunk version of the Arduino.
for kicks, I would recommend you get a couple of each. once you have the Arduino, you might find many other uses.

http://www.ebay.com/itm/111654763655

there is a version for the UNO
http://www.ebay.com/itm/252038915273

this offers the beinift of using an UNO with shields. VERY nice to have.

Mike351:
Should I buy a voltage sensor and a arduino uno?
My battery bank is 24 volts, so want the digital output to close when volts is 24 and open at 22 then close again at 24.

The Uno can measure voltages from 0 to 5v with its analog inputs. All you need is a couple of resistors to divide the battery voltage down to the 0-5v range. I presume you know how to do that if you are an electrician. Allow some headroom to allow for the highest possible battery voltage.

I haven't written any code yet what's the best way to learn it?

Get an Uno and practice with the examples that come with the Arduino IDE (the programming system). And there are loads of online tutorials. The Thread planning and implementing a program may be useful but it was not written for absolute beginners.

...R

Thanks guys that's great help,
On another idea do u think I can get arduino to regulate the voltage the solar panels input into the storage batteries?
Cheers

Hi,
Can you clarify for me, from your last post, is all you need is a controller to connect and disconnect your panels from your battery bank?

What do you want to do with the mains?

Can you draw and/or photograph a block diagram of what you want to do.
The UNO controller can easily monitor and output control to charge batteries, its your reference to mains switching that has me confused.

Tom...... :slight_smile:

Hey tom
I want to do 2 things with arduino

  1. Control digital output contact state from data received on an analogue input, (that is the volts the battery bank is at) that output controls through relays and contractor wether the house is on mains or solar power

  2. I want to regulate the output voltage of the solar cells so they don't smash the battery with too much volts. So I guess I'd need something that could keep the solar output in a certain range. But if panels crank out too many volts I want to reduce the volts and in turn increase the current output from the cells, not just switch the output from the cells on and off.

Sorry don't have drawing with me ATM
Hope it's clear?

Are you planning to run the house ac ( is that 120 or 240 ), from an inverter, powered from battery bank, charged by solar panels?
Then when the batteries get low, switch the house back over to the grid?

"But if panels crank out too many volts I want to reduce the volts and in turn increase the current output from the cells, not just switch the output from the cells on and off.
"
That is good in theory, but where do you expect the extra power to be sent? In some cases, you will have to just turn the cells off for a short time if you don't have anywhere to send the extra power being produces. One option could be a second hot water heater placed prior to the normal hot water heater.

To prevent flip flop, (switching back and forty to fast), put in some delay (soft delay would be best), to prevent fast switching. I would think about 30 seconds. What do you think?

What kinds of loads do you have in the house?
Central air/heat
electric stove/oven
electric hot water heater
microwave
refrigerator/freezer

How long do you calculate that your battery bank will power if all the heavy loads come on? (day/night)?
The real question I guess, is how much power do you have from panels, and batteries, VS, how much power does your house require.

BTW: I lived off the grid for 24 years, but I am back on now.

Hi,
First remember the PV panels are current generating devices, not voltage, so your batteries will charge at whatever current is coming form the panels.
All you need to do is switch the PV to the batteries when the battery voltage is below a certain level, and disconnect the panels from the batteries when they reach a voltage that represents their full charge.

You battery load, that is your inverter, can then be switched in at what ever battery charge you desire, but will turn the inverter off when the batteries reach a low voltage which represents low capacity.

What voltage/wattage are your PV panels?
What voltage and capacity are your batteries?
What capacity is your inverter?
What do you aim to load the inverter with, ie lights, etc?

Tom.... :slight_smile:

Mike351:
On another idea do u think I can get arduino to regulate the voltage the solar panels input into the storage batteries?

That is possible but it would be altogether more difficult.

The commercial solar regulators are not wildly expensive.

...R

Guys,
Don't worry too much about the setup I'm more interested in setting up the arduino,
I guess I'll just use a commercial eBay regulator.
I haven't worked out size of panels, inverter or bank size yet, just want to see if I can get it to the switching before looking into that stuff.
Cheers for all the input :slight_smile:

Jack wp why did u get back on grid? What was your setup if u don't mind me asking?
Did u dabble in wind generation? I'm considering wind also

@Mike,
I got back on the grid when my mother passed away, and I wanted to be with my father at that time.

I had considered wind (and hydro), but I was down sorta in a little valley, and wind seemed not practical, and my small creak did not provide enough flow to make hydro practical.

I Had 20 solar panels, and 10 deep cycle (trolling motor) batteries.
2k inverter, backup 2k gas generator.

I used wood burning stoves/heaters. I devised a couple natural air conditioner systems.
I found it to be a hardship as I got older ( I am 66 now).

If I had 10 times as many solar panels, and batteries, it may have been less of a hardship.