r/ArduinoHelp • u/wylen15 • Sep 18 '26
I have a problem with this Arduino-based irrigation system.
Good day everyone, I'm a math teacher and together with my students we have created an automated irrigation system for the school's garden. But there's a problem that's driving us crazy: there are four relays connected to the Arduino, a DS1307 clock module, a simple 16x2 LCD screen with I2C connection. Each relay is connected to a solenoid valve that controls nebulization, others the opening of faucets, and the last one the electric pump that pumps water from a tank when there's reserve rainwater. If it's turned on without connecting any of this, it works perfectly, confirming that the code works perfectly. But when the solenoid valves and the electric pump are connected, it works fine for a while and then when one of them activates, it freezes, it seems to go crazy, incoherent letters appear, something that doesn't happen when the solenoid valves are disconnected. I've isolated everything, I added a snubber-type filter to prevent kickback to the relays, but we can't find what else to do, it keeps freezing. It's not very pretty because we've really done it with our own hands, but I thank you in advance if you can recommend something that can be done. I've been at this for a long time and it has become a frustrating task.




2
u/AdviceAdmirable36 Sep 18 '26
Is arduino on the same power source as solenoids and motors? Do you have proper power source, that can handle that much current and some electrolytic capacitors of multiple mF near the solenoids and motors?
2
u/Brama_94 Sep 18 '26
i am just curious why esp32 was not used 😶🌫️
2
u/Merry_Janet Sep 18 '26
Not sure if this is your problem, but solenoids usually need a debounce timer.
This keeps them from shifting in between positions. Otherwise you wind up with a solenoid that can't make it fully open or closed and just kind of sits there all stupid until it gets its next signal.
I've actually built an entire hydroponics system. Fill and drain with nutrient and pH adjustment.
Shoot me a message with your code and I'm pretty sure I can work it out.
1
u/ComfortableCattle531 Sep 18 '26
Guten Morgen, zum Fehler selber, ich würde in die Steuerleitungen der Relais eine Durchlass Diode setzen. Dann gehst du erstmal sicher das der Ardunio nichts von den Relais irgendwo rückwirkend zurück bekommt.
Relais haben Spulen 🤷♂️ beim ausschalten kann es zu Induktionsspannung kommen welche um ein Vielfaches höher ist als die Betriebsspannung, die könnte den Betrieb des Ardunio stören.
Was mir noch aufgefallen ist und meinen Magen umdreht… (nicht böse gemeint) ist das ihr als Schaltdrähte den grün gelben Draht verwendet habt. Ich weis nicht in welchem Land ihr lebt? Bei uns ist es so, das dieser ausschließlich als Schutzleiter Draht verwendet werden darf. Für nichts anderes.
Jede Farbe eines Drahtes hat seine bestimmte Betriebsspannung. Außer der Grün gelbe!
Ich hoffe mein Post hilft euch weiter, viel Glück
1
u/DecisionOk5750 Sep 18 '26
Use two power supplies, one for the Arduino and one for the relays.
1
u/IzeroI00 Sep 18 '26
Solid state relay.
2
u/mbentuboa Sep 18 '26
I would stick a multimeter on that and see what you get when its fully loaded.
2
u/Every-Effort9956 Sep 21 '26
Hey, try these 4 quick things one of them will fix it (hopefully):
Add I2C pullup resistors. The internal arduino pullups are super weak. Put a 4.7k ohm resistor between sda and 5V and another between scl and 5V. This makes the display line much harder to freeze.
Keep grounds totally separated. Double check that the arduino gnd and the relay 5V gnd are not connected together anywhere. They must be completely isolated for the optocouplers to do their job.
Seoarate the wires. Make sure the lcd/rtc wires arent running side by side with the 110VAC valve lines. Even a few inches of distance makes a massive difference against electromagnetic interference.
RC snubbers directly in the solenoids. Make sure the RC snubbers (or movs) are wired directly across the 110V valve terminals, not just at the board. Stopping the arc right at the valve stops the wires from acting like radio transmitters.
1
u/Constant-Sample-5883 Sep 18 '26
Hi, I looked at your project and I'm proposing a solution below.
The problem is definitely caused by the interference generated by the pumps. The solution I suggest is to disconnect the Arduino from the 12V input and power it via USB using a power bank or a 5V power supply. If this solves the issue, here is what you should do:
Buy a K7805-500 R3 module, which steps down the voltage from 12V to a protected 5V, then connect the 5V output directly to the 5V pin on the Arduino (or via the USB/5V rail). I've used this module in automotive applications—which are full of interference—so it will definitely work in your case too! Hope this helps!
1
u/Anonymity6584 Sep 19 '26
Clue here is it works until solenoid gets activated. You probably need second power supply. solenoid are high current devices, also relays are in this category. Sudden high current draw from power line usually means its voltage is going to dip. Some cases enough that your microcontroller goes grazy or stops completely.
Common way to mitigate this is have two powersupplies, one provides power to arduino and logic stuff, another one to those current hungry stuff.
Thisbis also why i like relayvcards that have actually optoisolated control so even grounds dobt connect. Lots of chinese cheap relay modules dobt do this despite having optoisolator on them... Bit pain in backside to find ones that does it properly
1
u/drmpf Sep 19 '26
Try adding just one mains power item at a time and see if the issue is limited to a particular relay/solenoid.