Afternoon all, This is my setup for automated greenhouse watering. But I am having some trouble with the 5v relays. (The relays I’m using are https://www.ebay.co.uk/itm/221890132279)
The system is fed off solar batteries and runs through the charge controller. I have the green LED which lights in the setup() function of the board. My reasoning is, if the solar battery runs out and then recharges (i.e the board restarts) then that light will illuminate to tell me that has happened, I have a red switch next to this LED that once pressed it turns the LED off, just to confirm I am aware that power has been lost at some stage, the LED shouldn’t light again until power is lost or the board is reset.
This part of the program works. However, if I connect the pins leading to the relay I have an issue where if the relay switches power then the LED will go off when it’s not meant to.
Things I have tried:
I have tried this with the 12V load disconnected, and the program works as it should, only when it is switching the 12V I have issues.
I have a separate 5v dc powering the relay side of the board jd-vcc which is stepped down from the 12v. The relays vcc and inputs are switched from the Uno which is running from the solar controllers onboard USB port
Input-pullup is selected on the reset switch so It shouldn’t be an issue with floating voltage, although I haven’t tried using an external pullup resistor.
This is the simplified wiring diagram I have knocked together for the setup:
Like I said, I only have the issue when the relays are switching the 12V, if I leave that part disconnected then the sketch works as I want. If I connect the 12V then my pump runs and the flowers are wartered, its just the LED that turns off after the first switching cycle.
From a bit of google research this makes me think it is caused by electrical noise and a ‘flyback diode’ may be the answer. But before I dive down that rabbit hole I wanted to see what others opinions were. Am I on the right track?
Thanks for reading and apologies for the mess of wires in my first photo you’ve just spent 10mins tracing to try and figure out what I’m talking about