Switch to DC on AC loss at predefined times.

Hi there Arduino community,

I am living in South Africa where were are facing something our lovely government has dubbed: Loadshedding - Whereby, during certain times when our power grid is faced with issues with the poorly maintained power infrastructure (due to the corrupt government squandering funds, getting rid of skilled workers in favour of Black empowerment [nothing against this, but the lack of skill/experience is the issue, not the colour of skin] etc.), they drop areas from the grid in order to reduce strain on the local power grid.

We see this once in a while and can range from a single (Stage 1 loadshedding) 2 to 2.5 hour outage, to several (Stage 2 to 6) outages that last between 2 to 2.5 hours every 5 hours.

So long story short, I run some horticultural equipment that is to remain powered up for 18 hours per day during the vegetative phase, and 12 hours during the flowering stage.

I make use of high power COB LEDs (Luminus CMX-32 Gen 4) which runs off of Meanwell HLG-150 drivers from our AC 220V supply.

I have acquired some fairly decent 12V 5630 SMD LED strips that I want to switch over to when the AC power is cut, but obviously only during the "lights on" periods - this will be powerd by a few 12V 12 to 15Ah batteries connected to auto cut-off chargers which will maintain/recharge the 12V batteries between outages.

I am really quite excited to look at using an Arduino Uno R3 (locally available) and some relays to seamlessly switch on the 12V LED strips upon AC loss, but I have the following questions:

  1. Can the Arduino switch from a DC power adapter to battery without losing power in order to power on the 12V LED lights? If so, what voltage is required to run the Arduino, as I've read they are happy with between 9V & 12V - but wouldn't want to risk blowing the unit if connected to 12V?
  2. What would the required components be to achieve/manage this scenario? E.g. 220V relay that will trigger the switch to 12V relay upon loss of AC 220V, etc.
  3. Would I be able to program the Arduino to only switch to 12V during specific times of day? E.g. My 220V timers to my Meanwell drivers and other hardware is set to be on between 5am and 11pm, should the AC/mains cut off during loadshedding after 11pm and before 5am, it is to only power the Arduino and 12V exhaust fans from battery and not power on the LEDs connected to my 12V circuit.

I think I have covered everything here, but if you need more info, please don't hesitate to reply, I will keep a close eye on this thread as I am itching to start my tinkering.

Many thanks and regards, and stay safe during this COVID-19 pandemic we are facing globally as humankind.

Much love, respect and blessings from a fellow human being here in South-Africa. :slight_smile:

You have missed the current requirements for each switched circuit. The junk hobby relays we use with the Arduino will not work very long for you.

Paul

Paul_KD7HB:
You have missed the current requirements for each switched circuit. The junk hobby relays we use with the Arduino will not work very long for you.

Paul

Hi there Paul,

Thanks for your response, my apologies for omitting this crucial bit of info... If my calculations are correct it would be around 10A total on the 12V, this is split across 3 units of around 40W each (MAX).

I will draw up a quick visual representation of what I want to do.

whdii:
Hi there Paul,

Thanks for your response, my apologies for omitting this crucial bit of info… If my calculations are correct it would be around 10A total on the 12V, this is split across 3 units of around 40W each (MAX).

I will draw up a quick visual representation of what I want to do.

A block diagram that shows the components and the connections would be perfect.

Paul

Hey there Paul,

So herewith my diagram, it actually caused a few more questions to pop in my head. lol

  1. Can the Arduino switch between DC & Battery depending on if one source is lost?
  2. I need to be able to keep one 12V channel running at all times during outages (Intake & Exhaust fans for humidity control).
  3. I need to be able to switch the 12V lights on only during "lights on" periods (e.g. between 5am & 11pm).
  4. I was planning on using a separate timer between AC 220V & Arduino, but surely I can just use the Arduino as the timer on 220V circuit as well?

Thanks in advance. :slight_smile:

To be really honest, I would use one or more UPS to solve your problem and it could be installed next week. Whereas your Arduino project will take you 6 months or more to get all the bugs out.

Paul

whdii:

  1. Can the Arduino switch from a DC power adapter to battery without losing power in order to power on the 12V LED lights? If so, what voltage is required to run the Arduino, as I've read they are happy with between 9V & 12V - but wouldn't want to risk blowing the unit if connected to 12V?

I find this confusing.

Are you talking about the power to keep the Arduino working or the power for the LED lights?

If you are talking about the power to keep the Arduino working then my suggestion is to power the Arduino from a 12v lead-acid battery that is constantly trickle-charged from the mains. If you put a diode between the battery and the charger (so the battery cannot back-feed to the charger) then if the Arduino monitors the voltage from the charger upstream of the diode it can detect when the mains power fails. (Obviously you need a voltage divider to drop the charger voltage below the 5v that the Arduino uses).

Having said all that I wonder why you don't use the LEDs all the time to illuminate your plants from batteries that are charged from the mains. That way there would be no need for any changeover system?

...R

Run a charger to the battery and run a relay off the mains . When the relay drops out , use it’s normally closed contact to switch on the lights .

No need for Arduino

Paul_KD7HB:
To be really honest, I would use one or more UPS to solve your problem and it could be installed next week. Whereas your Arduino project will take you 6 months or more to get all the bugs out.

Paul

I could do this... UPS's with a 220V timer connected behind each one. But I thought this would make an interesting project, and would be awesome for when it's done... perhaps I was a bit overzealous with this then. :frowning:

Robin2:
I find this confusing.

Are you talking about the power to keep the Arduino working or the power for the LED lights?

If you are talking about the power to keep the Arduino working then my suggestion is to power the Arduino from a 12v lead-acid battery that is constantly trickle-charged from the mains. If you put a diode between the battery and the charger (so the battery cannot back-feed to the charger) then if the Arduino monitors the voltage from the charger upstream of the diode it can detect when the mains power fails. (Obviously you need a voltage divider to drop the charger voltage below the 5v that the Arduino uses).

Having said all that I wonder why you don't use the LEDs all the time to illuminate your plants from batteries that are charged from the mains. That way there would be no need for any changeover system?

...R

I am referring to keeping the Arduino going. As for the LEDs, Like I said in my initial post, I have high power LEDs as the main lights, they draw around 130W each (3x) and keeping them running for 2.5 hours a few times a day, on battery, is going to break the bank... in excess of R12 000 (+/- $700 U.S.) per unit - which is way out of my budget as horticulture is a hobby and not my main source of income (I'm in I.T.).

hammy:
Run a charger to the battery and run a relay off the mains . When the relay drops out , use it’s normally closed contact to switch on the lights .

No need for Arduino

Like I said, it only needs to cut over at certain times of day - e.g. if the power goes out after 11pm and before 5am, I only need to run fans off 12V, if it goes out between 5am and 11pm, I need to run the LED strip lights and fans - so there is some trickery involved, not just a simple, one goes off, kick in scenario... then a simple UPS will do the trick, but looking at Paul's reply, that might be the easiest option. A UPS with a double plug, one with a timer, one without and two 24W 12V DC adapters to run 1x set of LED strips & 1x set of 120mm PC fans for intake and exhaust.

But thanks for all the comments guys, I'd still like a high tech solution (as I like tinkering - may very well blow something up in the process, but hey... all in the name of fun and learning :stuck_out_tongue: ), perhaps start with a single unit and then manually switch over to 12V as my wife is a full time stay at home mommy, so she can hopefully assist when our baby isn't keeping her busy to flip the switches to battery for me, which hopefully won't stress out the plants too much, and with COVID-19 lurking about, I doubt we'll be traveling any time soon.

whdii:
As for the LEDs, Like I said in my initial post, I have high power LEDs as the main lights, they draw around 130W each (3x) and keeping them running for 2.5 hours a few times a day, on battery, is going to break the bank (in excess of R12 000 (+/- $700 U.S.) per unit - which is way out of my budget as horticulture is a hobby and not my main source of income (I'm in I.T.).

I don't understand that. Why would it cost more to run the LEDs from a battery that is charged from the mains compared to running them directly off the mains?

...R

Robin2:
I don't understand that. Why would it cost more to run the LEDs from a battery that is charged from the mains compared to running them directly off the mains?

...R

130W per light... I have 3 lights... that's a total of 390W (excluding fans for humidity control) - so let's say to keep all 3 units going I need 450W of constant power for 2.5 hours every 5 hours for 18 hours a day... That's A LOT of juice required in terms of battery power supplied at 220V (the drivers run off 110V or 220V - Meanwell HLG-150s).

Hope that clears it up, otherwise I'm confused as to why you're confused. :stuck_out_tongue:

whdii:
That's A LOT of juice required in terms of battery power supplied at 220V (the drivers run off 110V or 220V - Meanwell HLG-150s).

Do you mean that it would be too expensive to have the required battery capacity and the inverters to go from 12v to 220v?

In my Reply #6 I was actually thinking of you using the "12V 5630 SMD LED strips" all the time rather than using the 220v lamps.

...R

Robin2:
Do you mean that it would be too expensive to have the required battery capacity and the inverters to go from 12v to 220v?

In my Reply #6 I was actually thinking of you using the "12V 5630 SMD LED strips" all the time rather than using the 220v lamps.

...R

My idea was cheap 12V 12Ah batteries (with chargers) to go straight to the 12V LED strips & 12V fans with Arduino controlling when and how, etc. Which would've worked out to a guestimated +/- R5000.

Yes, a big Inverter UPS system (multiple 12V batteries with inverter to produce around 450W on 220V) would be ideal, but as stated, that system would set me back close on R36 000 to run all my equipment on battery for 2.5 hours at a time a couple of times per day - that's excluding installation costs and as this isn't my main source of income, i.e. there is no ROI, I can't justify spending this much on what is essentially a "hobby" I'm very passionate about.

The total Photosynthetically active radiation (PAR) output of the 12V LED strips, are a FRACTION of the Luminus CMX-32 Gen4 at 20W for the two strips vs 130W (also a MASSIVE amount of light output for the wattaage on high power/high efficiency COB LEDs).

The point of this exercise is merely to keep a fair amount of light on the plants during loadshedding as to not stress them out, which has massive negative effects during flowering which can cause a plethora of issues, such as seeds forming and plants turning hermaphrodites whereby they grow male and female flowers.

whdii:
The total Photosynthetically active radiation (PAR) output of the 12V LED strips, are a FRACTION of the Luminus CMX-32 Gen4 at 20W for the two strips vs 130W (also a MASSIVE amount of light output for the wattaage on high power/high efficiency COB LEDs).

The point of this exercise is merely to keep a fair amount of light on the plants during loadshedding as to not stress them out, which has massive negative effects during flowering which can cause a plethora of issues, such as seeds forming and plants turning hermaphrodites whereby they grow male and female flowers.

Thanks for the explanation.

By the way, what are you growing - marijuana?

I always think of South Africa as a country of free sunshine.

...R

Robin2:
Thanks for the explanation.

By the way, what are you growing - marijuana?

I always think of South Africa as a country of free sunshine.

...R

Awesome man, not a problem, thanks for taking the time to reply. :slight_smile:

Yes, you are correct sir (or m'am)... I grow my own cannabis indoors (not at the moment though... I've actually taken a break from smoking since the 9th of December 2019 - the day before my first child was born), but the medicinal/spiritual benefits this wonderful plant has had on my (and my wife's) life is nothing other than amazing (helps with back pain and tension headaches, stress and insomnia, anxiety attacks [I was on something similar to prozac for MANY years], my general "calmness" during the day-to-day, even whilst not medicated [I don't smoke at work, only in the privacy of my home after hours] just general quality of life improvements has been a blessing.

I also never grew anything before I attempted to grow indoor cannabis and it was a life changing experience which helped me turn my life around as I battled with alcohol abuse, borderline Satanic lifestyle (used to lose control and get into fights and crash cars and had a very, VERY bad view on God and religion as a whole due to the company I kept and type of music I considered my gospel).

I actually found/turned to God (as a newlyborn Christian) from being an Atheist (again borderline anti-Christ/satanist) for most my adult life as well, and have made a complete 180° in terms of who I was and who I am now. :slight_smile: My outlook on life is so much different, which I am really grateful for... only thanks to God's grace in the end.

South Africa is a lovely place... despite some of the racial, political and economical challenges we face here, it's not too bad and we can survive and have a fairly decent quality of life.

Anyhow, all the personal stuffs out the way... thanks again to all for replies and help - Should I still decide to give this setup a bash, I'll be sure to come share it here.

I actually found a local chap on 420sa.co.za who did something very similar and will get in touch with him to find out what he did and how it's working out for him.