Skip to content

Soi13/Modbus_slave_device

Repository files navigation

HVAC Filter Clogging Detection System

ESP32 + Sensirion SDP810-500 Differential Pressure Sensor
Modbus TCP Slave + MQTT Publisher for Home Assistant


📌 Overview

This project provides a practical solution for detecting HVAC air filter clogging using an ESP32 microcontroller and a Sensirion SDP810-500 differential pressure sensor. By measuring the pressure before and after the air filter, the system determines the pressure drop (ΔP). As the filter becomes dirty, air flow decreases → pressure drop increases → the system detects clogging.

This project exposes measured data via two simultaneous interfaces:

Modbus TCP Slave — allowing any BAS/BMS controller to poll the device
MQTT Publisher — reporting data to Home Assistant or any MQTT broker

The ESP32 works as:

  • I²C master for the SDP810-500 sensor
  • Modbus slave device on port 502
  • MQTT sensor publisher
  • Wi-Fi client

You can test Modbus functionality using Modpoll or any Modbus TCP client.



Circuit

Picture of schema



Picture of schema1 Picture of schema1

🛠 Features

✅ Differential Pressure Monitoring

  • Uses SDP810-500 for accurate low-range differential pressure readings
  • Calculates pressure difference and outputs values in Pascals
  • Includes CRC validation according to Sensirion protocol

✅ Modbus TCP Slave

  • Slave address: 1
  • Default port: 502
  • Exposes holding registers containing sensor data
  • Pollable from software like Modpoll, PLCs, BAS controllers, etc.

Registers map:

Register Meaning Notes
40001 (index 0) Differential Pressure (Pa) raw_dp/60 scaling
40002 (index 1) Temperature (°C) raw_temp/200 scaling

✅ MQTT Publishing

Publishes real-time pressure values to a Home Assistant MQTT broker:
Topic: homeassistant/sensor/pressure

✅ Wi-Fi Support

  • Connects to local network
  • Automatically reconnects if connection drops
  • MQTT starts only after Wi-Fi IP assignment


🧰 Hardware Requirements

  • ESP32 development board
  • Sensirion SDP810-500PA differential pressure sensor
  • 3.3V power supply
  • HVAC duct with two pressure sampling points
  • Tubing for connecting sensor ports

Wiring (ESP32 → SDP810-500)

ESP32 Pin SDP810 Pin Description
3.3V VDD Power
GND GND Ground
GPIO21 SDA I²C Data
GPIO22 SCL I²C Clock


🔧 Software & Libraries

This project is written fully in ESP-IDF, using the following components:
  • esp_wifi — Wi-Fi STA mode
  • esp_event, esp_netif
  • esp_modbus_slave — official ESP-IDF Modbus controller
  • esp_mqtt_client — MQTT client
  • driver/i2c.h — I²C driver for the SDP810 sensor
  • CRC8 implementation (Sensirion polynomial 0x31)


📡 Data Flow

1. Sensor Acquisition

ESP32 sends continuous measurement command to SDP810 using I²C.
Data is read every 2 seconds and validated with CRC checks.

2. Modbus Publishing

Converted measurements are stored in the holding registers array.
Modbus controllers poll the registers over TCP.

3. MQTT Publishing

Pressure value is formatted as a string and sent to the MQTT broker.
Compatible with Home Assistant auto-discovery.

Picture of schema1

Picture of schema2



🧪 Testing Modbus with Modpoll

Example command:

modpoll -m tcp -t 4:int -r 1 -c 2 192.168.x.x

This reads registers 40001–40002 from the ESP32.

Picture of schema1



▶️ How It Works in HVAC Systems

  1. Pressure tube A connects to duct before the filter
  2. Pressure tube B connects to duct after the filter
  3. Clean filter → low pressure difference
  4. Dirty filter → ΔP rises significantly
  5. ESP32 reads ΔP and makes it available to:
    • Home Assistant
    • Any Modbus poller
  6. Automations can notify you when ΔP exceeds thresholds

About

Slave Modbus device based on ESP32

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published