Pi_MQTT_Softener_Sensor

Check out my blog post that describes how to build this project and how I designed it. https://codejockeyscorner.blogspot.com/2021/10/raspberry-pi-mqtt-water-softener-salt.html

Install Dependencies

More information here: http://www.steves-internet-guide.com/into-mqtt-python-client/

pip install paho-mqtt

Update script with MQTT host, user, and password

Update the following MQTT configuration values:

#MQTT constants
mqttBroker = "<% MQTT_HOST %>"
mqttTopic = "home/pi/softener"
mqttUser = "homeassistant"
mqttPassword = "<% MQTT_PASSWORD %>"

Update the sensor pins to match how you wired your sensor

#sensor constants
TRIG = 23
ECHO = 24

Update the following distances to match your specific brine tank measurements

#measurements constants
TANK_EMPTY_DISTANCE = 31 #inches
TANK_FULL_DISTANCE = 6 #inches
TANK_LOW_WATERMARK_DISTANCE = 25 #inches

Run script

python salt_monitor.py