31.12.13

Magic Mote Thermostat and Wireless Temperature Sensor

A homemade thermostat up in the basement rafters controls the heating in my home. The smart bit is the radio frequency communication that connects it to a remote temperature sensor.



So, I'm planning a home automation system based around wireless nodes of my own design: the Magic Mote featuring a MSP430G2553 low power microcontroller plus NRF24L01+ 2.4 GHz radio module. (PCBs now available on Tindie!) Part of the motivation for doing this is that the wires between the furnace in the basement and the thermostat 2 floors up have broken and it's a terrible nuisance to fish new wires in a 100 year old house with knob and tube wiring inside the walls.

I hacked together this little relay box to control the furnace. Active low set and reset lines from microcontroller govern a 2-coil latching relay that switches the 24 VAC line to the furnace contactor. The box is powered by a 8.5 VAC doorbell transformer. The doorbell wires run conveniently adjacent to the furnace control lines in the basement. A bridge rectifier and 1000 uF cap convert that to about 11 VDC, enough to power the relay coils, which is dropped down to 5 V using a zener diode for output to a microcontroller.



I made a hideous mess of soldering to the perfboard, having both omitted to breadboard the circuit and misread the relay datasheet. The saving grace was having used 2x turned pin DIP8 sockets to mount the relay. More bodges followed. The resistor R1 was included to protect the zener diode for maximum life, but its value was unnecessarily large. When I modified the circuit to include a 3.3 V LDO voltage regulator I put a second resistor in parallel with R1 to bring the combined resistance down to somewhere around 100 Ω.



These little project boxes from Rapid were very handy, but slightly too small for this job. They were a good size for the wireless nodes though, and the aluminium lid might make a great ground plane for a dipole aerial.



This Magic Mote featured a DHT22/AM2303 temperature and humidity sensor connected to the 4-pin header. From its perch on top of the old thermostat in the 2nd floor hallway the RF transceiver had sufficient range to reach its counterpart in the basement. 



The firmware is at an early stage of development. Communication is one way. The wireless node transmits temperature and humidity readings every 2 seconds. For purposes other than demonstration a much slower frequency would be sensible to improve battery life. The LEDs blink green for successful transmission or flash orange if the transfer goes unacknowledged. The receiver decodes the message and controls the furnace relay according to a simple rule. The set temperature is hardcoded to 18 °C with a dead band of half a degree either side.

I am indebted to Spirillis for his excellent msprf24 library which interfaces the Nordic module and is superbly documented in the wiki. The DHT22 is read using an interrupt driven routine by TheDZhon ported to C. 

This demo is just a first step on the way to a more comprehensive home automation system. The plan is to use a BeagleBone to coordinate a network of sensors and appliances, interacting via a browser client and logging data to the web.


Resources




Linkback


10 comments:

Unknown said...

Are you really using a latching relay? The project is really great, but the problem with a latching relay is if it is on and anything happens, it fails on leaving the furnace on.

Tom said...

That's right Mark, the latching relay will tend to fail in the current state. So in summer, the relay will fail off. In winter, it will tend to fail on. For me that is probably useful behaviour :) Battery powered thermostats all use latching relays for reasons of power economy, although that is not a vital issue here.

Justblair said...

Are you using something like humidex to unite the humidity and temperature reading?

Tom said...

@Justblair, that's a good idea I'll look into that. I haven't connected up the AC yet. I was planning on using a lower temperature threshold when humidity is high for a short period in the early evening to get the humidity down.

KWest said...

Nice work..

One thing I'd suggest is that if the RX side doesn't see a MSG in a certain period that it goes into an error state and runs the furnace. You could add another air temp sensor local to the furnace and use it to monitor the temp when in the error state, a 5 min cycle should be enough to pull enough return air to get a valid room temp reading.

Tom said...

I see what you are saying. That could work well in a house with forced air. My house has radiators.. but not in the basement :)

flyboy said...

That's a nice project, but the guys are right. You don't want to use latching relays, and you should add a fail safe mode. Maybe if you don't "hear" a message from the transmitter after 2 minutes, it runs the blower on the furnace continuously or something like that.
Other than a few safeties, that's a nice project. Good work.

Tom said...

Thanks for the compliment. A manual override would be trivial to install, I suppose. Currently that can be achieved by simply sticking a jumper in the end of the ribbon cable from GND to _SET or _RST. I'm afraid I have to disagree on some points. I'm not an HVAC professional, but in my limited experience latching relays are near universal in home thermostats. I'm not at all convinced that failing with the heating off is always desirable. 10°F is forecast tonight!

michaelbelow said...

VERY INFORMATIVE ARTICLE. Thanks

www.cosmopolitanmechanical.ca

Anonymous said...

https://bestsmartthermostat.com/wifi-thermostat-for-geothermal/

Post a Comment