- System Overview
- Hardware Requirements
- File Structure
- Fresh Raspberry Pi OS Installation
- System Configuration
- Software Installation
- Hardware Setup
- Configuration Files
- Home Assistant Integration
- GUI Features
- Starting the System
- Troubleshooting
This control system manages:
- Snowmelt System: Glycol circulation through heated slab with heat exchanger
- DHW System: Domestic hot water recirculation
- Eco Mode: Reduced temperature setpoints during scheduled hours
- Equipment operates in three modes: Auto, On, Off
- Auto mode follows system logic; On/Off provides manual override
- Temperature-based control with high setpoint and delta T (differential)
- Shutdown Delay Timer: Schedule automatic snowmelt shutdown (15-min increments, up to 24 hours)
- Setpoint Persistence: User-modified setpoints are saved to disk and survive reboots (debounced to minimize SD card writes)
- 1-Wire Self-Healing: Automatic detection and recovery from 1-Wire bus failures — if all sensors become unresponsive, the system reloads kernel modules to restore communication without requiring a manual restart
- Raspberry Pi 4B (2GB+ RAM recommended)
- MicroSD card (16GB+ recommended)
- Power supply (official RPi 5V 3A recommended)
- Waveshare 7" touchscreen (1024x600)
- Oono 8-channel SPST relay HAT
- 5x DS18B20 1-Wire temperature sensors
- 4.7kΩ pull-up resistor (if not built into sensor cables)
- Jumper wires
- Terminal blocks (for relay connections)
- 18-22 AWG wire for relay outputs
/home/pi/snowmelt_control/
├── main.py # Main application entry point
├── sensors.py # Temperature sensor management (async background reads)
├── relays.py # Relay control module
├── control.py # Control logic engine
├── mqtt_integration.py # Home Assistant MQTT integration
├── gui.py # PyQt5 touchscreen interface
├── setpoint_persistence.py # Saves/loads setpoints to survive reboots
├── config.yaml # Main configuration file
├── secrets.yaml # MQTT credentials (not in git)
├── setpoints_state.yaml # Persisted setpoints (auto-generated, not in git)
├── requirements.txt # Python dependencies
├── install.sh # Automated installation script
├── discover_sensors.py # Sensor discovery utility
├── test_relays.py # Relay testing utility
├── snowmelt.service # Systemd service (with GUI)
├── snowmelt-headless.service # Systemd service (headless)
├── __init__.py # Python package marker
├── README.md # This documentation
└── venv/ # Python virtual environment (created during install)
/var/log/snowmelt/
└── control.log # Application log file
/etc/systemd/system/
├── snowmelt.service # Installed service file
└── snowmelt-headless.service
-
Download Raspberry Pi Imager from: https://www.raspberrypi.com/software/
-
Insert your microSD card into your computer
-
Open Raspberry Pi Imager and configure:
- OS: Raspberry Pi OS (64-bit) with Desktop
- Storage: Select your microSD card
- Click the gear icon for advanced options:
- Set hostname:
snowmelt-control - Enable SSH with password authentication
- Set username:
pi - Set password:
<your-secure-password> - Configure WiFi (if using wireless)
- Set locale/timezone
- Set hostname:
-
Click Write and wait for completion
- Insert the microSD card into the Raspberry Pi
- Connect the Waveshare touchscreen
- Connect keyboard/mouse (temporarily)
- Connect to your network (Ethernet recommended)
- Power on the Raspberry Pi
Open a terminal (or SSH in) and run:
# Update package lists
sudo apt update
# Upgrade all packages
sudo apt upgrade -y
# Install essential tools
sudo apt install -y git nano htop
# Reboot to apply any kernel updates
sudo reboot# Edit the boot configuration
sudo nano /boot/firmware/config.txtAdd these lines at the end of the file:
# 1-Wire temperature sensors on GPIO 23
dtoverlay=w1-gpio,gpiopin=23
# Disable screen blanking (for touchscreen kiosk)
consoleblank=0Save and exit (Ctrl+X, Y, Enter)
# Add 1-Wire modules to load at boot
echo "w1-gpio" | sudo tee -a /etc/modules
echo "w1-therm" | sudo tee -a /etc/modules
# Load modules immediately
sudo modprobe w1-gpio
sudo modprobe w1-therm# Add pi user to required groups
sudo usermod -a -G gpio,i2c,spi pi# For the desktop environment
sudo nano /etc/xdg/lxsession/LXDE-pi/autostartAdd this line:
@xset s off
@xset -dpms
@xset s noblank
For the official 7" Waveshare display, you may need:
sudo nano /boot/firmware/config.txtAdd:
# Waveshare 7" display settings (1024x600)
hdmi_group=2
hdmi_mode=87
hdmi_cvt=1024 600 60 6 0 0 0
hdmi_drive=1Option A: Clone from Git repository (if available)
git clone https://github.com/JohnTheHobbit/snowmelt-control.gitOption B: Copy files manually
Copy all the project files to /home/pi/snowmelt_control/
# Install required system packages
# Note: Package names for Raspberry Pi OS Bookworm (Debian 12)
sudo apt install -y \
python3 \
python3-pip \
python3-venv \
python3-pyqt5 \
python3-dev \
python3-libgpiod \
gpiod \
fonts-dejavu \
libopenblas-dev \
libopenjp2-7 \
libtiff6 \
i2c-toolsNote for older Raspberry Pi OS versions (Bullseye/Buster): If you're running an older OS version, use these package names instead:
libgpiod2instead ofgpiodlibatlas-base-devinstead oflibopenblas-devlibtiff5instead oflibtiff6
cd /home/pi/snowmelt_control
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Upgrade pip
pip install --upgrade pip# Install from requirements file
pip install paho-mqtt PyYAML
# Install GPIO library - use rpi-lgpio for Pi 5 compatibility
# rpi-lgpio is a drop-in replacement for RPi.GPIO that works on all Pi models
pip install rpi-lgpio
# Link system PyQt5 to virtual environment
SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
ln -sf /usr/lib/python3/dist-packages/PyQt5 "$SITE_PACKAGES/"
ln -sf /usr/lib/python3/dist-packages/sip* "$SITE_PACKAGES/"Note:
rpi-lgpioprovides the same API asRPi.GPIObut uses the modernlibgpiodbackend, making it compatible with Raspberry Pi 5 and Bookworm OS.
sudo mkdir -p /var/log/snowmelt
sudo chown pi:pi /var/log/snowmelt
sudo chmod 755 /var/log/snowmeltchmod +x main.py
chmod +x discover_sensors.py
chmod +x test_relays.py
chmod +x install.shDS18B20 1-Wire sensors use 3 wires:
- Red (VCC): Connect to 3.3V (Pin 1) or 5V (Pin 2)
- Black (GND): Connect to Ground (Pin 6, 9, 14, 20, 25, 30, 34, or 39)
- Yellow/White (Data): Connect to GPIO 23 (Pin 16)
Important: All 5 sensors share the same 3 wires (parallel connection)
Add a 4.7kΩ pull-up resistor between Data and VCC (if not built into sensor cables)
Wiring Diagram:
3.3V (Pin 1) ─────┬─────────────┬─── Red wire (all sensors)
│ │
[4.7kΩ] │
│ │
GPIO 23 (Pin 16) ─┴─────────────┼─── Yellow/Data wire (all sensors)
│
GND (Pin 6) ────────────────────┴─── Black wire (all sensors)
- Power off the Raspberry Pi
- Carefully align the Oono 8-relay HAT with the GPIO header
- Press down firmly to seat the HAT
- Power on and verify the relay LEDs are off
Connect your equipment through the relay terminals:
- Relay 1: Glycol Pump
- Relay 2: Primary Pump
- Relay 3: Bypass Valve
- Relay 4: DHW Recirculation Pump
- Relays 5-8: Available for future use
Warning: Ensure all high-voltage wiring is done by a qualified electrician!
cd /home/pi/snowmelt_control
source venv/bin/activate
# Run sensor discovery
python discover_sensors.pyExpected output:
Found 5 sensor(s):
Address Temperature Status
------------------------------------------------------------
28-2605d446635a 95.23 °F OK
28-0881d44609e5 104.56 °F OK
28-2401000088aa 138.42 °F OK
28-240100009c9a 119.87 °F OK
28-30b6d44610ba 117.34 °F OK
# Test all relays sequentially
python test_relays.py --test-all
# Or test individually
python test_relays.py --test 1
# Interactive mode
python test_relays.py --interactiveEdit config.yaml and verify the sensor addresses match your hardware:
nano config.yamlUpdate the sensor section with addresses from the discovery output:
sensors:
glycol_return:
address: "28-2605d446635a" # White tape
name: "Glycol Return"
label: "White tape"
glycol_supply:
address: "28-0881d44609e5" # Orange tape
name: "Glycol Supply"
label: "Orange tape"
heat_exchanger_in:
address: "28-2401000088aa" # Green tape
name: "Heat Exchanger In"
label: "Green tape"
heat_exchanger_out:
address: "28-240100009c9a" # Yellow tape
name: "Heat Exchanger Out"
label: "Yellow tape"
dhw_tank:
address: "28-30b6d44610ba" # Blue tape
name: "DHW Tank"
label: "Blue tape"nano secrets.yamlUpdate with your MQTT broker credentials:
mqtt:
broker: "192.168.1.201"
port: 1883
username: "your_mqtt_username"
password: "your_mqtt_password"
base_topic: "snowmelt"
discovery_prefix: "homeassistant"Important: Set proper permissions on secrets file:
chmod 600 secrets.yamlEdit config.yaml to adjust default setpoints:
setpoints:
glycol:
high_temp: 110.0 # Target glycol return temperature (°F)
delta_t: 15.0 # Start heating when temp drops this much
dhw:
high_temp: 125.0 # DHW tank high setpoint (°F)
delta_t: 10.0 # Start recirculation delta
eco:
high_temp: 115.0 # Eco mode DHW setpoint (°F)
delta_t: 15.0 # Eco mode delta
eco_schedule:
enabled: true
start_time: "22:00" # 10:00 PM
end_time: "06:00" # 6:00 AMEnsure MQTT is configured in Home Assistant. Add to configuration.yaml:
mqtt:
broker: 192.168.1.201
port: 1883
username: !secret mqtt_username
password: !secret mqtt_password
discovery: true
discovery_prefix: homeassistantThe system automatically creates these Home Assistant entities via MQTT discovery:
Sensors:
sensor.snowmelt_glycol_return_temperaturesensor.snowmelt_glycol_supply_temperaturesensor.snowmelt_heat_exchanger_insensor.snowmelt_heat_exchanger_outsensor.snowmelt_dhw_tank_temperaturesensor.snowmelt_heat_exchanger_delta_tsensor.snowmelt_snowmelt_statesensor.snowmelt_dhw_statesensor.snowmelt_eco_mode_active
Binary Sensors (Equipment State):
binary_sensor.snowmelt_glycol_pump_statebinary_sensor.snowmelt_primary_pump_statebinary_sensor.snowmelt_bypass_valve_statebinary_sensor.snowmelt_dhw_recirculation_pump_state
Selects (Equipment Mode):
select.snowmelt_glycol_pump_modeselect.snowmelt_primary_pump_modeselect.snowmelt_bypass_valve_modeselect.snowmelt_dhw_recirculation_pump_mode
Switches (System Enable):
switch.snowmelt_snowmelt_systemswitch.snowmelt_dhw_systemswitch.snowmelt_eco_mode
Numbers (Setpoints):
number.snowmelt_glycol_high_setpointnumber.snowmelt_glycol_delta_tnumber.snowmelt_dhw_high_setpointnumber.snowmelt_dhw_delta_tnumber.snowmelt_eco_high_setpointnumber.snowmelt_eco_delta_t
The touchscreen GUI (1024x600) provides three tabs:
- System Enable Buttons: Toggle Snowmelt, DHW, and Eco Mode on/off
- Shutdown Delay Timer: Set a countdown timer (15-min increments) to automatically disable the snowmelt system
- Status Indicators: Shows current state of each system (Idle, Heating, Bypass, Error)
- Temperature Displays: Grouped logically by Glycol Loop, Heat Exchanger (with ΔT), and DHW Tank
- Connectivity Status: MQTT and Network connection indicators in the bottom status bar
- Clock Display: Current time and date
- Individual control for each piece of equipment (pumps, valves)
- Three modes per device: Auto (follows control logic), On (manual override), Off (manual override)
- Real-time status indicators showing equipment state
- Setpoint Configuration: Adjust high temperature and delta T for Glycol, DHW, and Eco Mode
- Eco Mode Schedule: Set start and end times for eco mode (30-minute increments)
- System Information: Displays MQTT broker address and local IP address
- Restart RPi Button: Reboot the Raspberry Pi (amber button, with confirmation dialog)
- Shutdown RPi Button: Safely shutdown the Raspberry Pi (red button, with confirmation dialog)
- Non-blocking sensor reads: Background thread reads sensors asynchronously, preventing GUI freezes
- 1-Wire bus self-healing: Automatically detects total sensor failure and reloads kernel modules (
w1_therm,w1_gpio) to recover — up to 3 attempts before requiring manual intervention - Setpoint Persistence: Modified setpoints are automatically saved to
setpoints_state.yamland restored on restart - Touch-optimized controls: Large +/- buttons for setpoint adjustment
- Press ESC key to exit the application
cd /home/pi/snowmelt_control
source venv/bin/activate
# Test with mock sensors (no hardware required)
python main.py --mock-sensors --debug
# Test with real hardware
python main.py --debug
# Test headless mode
python main.py --no-gui --debug# Copy service files
sudo cp snowmelt.service /etc/systemd/system/
sudo cp snowmelt-headless.service /etc/systemd/system/
# Reload systemd
sudo systemctl daemon-reloadFor GUI mode (with touchscreen):
# Enable service to start on boot
sudo systemctl enable snowmelt.service
# Start the service now
sudo systemctl start snowmelt.service
# Check status
sudo systemctl status snowmelt.serviceFor headless mode (no display):
sudo systemctl enable snowmelt-headless.service
sudo systemctl start snowmelt-headless.service# View service logs
sudo journalctl -u snowmelt.service -f
# View application log
tail -f /var/log/snowmelt/control.logsudo rebootAfter reboot:
- Verify the GUI appears on the touchscreen
- Check Home Assistant for the new entities
- Verify temperature readings are updating
- Test equipment controls from both GUI and Home Assistant
The system includes automatic 1-Wire bus self-healing. If all sensors become unresponsive, the system will:
- Detect 5 consecutive all-sensor-failure read cycles (~10 seconds)
- Automatically unload and reload the
w1_thermandw1_gpiokernel modules - Retry up to 3 times before logging an error requiring manual intervention
If auto-recovery fails:
# Check service logs for reset attempts
sudo journalctl -u snowmelt.service | grep "1-Wire"
# Manual kernel module reload
sudo modprobe -r w1_therm w1_gpio
sudo modprobe w1_gpio
sudo modprobe w1_therm
# Or restart the service
sudo systemctl restart snowmelt.service# Check if 1-Wire is enabled
ls /sys/bus/w1/devices/
# Reload modules
sudo modprobe w1-gpio
sudo modprobe w1-therm
# Check config.txt
cat /boot/firmware/config.txt | grep w1# Test GPIO access
python test_relays.py --list-pins
python test_relays.py --test 1
# Check GPIO permissions
groups pi # Should include 'gpio'# Test MQTT connectivity
mosquitto_pub -h 192.168.1.201 -u username -P password -t test -m "hello"
# Check secrets file
cat secrets.yaml
# Run with debug logging
python main.py --debug# Check DISPLAY variable
echo $DISPLAY # Should be :0
# Check X server
xhost +local:
# Run manually with display
DISPLAY=:0 python main.py# Check service status
sudo systemctl status snowmelt.service
# View detailed logs
sudo journalctl -u snowmelt.service --no-pager -n 100
# Verify paths in service file
cat /etc/systemd/system/snowmelt.service- Check sensor polling interval in
config.yaml(increase if needed) - Verify sensors are responding properly
- Check for error loops in logs
# Start/Stop/Restart service
sudo systemctl start snowmelt.service
sudo systemctl stop snowmelt.service
sudo systemctl restart snowmelt.service
# View logs
sudo journalctl -u snowmelt.service -f
# Manual run (for testing)
cd /home/pi/snowmelt_control
source venv/bin/activate
python main.py --debug
# Discover sensors
python discover_sensors.py
# Test relays
python test_relays.py --interactiveFor issues or questions:
- Check the troubleshooting section above
- Review logs for error messages
- Verify hardware connections
- Ensure all configuration files are correct
Last updated: March 2026


