CLO2-100 con Arduino, ESP32, Raspberry Pi y Python
Cómo conectar ClO2-100 Sensor de dióxido de cloro a su propio microcontrolador o computadora y obtener lecturas por RS485 Modbus RTU. Las tablas son las de la ficha técnica, y los dos ejemplos de código se ejecutan contra la trama de ejemplo de la ficha técnica antes de publicar esta página.
Página del producto Ficha técnica (PDF) Ficha técnica (Markdown) Sketch de Arduino (.ino) Script de Python (.py)
Conexión de CLO2-100
La sonda es un dispositivo RS485, por lo que necesita un transceptor entre ella y su placa. En una computadora o una Raspberry Pi es un adaptador USB a RS485. En un microcontrolador es un módulo tipo MAX485 en un puerto serial por hardware. Alimente la sonda con una fuente dentro del rango de tensión de la tabla y conecte su tierra a la tierra del transceptor.
| Wire Color | Function | Description |
|---|---|---|
| Red | V+ | Power Supply (9-27V DC) |
| Black | GND | Power Ground |
| Green | RS485-A | Data+ (T/R+) |
| White | RS485-B | Data- (T/R-) |
Ejemplo en Python (Raspberry Pi, Linux, macOS, Windows)
El script solo necesita pyserial. Arma la solicitud Modbus por sí mismo, verifica el CRC de la respuesta e imprime una lectura cada cinco segundos. En Windows, pase el puerto COM como argumento.
#!/usr/bin/env python3
"""Read the Agrinovo CLO2-100 over RS485 Modbus RTU.
Works on a Raspberry Pi or any computer with a USB to RS485 adapter.
Install the serial library once: pip install pyserial
Run: python3 clo2_100.py /dev/ttyUSB0
"""
import struct
import sys
import time
import serial
PORT = sys.argv[1] if len(sys.argv) > 1 else "/dev/ttyUSB0"
ADDRESS = 0x01 # the sensor's Modbus address
def crc16(frame: bytes) -> bytes:
crc = 0xFFFF
for byte in frame:
crc ^= byte
for _ in range(8):
crc = (crc >> 1) ^ 0xA001 if crc & 1 else crc >> 1
return struct.pack("<H", crc)
def read_registers(port, address, function, start, count):
request = struct.pack(">BBHH", address, function, start, count)
port.reset_input_buffer()
port.write(request + crc16(request))
reply = port.read(5 + 2 * count)
if len(reply) >= 5 and reply[1] == function | 0x80:
raise IOError(f"sensor returned Modbus error {reply[2]}")
if len(reply) != 5 + 2 * count or crc16(reply[:-2]) != reply[-2:]:
raise IOError("no valid reply from the sensor")
return reply[3:-2]
def read_probe(port):
data = read_registers(port, ADDRESS, 0x03, 0x0000, 10)
return {
"chlorine_dioxide": struct.unpack(">f", data[2:4] + data[0:2])[0], # mg/L
"electrode_signal": struct.unpack(">f", data[10:12] + data[8:10])[0], # mV
"temperature": struct.unpack(">f", data[18:20] + data[16:18])[0], # °C
}
if __name__ == "__main__":
with serial.Serial(PORT, 9600, bytesize=8, parity="N", stopbits=1, timeout=1) as port:
while True:
print(read_probe(port))
time.sleep(5) Ejemplo para Arduino (Uno, Mega, ESP32, ESP8266, MKR, Pico)
El sketch usa la biblioteca Agrinovo: en el Arduino IDE abra Sketch > Include Library > Manage Libraries e instale "Agrinovo". La biblioteca elige el puerto serial según la placa, y los pines están al inicio de AgrinovoDefaultPort.h. DE y RE del transceptor van a un mismo pin de salida.
// Agrinovo CLO2-100 chlorine dioxide probe
// Prints chlorine dioxide, electrode signal and temperature every 5 seconds.
//
// Sensor cable
// Red supply +, 9-27 V DC
// Black supply ground, joined to the board's ground
// Green RS485 A
// White RS485 B
//
// The board talks to the sensor through an RS485 transceiver (MAX485 or
// similar). AgrinovoDefaultPort.h lists the serial pins used on each board.
//
// https://agrinovo.io/products/sensors/aqua/ion-selective/cl02-100-chloride-dioxide-probe/
#include <Agrinovo.h>
#include <AgrinovoDefaultPort.h>
const int DE_PIN = 4; // transceiver DE and RE, tied together
AgrinovoBus bus(AGRINOVO_PORT, DE_PIN);
AgrinovoCLO2100 probe(bus); // Modbus address 1
void setup() {
Serial.begin(115200);
agrinovoPortBegin(9600);
bus.begin();
}
void loop() {
if (probe.read()) {
Serial.print("Chlorine dioxide: ");
Serial.print(probe.chlorineDioxide(), 2);
Serial.println(" mg/L");
Serial.print("Electrode signal: ");
Serial.print(probe.electrodeSignal(), 2);
Serial.println(" mV");
Serial.print("Temperature: ");
Serial.print(probe.temperature(), 1);
Serial.println(" °C");
} else {
Serial.println(probe.errorText());
}
delay(5000);
} Qué leen los ejemplos
Ambos ejemplos envían una sola solicitud, función 0x03, 10 registros desde 0x0000, y decodifican estos valores:
| Valor | Unidad | Registro | Codificación |
|---|---|---|---|
| Chlorine dioxide | mg/L | 0x0000 | Flotante de 32 bits en dos registros, palabra baja primero |
| Electrode signal | mV | 0x0004 | Flotante de 32 bits en dos registros, palabra baja primero |
| Temperature | °C | 0x0008 | Flotante de 32 bits en dos registros, palabra baja primero |
Otras herramientas Modbus
La misma solicitud funciona desde cualquier maestro Modbus RTU: pymodbus, minimalmodbus, Node-RED, LabVIEW, un PLC o un registrador de datos de terceros con puerto Modbus. Use la configuración serial, el código de función y las direcciones de registro indicados arriba.
Registro de datos sin escribir código
El controlador Omni Genesis lee CLO2-100 y envía las lecturas a la nube de Agrinovo por la red celular, donde se pueden exportar o leer mediante la API de la nube.
Referencia de la ficha técnica
Specifications
| Parameter | Specification |
|---|---|
| Measurement Principle | Electrochemical electrode |
| Chlorine Dioxide Range | 0.00-20.00 mg/L |
| Resolution | 0.01 mg/L |
| Accuracy | ±0.1 mg/L |
| Temperature Range | -10.0 to 110.0 °C |
| Temperature Resolution | 0.1 °C |
| Temperature Accuracy | ±0.5 °C |
| Temperature Element | TH10K thermistor |
| Temperature Compensation | Automatic / Manual |
| Communication | RS485, Modbus-RTU |
| Isolation | 2500 Vrms |
| Supply Voltage | 9-27 VDC |
| Power Consumption | ≤0.5W |
| Housing Material | PPS |
| Mounting Thread | M20×1.5 or G3/4 |
Communication Settings
| Parameter | Value |
|---|---|
| Protocol | Modbus-RTU |
| Baud Rate | 9600 bps (configurable) |
| Data Bits | 8 |
| Parity | None |
| Stop Bits | 1 |
| Default Address | 0x01 |
Supported baud rates: 1200, 2400, 4800, 9600, 19200 bps.
Register Map
Measurement values are available in two formats. Function 0x03 returns IEEE-754 float32 (each value spans 2 registers, transmitted low word first). Function 0x04 returns scaled 16-bit integers, each followed by a register carrying the decimal places and unit code.
Measurement Registers (Function 0x03 / 0x04 read)
| Address | Description | Range | Data Type |
|---|---|---|---|
| 0x0000-0x0001 | Chlorine Dioxide (ClO₂) | 0.00-20.00 mg/L | Float32 |
| 0x0004-0x0005 | Electrode Signal | -10.00 to 40.00 mV | Float32 |
| 0x0008-0x0009 | Temperature | -10.0 to 110.0 °C | Float32 |
Configuration Registers (Function 0x03 read / 0x06 write)
| Address | Description | Default | Range / Notes |
|---|---|---|---|
| 0x0019 | Calibration Status | Not calibrated | Bit0 = zero point, Bit1 = slope point |
| 0x001A | Electrode Offset | 0.00 mg/L | ±0.30 mg/L (value ×100) |
| 0x001C | Electrode Slope | 100.0% | 30.0-300.0% (value ×10) |
| 0x001E | Device Address | 1 | 1-247 (255 = broadcast) |
| 0x001F | Baud Rate Code | 3 (9600) | 0=1200, 1=2400, 2=4800, 3=9600, 4=19200 |
| 0x0020 | Temp Compensation Type | 1 (auto) | 0 = manual, 1 = automatic |
| 0x0021 | Temp Setpoint / Offset | 25.0 °C / 0.0 °C | value ×10 (see note) |
| 0x0023 | pH Compensation Switch | 1 (on) | 0 = off, 1 = on |
| 0x0024 | pH Compensation Value | 4.00 pH | 0.00-14.00 pH (value ×100) |
| 0x002D | Filter Coefficient | - | 1-16 |
Register 0x0021 holds the manual temperature setpoint when 0x0020 = manual, or the temperature offset when 0x0020 = automatic. Example: a stored value of 250 means 25.0 °C; to set 10.0 °C write 100 (0x0064).
Information Registers (Function 0x03 read, 0x06 write where applicable)
| Address | Description | Notes |
|---|---|---|
| 0x0040 | Work Mode | 0x10 = measure, 0x50 = setting, 0x60 = calibration |
| 0x0041 | Mode Parameter | Mode-specific |
| 0x0043 | Calibration Control / Status | Write standard value to calibrate (see Section 8) |
| 0x0046 | Software Version | Read only |
| 0x0047 | Hardware Version | Read only |
| 0x0048-0x0049 | Serial Number | Read only |
Reading Data
Read Chlorine Dioxide value (Float32 from 0x0000-0x0001)
Read 2 registers starting at 0x0000:
Request: 01 03 00 00 00 02 C4 0B
Response: 01 03 04 E7 2F 41 1F 8C D6
Decoding (word-swap example):
Received bytes E7 2F 41 1F → reorder the two 16-bit words to 41 1F E7 2F → IEEE-754 float = 9.99 mg/L
Read all measurement values
Read 10 registers from 0x0000:
Request: 01 03 00 00 00 0A C5 CD
Returns Chlorine Dioxide, Electrode Signal, and Temperature as float32 values.
Integer format (Function 0x04)
Function 0x04 returns each value as a scaled integer followed by its decimal/unit register. For example, a value of 998 with 2 decimal places represents 9.98 mg/L; a temperature value of 250 with 1 decimal place represents 25.0 °C.
Address and Baud Rate Configuration
Change Address (0x01 → 0x02)
Write the new address to register 0x001E:
01 06 00 1E 00 02 68 0D
Change Baud Rate (to 2400)
Write the baud rate code to register 0x001F:
01 06 00 1F 00 01 79 CC
Broadcast Discovery
Use address 0xFF (255) with only one device connected.
Calibration
The sensor supports two-point calibration: a slope point and a zero point. Standard solutions are used to calibrate a newly installed sensor or to re-calibrate periodically. Calibration is performed by writing to the calibration control register 0x0043 with function 0x06.
Procedure
- Immerse the electrode in the standard solution.
- Wait for the reading to stabilize.
- Write the calibration command to register 0x0043.
- Read register 0x0043 to check the result:
- 0 = calibration successful (returned to measure mode)
- 1 = calibrating (re-read status shortly)
- 2 = no valid standard value received within 180s
- 3 = signal could not stabilize or value out of range within 180s
- 4 = electrode performance (slope or offset) out of allowed range
- Repeat for the second point.
Slope Point
Write the standard solution value as an integer scaled ×100. For a 5.00 mg/L standard, write 500 (0x01F4):
01 06 00 43 01 F4 78 09
Zero Point
Write the zero point code 0x0001:
01 06 00 43 00 01 B9 DE
Clear Calibration
Write 0x7FFF to register 0x0043 to clear all calibration data:
01 06 00 43 7F FF 18 6E
Factory Reset
A factory reset clears calibration data and restores temperature compensation settings to default. It requires two commands.
Enter Setting Mode
Write 0x0050 to the work mode register 0x0040:
01 06 00 40 00 50 88 22
Send Reset Command
Write 0x7FFF to the mode parameter register 0x0041:
01 06 00 41 7F FF B9 AE
The sensor restores defaults and restarts.
Revision History
| Rev | Date | Changes |
|---|---|---|
| 1.0 | June 2026 | Initial release |
| 1.1 | August 2026 | Layout revision |
| 1.2 | October 2026 | New layout |
Contact
Agrinovo, https://agrinovo.io/products, [email protected], +972 54 688 8148 (direct / WhatsApp). Specifications subject to change without notice.
¿Preguntas sobre el cableado o el protocolo?
Cuéntenos qué placa o registrador usa y qué necesita medir.