ESP32 + relay + integrated 230V AC power supply + sensors

1 relay board

In a home automation installation, we often need at the local level a set including sensors such as:

  • a presence detector,
  • a measurement of brightness
  • a temperature measurement

A relay as actuator

A microcontroller for processing

There are many relays on the market that can be controlled with their proprietary software, but it is difficult to add a sensor or sensor.

The modules presented here brings together an ESP32, 1 or 4 relays, and a power supply on the same board.

We find them at Aliexpress :

Benefits

  • ESP32 grouping, relay and power supply. This simplifies the wiring
  • Plate mounting holes
  • GPIO or IO inputs/outputs to be wired below or above, which is very practical
  • Numerous GND, 5V and 3.3V pins to connect sensors
Adaptator USB / Serial (Aliexpress)

Drawbacks

  • No USB access for first programming. A USB/TTL interface is required

Hardware (1 relay board)

One power supply 230V AC

4 connectors * 10 pins

3V3CLK5VGND
SD0SD1SD3CMD
IO15IO2IO13SD2
IO0IO4IO14IO12
IO16IO17IO26IO27
IO5IO18IO33IO25
IO19GNDIO35IO32
IO21RXD0SVNIO34
TXD0IO22ENSVP
IO23GNDGND3V3

Programming Connector

IO0GNDGNDRXTX5V

Others

RelyIO16
LED blueIO23
Button EN (Reset)EN
Button IO0IO0

Hardware (4 relays board)

3 possible power supply inputs :

  • 230V AC
  • 7V à 30V DC
  • 5V DC

4 connectors * 10 pins

3V3CLK5VGND
SD0SD1SD3CMD
G15G2G13SD2
G0G4G14G12
G16G17G26 (relay)G27
G5G18G33 (relay)G25 (relay)
G19GNDG35G32 (relay)
G21RXDSVNG34
TXD0G22ENSVP
G23 (LED )GNDGND3V3

Programming Connector

IO0GNDGNDRXTX5V

Others

Button EN (Reset)EN
Button IO0IO0
Pcb with 4 relays

Programming

To download code, you need to connect a USB / TTL interface with the power strap on 3V3.

For powering the ESP32 card during programming, we have 2 choices:

  • power through the serial adapter VCC output to the 5V of the ESP card (will only work for programming)
  • supply the ESP32 with 230V and no serial link VCC output to ESP32 card

To start programming, you must:

  • keep the IO0 button pressed
  • press EN (Reset)
  • release the 2 buttons

So the ESP waits for programming. After programming push again the EN button to reset and starts the new program.

Software

This module has the advantage of not being proprietary, you can put whatever you want there.

Arduino

With the Arduino IDE tool, you can develop your own code. Choose the ESP32 DEV module board. Details on getting started can be found here: https://f1atb.fr/programming-the-esp32-application-to-the-photovoltaic-router/

With the Arduino, integrate OTA mode into your code allowing you to update the code remotely via WIFI. So you will no longer need the USB/TTL interface

ESP Easy

Firmware allowing you to program ESP8266 or ESP32 and having the code for many sensors on the market. This simplifies programming
https://espeasy.readthedocs.io/en/latest/index.html

ESPHome

Powerful firmware allowing you to program your ESP32 with simple descriptions of interfaces, actions, events etc in a yaml file. Often associated with the Home Assistant home automation system.
https://esphome.io/index.html

Example of construction

Here an example grouping :

  • IR sensor
  • Luminosity sensor
  • Sensor (DHT22) for temperature and humidity
  • Buzzer as bell
  • Interface to an On/Off switch
  • Relay connected to the light

F1ATB André

Ham Radio - Home automation - Photovoltaic

You may also like...

2 Responses

  1. Norbert says:

    Hello,
    thanks for your blog. Restarting the board results in switching the relay. Do you have this too? Thanks!