El relé de la bomba en un ESP32 hace clic al arrancar y el interruptor de la placa muestra "On" cuando no lo está
Traducido del English por IA ·
Bomba de riego en una pequeña granja, conmutada por un ESP32 mediante uno de esos módulos de relé azules de 5 V (optoacoplador, puente JD-VCC). El ESP32 escucha v1/rpc/req/+ para pump.set con {"on": true|false} y responde en v1/rpc/res/{id}. En la placa he puesto una tarjeta Switch que envía pump.set.Dos problemas:
- Cada vez que el ESP32 arranca (corte de energía o tras una actualización de firmware), el relé hace clic durante unos medio segundo. El contactor de la bomba se activa brevemente. No es bueno.
- Ayer el ESP32 estaba desconectado (Wi-Fi caído en el cobertizo), alguien cambió el interruptor de la placa y mostró «On» por un momento. El operario supuso que la bomba estaba funcionando.
La entrada del relé está en el GPIO 2. El módulo se alimenta desde el pin de 5 V del ESP32 (fuente USB).
Irrigation pump on a small farm, switched by an ESP32 through one of those blue 5 V relay modules (optocoupler, JD-VCC jumper). The ESP32 listens on v1/rpc/req/+ for pump.set with {"on": true|false} and answers on v1/rpc/res/{id}. On the board I put a Switch card that sends pump.set.
Two problems:
- Every time the ESP32 boots (power blip, or after a firmware update) the relay clicks on for about half a second. The pump contactor pulls in briefly. Not great.
- Yesterday the ESP32 was offline (Wi-Fi down at the shed), somebody flipped the switch on the board, and it showed «On» for a moment. The operator assumed the pump was running.
Relay input is on GPIO 2. Module powered from the ESP32’s 5 V pin (USB supply).
Traducido del English por IA ·
El GPIO 2 es un pin de strapping de arranque: cambia de estado durante el boot. Probablemente sea ese su clic.
GPIO 2 is a boot strapping pin, it toggles during boot. That’s probably your click.
Traducido del English por IA ·
Ah. ¿Hay algún pin que se mantenga en silencio durante el arranque?
Ah. Any pin that stays quiet at boot?
Traducido del English por IA ·
Hice la misma configuración de bomba para un proyecto de la universidad y me afectaron los dos problemas.Relé: muévelo al GPIO 26 o 27, que se mantienen en silencio durante el arranque. La mayoría de estos módulos azules son active LOW, así que establece el nivel antes de cambiar el pin a salida, o si no obtendrás igualmente un pulso corto:
digitalWrite(26, HIGH); // relay off for an active-low module
pinMode(26, OUTPUT);
Quita también el jumper JD-VCC y alimenta la bobina del relé desde su propio 5 V, manteniendo solo VCC/IN/GND desde el ESP. Una bobina alimentada desde el 5 V USB del ESP puede provocar una caída de tensión cuando se activa.Placa: el interruptor muestra lo que asocias como su estado actual. Haz que el firmware informe {"pump_state": 1} después de cambiar realmente, y asocia el campo Current state de la tarjeta Switch a pump_state. Entonces la tarjeta mostrará el estado que reporte el dispositivo cuando llegue, no el que se pulsó. Deja activado «Disable the control when The reading is old» (es el valor predeterminado) y marca también «The state is unknown», para que nadie pueda cambiarlo mientras el ESP esté desconectado. Mantén activado «Ask before running» para una bomba, que también es el valor predeterminado. Ajustes de la tarjeta: Control cards
I did the same pump setup for a uni project, both issues bit me.
Relay: move it to GPIO 26 or 27, they stay quiet through boot. Most of these blue modules are active LOW, so set the level before switching the pin to output, otherwise you get a short pulse anyway:
digitalWrite(26, HIGH); // relay off for an active-low module
pinMode(26, OUTPUT);
Also take the JD-VCC jumper off and feed the relay coil from its own 5 V, keep only VCC/IN/GND from the ESP. A coil on the ESP’s USB 5 V can brown it out when it pulls in.
Board: the switch shows what you bind as its current state. Have the firmware report {"pump_state": 1} after it actually switched, and bind the Switch card’s Current state slot to pump_state. The card then shows the device’s reported state once it arrives, not what was clicked. Leave «Disable the control when The reading is old» on (it’s the default), and also tick «The state is unknown», so nobody can flip it while the ESP is offline. Keep «Ask before running» on for a pump, that’s the default too. Card settings: Control cards
Traducido del English por IA ·
Me cambié a GPIO 26 con el truco de HIGH antes de OUTPUT, sin más clics en 20 reinicios. Vinculé el interruptor a pump_state y el firmware informa después de conmutar. Tenía la opción del valor anterior, pero no la del estado desconocido, así que la tarjeta seguía siendo pulsable justo después de un reinicio. Ahora están marcadas las dos.
Moved to GPIO 26 with the HIGH-before-OUTPUT trick, no more click across 20 reboots. Bound the switch to pump_state and the firmware reports after switching. I had the old-reading option but not the unknown-state one, so the card was still clickable right after a restart. Both ticked now.
- Debes estar registrado para responder a este debate.
Únete a la conversación
Inicia sesión para preguntar y responder, dar me gusta a las publicaciones útiles y marcar la respuesta que resolvió tu problema. Cada aportación suma puntos y niveles.

