WiFi Thermostat

Raspberry Pi Pico W Based Thermostat; First Prototype.

We are currently working to develop a WiFi Thermostat.  In January 2025 my Honeywell thermostat stopped working.  The temporary solution (first prototype) was to fabricate a thermostat from a Raspberry Pi Pico W microcontroller board and a relay board that I had on hand.  We have designed a second prototype and are waiting for the pcb.

Design parameters: Things I did not like about the old thermostat include: 1. That it ran off of battery power so the batteries needed to be replaced periodically.  2. The parameters (time and temperature information) were all kept in volatile memory so the thermostat needed to be re-programmed any time the battery was replaced. 3.  The programming interface was limited to a few buttons that needed to be pressed to change the time, temp, etc. 4. The current time needed to be updated using the buttons as well.  5. The display could not be read in low light or from anywhere except standing directly in front of it.  

Addressing the issues: 1.  The power for the first generation prototype is supplied by a usb charger.  The second generation will have an on-board converter to run from the AC provided over the furnace wiring.  While the thermostat will not run when the power to the house is off, the furnace will not run without power either, so that is not much of a loss.  2. Our thermostat will store the time and temperature parameters in non-volatile memory. While the first prototype kept its parameters in firmware, the second (and presumably all future prototypes) will store the parameter in on-board flash memory (or EEPROM if we change microcontrollers).   3. The first prototype is programmed from a host computer over usb.  In the future we will have the ability to change programming over wifi.  4. The thermostat connects to wifi and syncs the time with information from the internet.  5. We are currently displaying time, temperature, set temperature and whether the furnace is turned on using a display on our computer.

Relay Circuit

The relay (G50-1A4-EU DC5) is rated at 10 Amp with 5 volt switching.  R1 is 50 ohm 603 package.  U1 is a power driver (DRDC3105F-7).  The switch is operated at 3.3 volts from a gpio pin on the microcontroller.  The NO and common connections (J1, pins 1 and 2) go to the red and white wires to the furnace.  

Circuit board

The circuit board was originally intended to be a temperature controller for a reflow hot plate.  The only components that are populated in the thermostat are the relay (K1) power driver (U1) and R1.

You can purchase the circuit board from the shared projects page at OSHPark.  Three boards can be purchased for $6.80 plus shipping.

Wiring Diagram

The Pico is powered by a usb charger and supplies +5, +3.3 and GND to the temperature controller.  The "Switch" pin connects to the wire pad marked "SW" on the pcb.  TH1 is a 100 KOhm thermistor I got from Amazon.  GP21 and GP19 are declared as pullup inputs in the firmware.  There is a ground wire with an alligator clip that can be connected to either of these GP pins to signal the thermostat to maintain one of two pre-set temperatures.  

Firmware

Firmware was written in the Arudino IDE.  The design was intended to measure the temperature and turn the furnace on for 12 minutes if the temperature is below the set  point.  After the 12 minute active heating time, the furnace is turned off for two minutes before measuring again.  

Time is monitored over WiFi.  The time monitoring code was copied pretty much verbatim from the Arduino "TimeNTP_ESP8266WiFi" example sketch.  The temperature reading part of the code was taken from an instructable sketch that I found on the internet.

Display

The indoor temperature, current temperature setting and whether the furnace is currently turned on or not are transmitted over WiFi when prompted by a computer on the network.  The image to the left shows the display on a Raspberry Pi fitted with  a touch screen.  This computer is also connected by WiFi to another microcontroller that measures the outdoor temperature and humidity. 

Next Steps

Hardware: Plans for our second generation PCB were sent for fabrication in January 2025.   We expect to get them back in early February.

The current prototype thermostat is powered by a usb charger and only has a circuit to control a furnace.  Commercial WiFi thermostats take power from the 24 volt AC provided through the furnace wiring and have circuits for controlling air conditioning and a fan in addition to the furnace.  As described below, our next circuit board will incorporate a rectifier a voltage regulator to convert the 24 volt AC to 5 volt DC.  While I do not have air conditioning, we will incorporate relays to support it.

Should we have an SD card reader?  User name and password could be saved on the card

The thermostat also needs an enclosure.  

Firmware: The current firmware does not allow the user to adjust the set times, set temperatures, internet address, password, or other parameters.  The next firmware development will allow the user to input these into flash (nonvolatile) memory that will be re-loaded when the power cycles off.

User Interface(s):  We are writing a separate "Setup" user interface to allow parameters to be uploaded to the thermostat over usb.  How annoying is it to have to input a device's network name and password using three buttons when you have a perfectly serviceable computer standing by?  The "Setup" interface will allow the user to set parameters including the network name and password into non-volatile memory, so these parameters will not be lost when power is down.

While our second prototype will allow connection to an oled display, my own choice is to use the computer and we may not get to writing code for the display soon.

Our 2nd generation hardware 

Three Relays: While the first generation thermostat was only equipped to run a furnace, this model will have three relays, one for the furnace, a second for AC, and a third for a fan.  

Built in 24 V AC to DC power: This generation will also be able to be powered from the 24 volt AC supplied by the thermostat wiring.  Note that this requires that wiring from the house  include a "Common" wire, which is commonly blue. If this wire is not present, the thermostat can still be powered using a usb charger.

Buttons and indicators: There will be three push button switches for future definition, and three four indicator lights, one that indicates power and three that can be controlled by the microcontroller.

Display: Connectors broken out for OLED display.  Not sure that I want to write code for this, but the hardware will be there to support that decision.