ESP32 Developed a multi-stage water filter monitoring system using ESP32 microcontroller that tracks filter status and reports data to a central server for real-time monitoring.
Proxmox VE The heart of my home lab environment
OpenWrt Death by Networking
This project involves using an ESP32 microcontroller to monitor the status of a multi-stage water filtration system. The need for this project arose from me not wanting to waste money on filters that were still good. The recomendataion for replaceing the filters was 6 months for some and 1 year for others. However, these recommendations are based on average usage of a family of four.
Using an ESP32 microcontroller and TDS sensors placed at various stages of the filtration process, the system measures the TDS levels of the water before and after each filter stage. The values are then sent to Home Assistant to display and log the values over time.
The code for the ESP32 was pushed using esphome yaml configuration. I have included the code below for reference.
esphome:
name: "tds-sensor"
friendly_name: Water Filter
min_version: 2024.11.0
esp32:
board: esp32dev
framework:
type: esp-idf
# To Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
wifi:
ssid: "WifiSSID"
password: "HiddenPassword"
sensor:
- platform: adc
pin: GPIO34
name: "Water TDS Post Stage 1"
update_interval: 600s
unit_of_measurement: "ppm"
filters:
# Smooth out noise with an exponential moving average
- exponential_moving_average:
alpha: 0.1 # Smaller alpha = more smoothing
send_every: 1
# Convert ADC raw value to millivolts and apply the derived formula
- lambda: return round(((0.4071 * (x * 1000)) - 7.1881));
# Clamp values to avoid negative PPM readings
- lambda: if (x < 0) return 0; else return x;
- platform: adc
pin: GPIO35
name: "Water TDS Post RO"
update_interval: 600s
unit_of_measurement: "ppm"
filters:
# Smooth out noise with an exponential moving average
- exponential_moving_average:
alpha: 0.1 # Smaller alpha = more smoothing
send_every: 1
# Convert ADC raw value to millivolts and apply the derived formula
# This formula is based on calibration with TDS meter readings
- lambda: return round(((0.4071 * (x * 1000)) - 7.1881));
# Clamp values to avoid negative PPM readings
- lambda: if (x < 0) return 0; else return x;
Below are some photos of the project in various stages of development and deployment.
Through this project, I gained hands-on experience with microcontroller programming, sensor integration, and data visualization. One mistake I made initally was using a static IP address for the ESP32. This caused issues when I changed subnets and had to reconfigure the IP address. Using DHCP with a reserved address would have been a better approach so I dont have to crawl underneath my sink to reconfigure the device.