Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

The issue of controlling the solenoid valve on ESP32 via relay in Home Assistant

retleh10

Newbie
Joined
Sep 27, 2023
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
13
Hi, I’m a beginner with ESP and I’m making an automatic irrigation system on ESP32 and I have a problem with the control of the solenoid valve. When I turn on the power on the relay (OKY3030 OKYSTAR), the red LED (power) turns on and the green +SW is on all the time. I found a simple code and use it in Home Assistant:

switch:
- platform: gpio
name: "Solenoid valve"
pin: GPIO26
restore_mode: ALWAYS_OFF

A button has been created in the HA panel that I should control the valve with, but the valve is on all the time.
When I use this button, the green LED dims slightly.
The 5V power supply is from the ESP (USB-C cable connected), and the solenoid valve is powered by 12V DC.
In the attachment I add a wiring diagram. Please help me to solve the problem.

schemat.png
 
Just a guess without seeing your code:
The 5V pin on the ESP32 board is the USB supply fed through a diode so it will generally be a little lower than 5V but it may not be able to supply enough current to operate the relay board. The green LED, whatever it is because it doesn't appear in your schematic, may be dimming because the power rail is dropping.

Brian.
 
Normally one also uses a diode across a solenoid to minimize inductive
spike due to solenoid coil. Help prevent relay arcing of contacts.

1695851796430.png


No diode in circuit :

1695853336939.png


Diode clamp across solenoid :

1695853426772.png




Regards, Dana.
 
Last edited:
We are yet missing a specification of the relays module input circuit. It's not necessarily compatible with 3.3 V logic level signal provided by ESP32.
--- Updated ---

You should also check if level sensor output can be directly connected to ESP32 without voltage reduction.
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top