Skip to Content

Case study · Water treatment · ESP32 PLC 42

Keep pH and chlorine in range with one ESP32 PLC 42.

pH and chlorine dosing, MQTT to a Panel PC, remote settings.

4analog sensors: pH and chlorine in each tank
3ON/OFF outputs: water pump and two dosing valves
1ESP32 PLC 42 runs the control loop
MQTTvalues to the Panel PC over Ethernet

A sensor reading is only a number.

The PLC turns it into the right dose.

Analog sensors read pH and chlorine in the untreated and the treated water tank. One ESP32 PLC 42 opens the dosing valves, regulates the dosing pump and sends every value over MQTT to a 10.1" Panel PC. The operators see the plant and change its settings from another location. This case describes a real station. We do not name the customer or the site. The goal was clear: an autonomous water treatment station with remote monitoring, remote configuration, and a design that is easy to copy to another site nearby. The customer chose an ESP32 PLC 42 because its programming platform is free and flexible. The PLC runs a program written in the Arduino IDE. The user interface and the database run on Node.js.

The challenge

Dose the right amount, with nobody standing next to the tank.

pH and chlorine change all the time. If you dose too little, the water is out of specification. If you dose too much, you waste chemicals. Your control system has to read the water, correct it, prove the result and show all of it to people who are not on site.

01

Two values, one dose

Analog sensors read pH and chlorine at a fixed interval. When a value leaves its range, the system must dose at once. Not when someone checks.

02

An unattended station

The customer wanted an autonomous station. Nobody stands next to the tanks, so the status and the settings must be available from another location.

03

Built to copy

The same design had to be easy to replicate in another area nearby. Same hardware, same program, a new site.

Proof at the outlet

Two more sensors in the treated water tank measure pH and chlorine again. You do not assume the dose was right. You measure it.

How it works

Two loops: dose the water, then prove it.

Move the sliders and press the buttons. The panels show the general pattern: what the PLC reads, what it switches and what the operators see. They are illustrative simulations. They do not show the program, the set points or the data of the installation.

Loop 1 · Dosing

Out of range? The PLC doses until the value is back.

Analog sensors in the untreated water tank read pH and chlorine at a fixed interval. The ESP32 PLC 42 compares each value with its range. When a value is out of range, the PLC opens the solenoid valve of that chemical and regulates the speed of the dosing pump. When the value is back in range, it closes the valve. You set the ranges on the Panel PC.

  • pH and chlorine sensors on analog inputs (4-20 mA or 0-10 V)
  • One ON/OFF output per dosing solenoid valve
  • Dosing pump speed regulated by the PLC (signal not published)
  • Water pump on an ON/OFF output, to the treated tank
pH 7.2Cl 1.0UNTREATED WATERESP32 PLC 42ClOFFpHOFFPOFF
7.2
1.00 mg/L
Dosing pump speed0 %
example: analog output 0 to 10 V
Chlorine valvepH valveWater pump

Example ranges: pH 6.5 to 8.5, chlorine 0.5 to 1.5 mg/L. The valve closes again at chlorine 0.8 mg/L or pH 7.0 to 8.0 (example hysteresis). Illustrative simulation. Example set points and scaled times. The real set points of the installation are not published.

Loop 2 · Proof and supervision

The treated tank confirms. The Panel PC shows it.

Two more sensors in the treated water tank measure pH and chlorine again. The ESP32 PLC 42 sends all values over MQTT on the Ethernet cable to the TouchBerry Pi 10.1" Panel PC. The operators see the plant there, and the database keeps every value. From the Panel PC they change the preset values, and the PLC doses to them.

  • Two sensors in the treated water tank confirm the result
  • MQTT over Ethernet between the PLC and the Panel PC
  • Status and settings available from another location
  • Every value stored: traceability of the treatment
ESP32 PLC 42MQTTPanel PC · plant overviewRawpH0RawCl0TreatedpH0TreatedCl0Cl set point0.5 mg/LRecords0
MeasurePublishShowAct

MQTT messages (example topics)

    Illustrative simulation. Example set points and scaled times. The real set points of the installation are not published.

    Related simulator: remote telemetry of a water network

    System architecture

    How does one ESP32 PLC 42 run a water treatment station?

    Four analog sensors go to the ESP32 PLC 42: pH and chlorine before and after the treatment. Three ON/OFF outputs drive the water pump and the two dosing solenoid valves. An Ethernet cable carries MQTT messages to the Panel PC. This diagram follows the original diagram of the case.

    Water treatment automation: pH and chlorine dosing with an ESP32 PLC 42 and a Raspberry Pi Panel PCUNTREATED WATERTREATED WATERChlorinepHChlorinepHESP32 PLC 424 analog inputs · 3 ON/OFF outputs4-20 mA / 0-10 V4-20 mA / 0-10 VON/OFFWater pumpON/OFFClCl valveON/OFFpHpH valveDosing pumpspeed signal:not publishedEthernet · MQTTPanel PCTouchBerry Pi 10.1"Node.jsinterface · databaseBased on the original diagram of the case. The dosing pump signal and the location of the Node.js application are not published.UNTREATED WATERpH · Chlorine4-20 mA / 0-10 VESP32 PLC 424 analog inputs3 ON/OFF outputsON/OFFClpHWater pumpCl valvepH valveDosing pumpspeed: signal not publishedTREATED WATERpH · Chlorine → PLCEthernet · MQTTPanel PC · TouchBerry Pi 10.1"Node.js: interface · databaseBased on the original diagram of the case.Dosing pump signal: not published.
    Sensor signals, 4-20 mA or 0-10 VDigital ON/OFF outputsEthernet · MQTTWater flow
    Signals and data
    SignalBetweenTypePurpose
    pH, raw waterBetweenpH sensor → ESP32 PLC 42TypeAnalog 4-20 mA / 0-10 VPurposeInput of the dosing loop
    Chlorine, raw waterBetweenChlorine sensor → ESP32 PLC 42TypeAnalog 4-20 mA / 0-10 VPurposeInput of the dosing loop
    pH and chlorine, treated waterBetween2 sensors → ESP32 PLC 42TypeAnalog 4-20 mA / 0-10 VPurposeConfirms the result of the treatment
    Chlorine dosingBetweenESP32 PLC 42 → solenoid valveTypeDigital ON/OFFPurposeAdds the chlorine product
    pH correctionBetweenESP32 PLC 42 → solenoid valveTypeDigital ON/OFFPurposeAdds the pH correction product
    Water pumpBetweenESP32 PLC 42 → pumpTypeDigital ON/OFFPurposeMoves water from the untreated to the treated tank
    Dosing pump speedBetweenESP32 PLC 42 → dosing pumpTypeExample: analog 0-10 VPurposeSets the dose rate. Signal not published
    Values and set pointsBetweenESP32 PLC 42 ↔ Panel PCTypeEthernet · MQTTPurposeDisplay, records and remote settings

    Why it works

    One controller for the loop. Open tools for the rest.

    Open and free to program

    Arduino IDE for the PLC, Node.js for the interface and the database. No licence fees, and you can change any part of the program.

    Room to grow

    This station uses 4 analog inputs and 3 ON/OFF outputs. The ESP32 PLC 42 has 26 inputs and 16 outputs, so you can add turbidity, tank levels or a second dosing line.

    Engineers from day one

    Our technical team supported the customer from the project definition to the commissioning. You get the same support for your plant.

    Hardware used

    One PLC on the DIN rail, one Panel PC in the plant.

    ESP32 PLC 42, industrial controller based on ESP32 with 42 I/O

    ESP32 PLC 42

    The controller of the station. It reads the four analog sensors, drives the two dosing solenoid valves and the water pump, regulates the dosing pump and publishes the values over MQTT. You program it in C++ with the Arduino IDE.

    Inputs
    26: 14 digital optoisolated, 12 analog/digital (0-10 V)
    Outputs
    16: 10 digital optoisolated, 6 analog/digital/PWM (0-10 V), 5 to 24 Vdc
    Network
    Ethernet 10/100 (RJ45), Wi-Fi 2.4 GHz, Bluetooth LE
    Serial
    RS-485, RS-232, TTL
    Power supply
    12 to 24 Vdc
    Mounting
    DIN rail TS35, IP20

    The analog inputs read 0-10 V. For a 4-20 mA sensor, add a shunt resistor or a signal converter. The outputs are optoisolated, without relays: a pump motor needs a contactor or an interface relay. The case does not publish its wiring. Check the ratings in the family datasheet.

    TouchBerry Pi Panel PC 10.1 inch with Raspberry Pi 4

    TouchBerry Pi Panel PC 10.1"

    The operator station in the plant. An industrial 10.1" Panel PC with a Raspberry Pi 4. It receives the values over MQTT, shows the state of the plant and sends the new set points to the PLC.

    Role
    Display, records and remote settings
    Screen
    10.1"
    Computer
    Raspberry Pi 4
    Link to the PLC
    Ethernet · MQTT

    The case names a Touchberry Pi 10.1" Panel PC and does not publish the exact version. The image and the link show the current TouchBerry Pi Panel PC 10.1" FLEX.

    Questions about this case

    Which water values does the system measure?

    pH and chlorine, first in the untreated water tank and again in the treated water tank, with four analog sensors (4-20 mA or 0-10 V). The case also lists turbidity among the values the operators can see.

    How does the PLC decide when to dose?

    It compares each reading with an allowed range. When a value is out of range, it opens the solenoid valve of that chemical and regulates the speed of the dosing pump until the value is back in range. The real ranges are not published. The numbers on this page are examples.

    Is this an Arduino PLC or an ESP32 PLC?

    The controller is an ESP32 PLC 42. You program it with the Arduino IDE. Same IDE and same language (C++), with the Industrial Shields ESP32 boards package. Most of your code and skills carry over.

    How do the operators see the plant from another location?

    The PLC sends the values over MQTT on Ethernet to a TouchBerry Pi 10.1" Panel PC. A Node.js application handles the user interface and the database. The case does not publish how the remote access is set up. A VPN or a broker with TLS and passwords are common options.

    Can I add turbidity, tank levels or a second dosing line?

    Yes. This station uses 4 analog inputs and 3 ON/OFF outputs. The ESP32 PLC 42 has 26 inputs, 12 of them analog (0-10 V), and 16 outputs. Count your signals first, then add the sensors to the same program.

    Can the same design be copied to another site?

    Yes. Easy replication in another area nearby was one of the goals of the customer. You reuse the PLC program, the Panel PC application and the wiring layout, and you set the ranges for each site.

    Download the case study

    4-page PDF with the challenge, the logic, the architecture and the hardware. No form required.

    Similar project?

    Tell us your water and your chemicals. An engineer will answer.

    Tell us what you treat, which values you measure (pH, chlorine, turbidity, levels) and how you dose. We will tell you which controller fits and how to connect your sensors, valves and pumps.

    • You get an answer from our technical team
    • I/O count and sizing for your station
    • Arduino, ESP32 or Raspberry Pi based PLCs