Download PDF
      SAMOVAR                                  
×
Menu

How to connect a relay module correctly

 
 
You can connect 5-volt or 12-volt relay modules to the ESP32.
The module must have a JDVCC - VCC jumper.
 
Warning:
If the JDVCC-VCC jumper is missing, the module has no galvanic isolation of the power supply.  Using such modules is not recommended.
 
 
Circuit diagram, using one channel as an example:
To connect to the ESP32:

The upper connector in the diagram:
REQUIRED! Remove the jumper!
- Apply the negative of the relay power supply (-5 or -12 V, depending on the relays used) to the GND pin.
- The VCC pin is not used (that is, it is not connected to anything).
- Apply the positive of the relay power supply (+5 or +12 V) to the JDVCC pin.

The second connector:
- Connect VCC to +3.3 volts from the ESP32
- Connect IN1, IN2 to the required ESP32 output. For full galvanic isolation, you can leave the GND pin of this connector unconnected to the ESP32 GND pin.
 
This way the whole module, including the relays, is powered from a separate power supply (5 or 12 volts), and only 3.3 volts comes from Samovar: to resistor R2, the optocoupler LED and the indicator LED.
If the IN1 pin is at logic zero, the relay turns on; if it is at logic one (+3.3 volts), the relay turns off
 
Note.
Most relay modules are of the Low Level Trigger type (LLT, enabled by default). This means that to turn the relay on, the relay control input (IN1) must be at logic "0". When logic "1" is applied to the input (IN1), the relay turns off. Such relays are used when the microcontroller controls many devices, to reduce the microcontroller's heating and current consumption. They are also used in systems where the relay must be on when power is applied or "by default".
 
To control the module with logic "1" instead of logic "0":
- In the Samovar web interface, on the Settings – Other («Настройки – Прочие») tab, select the required module trigger level.
 
The rele1…rele4 fields set the level at which the relay turns on. For the module described here, which turns on with logic zero, set the level to LOW.
 
Warning. On the ESP32 DevKit, relay No. 2 (stirrer) is connected to GPIO15. This is a strapping pin that the hardware pulls high when the board is reset. A module that turns on with logic one will briefly switch on on this channel at every Samovar boot. For relay No. 2, use a module that turns on with a low level (LOW).