Relay
A switch the program controls, to turn on and off things with their own power supply: a pump, a lamp, a fan.
The test program
Test this part on its own before you build the rest: if it works alone, the rest is built on something you know works.
10 RELAY on
20 WAIT 1000
30 RELAY off
40 WAIT 1000
50 GOTO 10What you should see: The relay clicks every second and its LED turns on and off. Try it with nothing connected to its terminals.
▶ Try it in the IDEWhat to buy
- 1-channel 5V relay module (for a pump, fan or low-voltage lamp; never the 230 V mains)The relay just SWITCHES your device. Power the pump/lamp from its OWN supply, never from the board pin. A 1-channel 5V opto-isolated module is plenty.
How to wire it to an ESP32-S3
- IN → ESP32-S3: GPIO42
- VCC → ESP32-S3: 5V
- GND → ESP32-S3: GNDCommon ground: this link is mandatory.
- COM · NO → your devicePower the device (pump, fan, lamp) from its own low-voltage supply (batteries or 5-12 V), never the 230 V mains
If it does not work
- The board restarts by itself
- The load or the relay's coil disturbs the board's power. Power the pump or lamp from its own supply, never from the board, and use an opto-isolated module.
- The program runs but nothing happens
- The module gets no 5 V, or the signal is on the wrong pin. VCC to 5 V, GND to GND, IN to the pin shown in the diagram.
Which boards it works on
- ESP32-S3 Freenove: yes
- Nordic nRF54LM20 DK: yes
- Arduino UNO R4 WiFi: yes