Dual power Attic fan

I'm have two solar attic fans that at one time ran off of Solar when there was enough sun to power them and DC when there wasn't. The controller died and $230 is more than I want to pay to replace it.

So what method would I use to allow the Arduino to detect when to switch from solar power to DC? I know how to set up the Temperature and Humidity portion of the project.

I think the controller was also the battery charger ? I cannot see that kind of money for a switch

monitor the battery for voltage. there is a threshold where you can use it. you did not state what voltage a fully charged battery is. or what a discharged battery is.

assume 14 volts is fully charged 11 volts is discharged.

if the temp is too high, turn on the fan
if the battery if over 13.5 volts, use battery
if the battery is lower than 11.5 volts, use direct power.

should be simple relay.

You also need to stop (over) charging those batteries when it has reached capacity (say 14v - or whatever the spec says) otherwise they will have a very short life.

You may be able to switch to a very low trickle charge current just to keep them topped up without damaging them - once again the specs on those batteries should tell you this.

You Arduino can handle this too.

I think I would use a bit different logic than Dave -
-- if temp too high, turn on fan
-- if solar high enough to run fan, run on solar
-- else use battery

In addition, you need to control battery charging as pointed out by others - is there a source of power to the fan assembly to be able to charge the batteries or does it only charge them from solar if there is any surplus? You would have to do a bit more research into how much current at the working voltage the solar panel puts out as well as how much current the fan motor requires. An arduino can certainly handle the issue, but you need to determine just how to allocate power depending on if there is external power or if this is all solar powered (including charging the batteries).