Build a modular HVAC system with Raspberry Pico W, MQTT, and Home Assistant to optimize furnace and AC efficiency while keeping your data private. This Homatica project by Claudio Cabete uses servo-controlled gas modulation and real-time sensor data for a smarter, greener home.
Traditional thermostats react slowly and waste energy, while many smart thermostats rely on cloud services, risking your privacy. My goal was a privacy-first, locally hosted HVAC controller that anticipates thermal behavior, modulates fuel usage, and adapts dynamically—all without third-party data sharing. This project embodies Homatica’s mission: modular, resilient, and customizable home automation built with open-source tools like Home Assistant.
All components communicate via MQTT, with the Pi 4 orchestrating logic and logging telemetry to MariaDB.
import machine import time from umqtt.simple import MQTTClient # Servo control for gas modulation servo = machine.PWM(machine.Pin(16)) servo.freq(50) def set_servo_duty(duty): servo.duty_u16(int(duty * 65535 / 100)) # MQTT setup client = MQTTClient("pico_w", "mqtt_broker_ip") client.connect() def on_message(topic, msg): if topic == b"hvac/ctrl/outputs": duty = float(msg.decode().split("gas_pwm:")[1]) set_servo_duty(duty) client.set_callback(on_message) client.subscribe("hvac/ctrl/outputs")
Active schedule selected: eid=0 mode=hold sch_type=AC sch_hvac_mode=AC setpoint=24.7 fan_on=0 fan_off=1800
HEAT_TEMP_TRIGGER: 18 AC_TEMP_TRIGGER: 26 heat_max_setpoint: 20 ac_max_setpoint: 25 dead_band: 0.7 ac_min_run_secs: 900 ac_min_off_secs: 300 ac_fan_delay_secs: 60 furnace_fan_delay_secs: 90 hvac_mode: AC sch_mode: AC settemp: 24.7 setadjtemp: 24.7 fan_cycle_on_secs: 0 fan_cycle_off_secs: 1800 udv_hvac_mode: AC 🌦️ Weather: temperature: 72°F humidity: 97% condition: rainy forecast: temperature: 77°F templow: 72°F humidity: 95% wind_speed: 13.17 km/h uv_index: 5.3 precipitation: 0.47 datetime: 2025-09-25T16:00:00+00:00 🌡️ Sensors: HVAC Central Unit CTLR: In Air Temp: 22.81°C Internal Temp: 29.86°C Out Air Temp: 11.63°C Portable Thermostat: Ambient Temp: 22.94°C Internal Temp: 29.86°C BedRoom Thermostat: Ambient Temp: 25.69°C Internal Temp: 33.60°C
Mode: AC Setpoint: 24.7 AvgTemp: 24.8 TempDiff: 0.10 ac_state_change_lap: 575.31 ac_state: 1
Time since last fan state change: 514.78s Air Temp Delta: temp_diff_air: 11.19 fan_diff_on: 6.0 fan_diff_off: 3.0 Thermostat Temp Delta: temp_diff_thermostats: 2.75 thermostat_diff_on: 4.5 thermostat_diff_off: 3.7 During AC Active: temp_diff_air: 11.19
registers: air_in_out_delta: True thermostats_delta: False fan_cycle: False ac_fan_delay: True furnace_fan_delay: False post_ac_fan: False post_furnace_fan: False circfan_state: 1 fan_reason: air_in_out_delta, ac_fan_delay
Topic: hvac/ctrl/outputs Payload: device_id: 7 settemp: 24.7 setadjtemp: 24.7 udv_hvac_mode: AC fan_cycle_on_secs: 0 fan_cycle_off_secs: 1800 sch_mode: hold gas_pwm: 11.4 hvac_mode: AC avg_temp: 24.8 data: - ioid: 0, io_v: on - ioid: 1, io_v: off - ioid: 2, io_v: on - ioid: 16, io_v: on, io_freq: 50, io_duty: 11.4
I’m enhancing the override logic for smoother manual interventions and developing animated diagrams to visualize system states. A full tutorial with schematics and MicroPython code is in progress—stay tuned on my blog!
This HVAC controller was crafted with AI assistance, from optimizing MicroPython code to refining control logic and documenting the build. AI helped me explore edge cases and streamline the system, but the core design—every wire, code line, and debug session—came from my passion for DIY automation, sparked by building an FM transmitter at age 12.