Rough estimate, check with your seller: prices vary by shop and period.
Project goal
You will know whether your water softener’s salt bin is full, half full or needs a refill, without opening the lid every time. Four approaches are covered, from the simplest (visual mark and calendar reminder) to an ESP32 — a small electronic board with Wi-Fi — plus a distance sensor, ESPHome software that prepares its program, and Home Assistant, the free software that gathers your connected devices, for a phone alert.
Why build it
On many softeners the opaque lid completely hides the salt level: you only discover an empty bin when you open it. That is the author’s (Emmanuel Sauvage) situation: the bin was nearly empty, and it only showed after opening. An approximate level (full / half / refill) is enough to buy pellets in time and avoid hard water returning.
Useful terms for this project: ESP32 (small Wi-Fi board) · ESPHome (prepares the board’s program) · GPIO (the board’s pins) · OTA (update without a USB cable)
Prerequisites
- A water softener with a salt-pellet bin you can open.
- For connected options: a running Home Assistant, and for Zigbee a coordinator (USB stick or compatible hub).
- For the ESP32 build: ESPHome installed, 2.4 GHz Wi-Fi within range, and a socket for a 5 V USB supply.
Installation photos



Four solutions, from simplest to most DIY
A — No electronics: visual gauge and calendar reminder
Difficulty Beginner · Budget Free
Open the lid and mark three heights (permanent marker or plastic ruler): full, half, refill. Note how many kilos you add and, over a few weeks, estimate your pace (water hardness and usage). Create a phone calendar reminder or a time-only Home Assistant automation (“every X days, check the salt”).
Installation No wiring. Check the level at each reminder and adjust the interval after two or three refill cycles.
Phone alert Calendar reminder or timer notification — no automatic measurement.
B — Commercial Zigbee or Wi-Fi tank level sensor
Difficulty Beginner to intermediate · Budget about $40–100 depending on model and coordinator (check with the seller)
Real ultrasonic tank-level sensors exist, for example Tuya / EPTTECH TLC2206 (Zigbee TLC2206-ZB, supported in Zigbee2MQTT with a percentage). They measure distance to a surface and expose a percentage. They are designed for liquids; on salt pellets the surface is uneven, so treat readings as approximate (full / half / low). Another simple path used with Home Assistant: a wired Zigbee leak sensor at the bottom — it only reports “too low” when brine reaches the probe, not a true percentage.
Installation Fix the head under the lid above the salt, set installation height in the app or Zigbee2MQTT, pair it, then add a Home Assistant alert.
Phone alert Low threshold → mobile notification (liquid_level_percent or liquid_state).
C — Scale / weighing
Difficulty Intermediate · Budget variable; often impractical under a softener
Weighing the bin or salt bags sounds logical, but a floor-standing softener tied into plumbing is a poor fit for a continuous scale: brine water and resin weight confuse the reading, and the wet/salty environment damages load cells (HX711 type). A kitchen scale when you add bags helps track consumption, not a reliable automatic alert.
Installation Not recommended as permanent monitoring under the bin. Weigh only when adding pellets to estimate your pace.
Phone alert No reliable automatic alert in this context.
D — ESP32 + waterproof ultrasonic JSN-SR04T (or ToF) + ESPHome
Difficulty Intermediate · Budget about $25–60 depending on seller (ESP32 + probe + enclosure)
An ESP32 measures distance to the pellets with a JSN-SR04T (waterproof ultrasonic probe on a cable; the module’s PCB is not waterproof) or, alternatively, a VL53L0X / VL53L1X ToF sensor (Time of Flight: light-based distance, shorter range, often better for small bins). ESPHome turns distance into a percentage and full / half / refill. A classic HC-SR04 has no waterproof probe and corrodes quickly here.
Installation Follow the detailed build below: wiring, flash, empty_m / full_m calibration, then the Home Assistant automation.
Phone alert binary_sensor “Salt needs refill” → notification (YAML provided).
Where to place the sensor
Mount the sensor under the lid, above the pellet bin, aiming at the salt surface. Avoid the control valve (display), the blue resin bottle and the brine well (vertical tube). Keep the ESP32, USB supply and ultrasonic driver board outside the wet zone, linked by a cable.
Diagrams
Parts list
This ESP32 board is the base for every project in the series. ESPHome also works with other ESP32 boards: the board-choice guide helps you compare them. Which ESP32 board to choose?
Suggested board
ESP32-C6-DevKitC-1
- Wi-Fi 6, Bluetooth 5, Zigbee and Thread (at hardware level)
- Supported by ESPHome (ESP-IDF framework)
- USB-C for flashing and power
Watch-outs
- 2.4 GHz Wi-Fi only
- Use a USB cable that carries data
Main components
| Item | Quantity | Role and precautions |
|---|---|---|
| ESP32-C6-DevKitC-1 | 1 | Wi-Fi control board (see the box above). |
| JSN-SR04T (waterproof ultrasonic probe) | 1 | Cable probe aimed at the salt; keep the module PCB outside the bin. Alternative: VL53L0X or VL53L1X ToF under the lid. |
| 1 kΩ and 2 kΩ resistors | 1 of each | Voltage divider on Echo (5 V → ~3.3 V) into GPIO18. |
| Plastic enclosure + cable gland | 1 | Keeps the ESP32 and module board dry; optional conformal coating on solder joints. |
Small parts
| Item | Quantity | Role and precautions |
|---|---|---|
| USB-C data cable | 1 | For flashing and power. Charge-only cables do not carry data. |
| USB 5 V power supply (CE/UKCA-marked charger) | 1 | At least 1 A for the board alone; more if peripherals draw power from it. |
| Dupont jumper wires (male-female and female-female) | 1 | One mixed pack covers every prototype. |
| Assorted 1/4 W resistors | 1 | Handy for pull-ups (4.7 kΩ to 10 kΩ) and protection (330 Ω). |
| Heat-shrink tubing | 1 | Insulates solder joints and splices; avoid tape in a permanent build. |
| Vented plastic or 3D-printed enclosure | 1 | Protects the board; leave a cable gland and vents if the sensor measures air. |
Amazon links are affiliate links: the site may earn a commission at no extra cost to you.
Step-by-step build
Step 1. Prepare ESPHome and create the device
- In Home Assistant, open the ESPHome Device Builder add-on (see the tutorial “Install ESPHome in Home Assistant (Device Builder)”). ESPHome is the software that turns a simple settings file into the program for your ESP32 board, without you having to write any code.
- Open “Secrets” (top right): this file keeps your passwords apart, so you can share your configurations without revealing them. Check that wifi_ssid (the name of your Wi-Fi network), wifi_password, api_encryption_key (the key that encrypts the link with Home Assistant), ota_password (for updates without a cable) and ap_password (for the board’s fallback Wi-Fi network) exist, and add any missing line. A valid API key is a long 32-byte string encoded in base64, which you can generate with “openssl rand -base64 32”.
- Click “New device”, name it “niveau-sel-adoucisseur”, pick ESP32-C6, skip the flash for now, then replace the file content with the YAML from this page (“Edit”). YAML is a configuration file written in plain text: it describes, line by line, what the board must do.
What you should see: The file opens in the editor with syntax highlighting and no red underline.
Check: The “Validate” action (⋮ menu) answers “Configuration is valid”.
Step 2. Locate the measurement zone in the bin
- Open the lid and note: control valve, resin bottle, brine well, pellet surface.
- Pick a point under the lid that aims only at the pellets, with no obstacle.
- Measure roughly “sensor → full salt” and “sensor → empty / bottom”: these become full_m and empty_m.
What you should see: The open-bin photo and placement diagram match your unit.
Check: No tube or resin bottle crosses the planned beam.
Step 3. Wire the JSN-SR04T with 3.3 V protection
- USB unplugged. Connect module VCC to ESP32 5V/VIN, GND to GND, TRIG to GPIO5.
- On Echo: 1 kΩ in series to GPIO18, and 2 kΩ from GPIO18 to GND. Never feed 5 V Echo straight into an ESP32 GPIO.
- Only the waterproof probe goes under the lid; the module PCB and ESP32 stay in the dry enclosure outside.
What you should see: The probe cable leaves the bin without blocking the lid.
Check: Polarity checked; no bare wire in the salt.
Step 4. Flash the board and add it to Home Assistant
- Connect the board to your computer with the USB-C data cable: “flashing” means writing the program into the board’s memory, and this first write must be done over a cable. The board can already be wired or sitting on the breadboard, but any external peripheral with its own power supply must stay switched off.
- In ESPHome click “Install”, then “Plug into this computer” (Chrome or Edge over HTTPS) or “Manual download” and upload the file with ESPHome Web (web.esphome.io). If the port is missing, follow the flashing tutorial.
- After the reboot open Settings → Devices & services: the ESPHome device is discovered; click “Configure” and paste the API encryption key.
What you should see: The “Logs” show the Wi-Fi connection and then “Successfully connected to Home Assistant”.
Check: The device appears under Devices & services → ESPHome with its entities; later updates need no cable and go over Wi-Fi (this is OTA, “Over The Air”).
Step 5. Calibrate empty_m / full_m and the states
- After flashing, read “Salt distance” nearly empty, then after a refill (or with a card at full height).
- Edit empty_m and full_m in the YAML, Validate, then update over OTA (no cable).
- Check that “Salt state” shows full, half or refill steadily for a few minutes.
What you should see: The percentage rises when you add pellets.
Check: “Salt needs refill” turns ON below the 33 % threshold.
ESPHome code (YAML)
YAML is a configuration file written in plain text: it tells ESPHome what the board must do. Paste this one into ESPHome after creating the device. It targets an ESP32-C6 board; values to personalise are marked with “CHANGE” comments.
esphome:
name: niveau-sel-adoucisseur
friendly_name: Softener salt level
esp32:
board: esp32-c6-devkitc-1 # XIAO ESP32C6: use board: seeed_xiao_esp32c6
framework:
type: esp-idf # required for ESP32-C6
logger: # serial logs, also visible over Wi-Fi
api:
encryption:
key: !secret api_encryption_key
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid # 2.4 GHz network only
password: !secret wifi_password
ap: # fallback hotspot if the Wi-Fi is unreachable
ssid: "niveau-sel-adoucisseur fallback"
password: !secret ap_password
captive_portal:
# Ultrasonic JSN-SR04T (waterproof probe). Keep the driver board dry outside the salt bin.
# Echo is 5 V when the module is powered at 5 V: use a 1 kΩ / 2 kΩ divider into GPIO18.
# CHANGE the empty_m / full_m values after calibration on YOUR softener.
sensor:
- platform: ultrasonic
trigger_pin: GPIO5
echo_pin: GPIO18
name: "Salt distance"
id: salt_distance
update_interval: 60s
pulse_time: 10us
timeout: 2.0m
unit_of_measurement: "m"
accuracy_decimals: 3
filters:
- median:
window_size: 5
send_every: 1
- clamp:
min_value: 0.20 # JSN-SR04T blind zone ~20 cm
max_value: 1.20
- platform: template
name: "Salt level percent"
id: salt_percent
unit_of_measurement: "%"
device_class: battery
accuracy_decimals: 0
update_interval: 60s
lambda: |-
// CHANGE after measuring your tank with salt empty then full
const float empty_m = 0.55; // sensor-to-salt when nearly empty
const float full_m = 0.25; // sensor-to-salt when full (stay above blind zone)
float d = id(salt_distance).state;
if (isnan(d) || empty_m <= full_m) return {};
float pct = (empty_m - d) / (empty_m - full_m) * 100.0f;
if (pct < 0.0f) pct = 0.0f;
if (pct > 100.0f) pct = 100.0f;
return pct;
- platform: wifi_signal
name: "WiFi signal"
update_interval: 120s
entity_category: diagnostic
text_sensor:
- platform: template
name: "Salt state"
id: salt_state
icon: mdi:water-percent
update_interval: 60s
lambda: |-
float p = id(salt_percent).state;
if (isnan(p)) return {"unknown"};
if (p >= 66.0f) return {"full"}; // plein
if (p >= 33.0f) return {"half"}; // à moitié
return {"refill"}; // à recharger
binary_sensor:
- platform: template
name: "Salt needs refill"
device_class: problem
lambda: |-
return id(salt_state).state == "refill";
YAML comments are in English, as in the ESPHome documentation. This code has not been run on your hardware: use “Validate” before flashing and adjust pins and names.
Home Assistant integration
- Entities “Salt level percent”, “Salt state” and “Salt needs refill” appear under ESPHome devices.
- Add a gauge or entity card to the dashboard for a quick glance.
- Use the automation below (replace notify.mobile_app_YOUR_PHONE) to get a refill reminder.
Sample automation (salt reorder reminder)
alias: Softener — order salt
description: Phone alert when the salt bin needs a refill
triggers:
- trigger: state
entity_id:
- binary_sensor.niveau_sel_adoucisseur_salt_needs_refill
from: "off"
to: "on"
for:
hours: 0
minutes: 15
seconds: 0
conditions: []
actions:
- action: notify.mobile_app_YOUR_PHONE
data:
title: Water softener
message: "Salt is low. Buy salt pellets and refill the bin."
mode: singleCommon problems and troubleshooting
| Symptom | Fix |
|---|---|
| Frozen or wild distance | Probe mis-aimed, blind zone (< 20 cm), or Echo without divider. Move the sensor back, check 1 kΩ/2 kΩ wiring, increase the median window. |
| Jumpy percentage | Uneven pellet surface: expected. Rely on full/half/refill states; set update_interval to 120 s. |
| Fast corrosion | Module PCB or ESP32 was inside the bin. Move all electronics out; leave only the waterproof probe; use an enclosure + gland. |
| No notification | Check the real entity_id under Settings → Entities, and that the Companion app is linked to notify. |
FAQ
Zigbee, Wi-Fi, ESP32, ESPHome, ToF, MQTT, GPIO — what do they mean?
Zigbee is a low-power radio network for sensors (needs a coordinator). Wi-Fi is the home wireless network (2.4 GHz for the ESP32). An ESP32 is a small programmable board with Wi-Fi. ESPHome builds its program from a YAML file. ToF (Time of Flight) measures distance with light. MQTT is a messaging protocol often used with Zigbee2MQTT. GPIO means the board’s input/output pins.
Can I use a classic HC-SR04?
Not recommended here: no waterproof probe, fast corrosion in salt and moisture. Prefer JSN-SR04T or a protected ToF.
Will the percentage be exact?
No: pellets are not a flat surface. The useful goal is full / half / refill, calibrated on your bin.
Do I need a Zigbee coordinator for the ESP32 option?
No: the ESP32 talks Wi-Fi straight to Home Assistant via ESPHome. A coordinator is only needed for commercial Zigbee sensors.
Related tutorials
These step-by-step guides explain the gestures common to every project in the series.
- Install ESPHome in Home Assistant (Device Builder)Install the add-on, prepare your passwords (secrets) and create the first device
- Flash an ESP32 with ESPHome (USB, drivers, boot mode)First upload over USB, CP210x and CH340 drivers, boot mode
- ESP32 wiring basics: GPIO, 3.3 V and pull-upsWhich pins to avoid, 3.3 V versus 5 V, pull-up resistors and common ground
- ESPHome OTA updates: flash without a cableUpdate the board without a cable, OTA password and recovery if something goes wrong
Other ESP32 projects
- Energy meter (pulse output)
- Automatic irrigation
- Temperature and humidity sensor
- See all ESP32 projects
