Introduction #
Switching a pump on and off is easy. Protecting it is the harder part. A pump that runs dry loses its cooling and lubrication, and its seals and bearings can fail within minutes. A good controller therefore does more than close a relay: it watches the pump while it runs, stops it when something goes wrong, and keeps a record of how long it has worked.
This tutorial builds an ESP32 pump controller on the NORVI X-CPU-ESPS3-X1 with the NORVI X-R8 relay module. Relay 1 of the X-R8 switches the 230 V AC coil of a small motor contactor, and relay 2 switches a motor-ON indicator lamp that follows it. An RS485 pressure transmitter on the pump discharge pipe is read over Modbus RTU. If the pressure stays below an adjustable limit for 2 seconds while the motor is running, the pump is stopped and locked in a fault state until an operator resets it.
What you will need #
- NORVI X-CPU-ESPS3-X1 controller and NORVI X-R8 relay module
- 24 V DC supply (1 A or higher)
- Motor contactor for the pump with a 230 V AC coil, an RC snubber or varistor for the coil, a small fuse or breaker for the coil circuit, and an indicator lamp
- RS485 Modbus pressure transmitter (QDW90A-YK-1 RS485 version, gauge pressure) and a 24 V supply for it
- Shielded twisted-pair cable for RS485, a multimeter, and a reference pressure gauge for commissioning
- USB cable and the Arduino IDE with ESP32 board support
System Architecture #
The system is a short chain from the pressure sensor to the pump motor, with the controller in the middle making the decisions.

Signal flow #
Sensing. The transmitter on the discharge pipe measures gauge pressure and answers Modbus RTU requests over RS485.
Processing. The ESP32-S3 polls the sensor every 500 ms, scales and smooths the reading, and runs the state machine: STOPPED, RUNNING and FAULT.
Switching. The X1 writes to the PCA9538 I/O expander on the X-R8 over I²C (address 0x73). Relay 1 closes the contactor coil circuit and relay 2 lights the motor-ON lamp at the same moment.
Hardware and Wiring #
- Power off the system.
- Mount the X-R8 on the DIN rail beside the X-CPU and seat it on the expansion port.
- Set DIP 1 OFF and DIP 2 OFF for address 0x73.
- Wire the coil supply through COM1 and NO1 of relay 1 to coil terminal A1, and the neutral to A2.
- Wire the indicator lamp supply through COM2 and NO2 of relay 2.
- Wire the pressure transmitter: 24 V supply to its power pins, and RS485 A and B to the X1 RS485 terminals.
- Connect the 24 V DC supply to the X-CPU power terminals, then power up.

Switching a Contactor and a Lamp with Relay Outputs #
The relay switches only the low-current coil of a contactor, and the contactor’s heavy contacts carry the motor current. The motor current must not be switched directly through an X-R8 relay.

Run-Dry Protection #
While the pump runs and moves water, the discharge pressure sits at a normal value. If the water supply fails, the pressure collapses. The controller compares the filtered pressure with RUN_DRY_PRESSURE and stops the pump if the pressure stays below it.

#define PRESSURE_UNIT "bar"
static const float RUN_DRY_PRESSURE = 0.50f; // trip limit, in PRESSURE_UNITArduino Code for the Pump Controller #
The full sketch (sketch.ino) is in the pump-control project, together with its README.
Explore technical files and available resources.
View on GitHub ↗
Troubleshooting #
Safety. Disconnect all power before wiring and let a qualified electrician install the system. This controller is an equipment-protection interlock and is not a safety function. Do not exceed the relay contact rating, including for the lamp.
Conclusion #
You now have a pump controller that switches a contactor through a relay on the X-R8, reads a Modbus pressure transmitter, and stops the pump with a latched fault when the pressure collapses while the motor runs. It lights a motor-ON lamp on relay 2 that always matches the contactor and the display.