How to Make a Wireless Thermostat

By Robin Mitchell

 

Electric heaters are great for heating up a room, but they never come with a room thermostat (only those arbitrary 1 to 10 dials). In this DIY Hacking project, we will build a wireless thermostat that will turn these heaters into a room temperature-controlled heater.

 

Required Materials

 

Transmitter

  • 1K Resistor (R1, R2)
  • 100nF Capacitor (C1, C3, C4)
  • 10uF Capacitor (C2)
  • 1N5817 (D1, D2)
  • 100K Potentiometer (RV1)
  • PIC16F819 (U1)
  • 7805  (U2)
  • DHT11 (J2)
  • 433MHz Transmitter Module  (J3)

 

Receiver

  • 1K Resistor (R1)
  • 10K Resistor (R2)
  • 100nF Capacitor (C1, C3, C4)
  • 10uF Capacitor (C2)
  • 1N5817 (D1, D2, D3)
  • 2N3904 (Q1)
  • Relay (RL1)
  • PIC16F819 (U1)
  • 7805 (U2)
  • 433MHz Receiver Module (J2)

 

Other Materials

  • MPLAX with XC8
  • PICKIT3

 

Wireless Thermostat Schematic

 

The transmitter circuit

 

The receiver circuit

 

How the Wireless Thermostat Works

 

The project is composed of two main circuits — the transmitter and receiver — and the code found on the microcontrollers. The transmitter circuit is very trivial, with a PIC16F819 as the main controller, a potentiometer to be used as a temperature dial, a DHT11 module for measuring the room temperature, a simple 433MHz transmitter module, and a power-regulation circuit. The receiver circuit is also very simple, with the main microcontroller (also a PIC16F819), a relay and transistor to drive the relay, a 433MHz receiver module, and a power-regulation circuit. The PIC16F819 was chosen for this circuit due to its small size, its cost (a buck a piece in the right place), and its DIP package (18 DIP).

The complexity of the circuit is in the coding of the two circuits, and due to their length, the entirety of the code will not be explained here. However, the code will be explained as well as the reasoning behind the design.

Both the transmitter and receiver use similar start-up code, which involves configuring the internal oscillator, the IO pins, and various other modules. For example, the transmitter needs to configure the ADC to allow readings from the POT while the receiver needs to disable all ADC pins. Once ready, the transmitter circuit continuously takes readings from the DHT11 and compares the temperature to the temperature setting on the POT. The voltage output of the POT can be between 0 and VCC, which corresponds to values between 0 and 255. Since we don’t want a temperature above 30 degrees or one lower than 10, a simple formula is used to convert the position of the POT to a desired temperature:

temperatureSetting = 10 + (temperatureDial / 12)

If the temperature setting is greater than the current temperature, the transmitter will change the heater status to 1 (else 0). With all of that done, the transmitter transmits the heater status wirelessly to the receiver so the receiver can configure the output relay to either turn on the heater or turn it off. But how do we transmit this data?

The 433MHz band is very noisy, and chances are, your receiver will pick up much interference. Because of this, we cannot send pulses of different length to indicate if the heater is to be turned on or off. Instead, we need to send a data packet that is somewhat unique so the receiver can distinguish between noise and information.

 

 

The protocol used for transmitting data

 

Key points about the protocol:

  • The start bit is 2T high and 2T low
  • A data bit is 2T wide
  • The first T unit in the data is the clock signal (logical high)
  • The second T unit in the data is the data bit (either high or low)

The length and speed of the transmission is not too important; it only matters that the receiver reads the data bits at the correct time. In theory, the two project files attached to this project should work out of the box, but if you find that the receiver is never picking up the transmission, yet you can see the receiver module receiving the data, you may need to edit the receiver code delays or adjust the oscillator to match the pair.

 

Construction

 

This project can be built with many different circuit construction techniques including stripboard, matrix board, and PCB. However, it is advised not to use a breadboard if the electrical heater uses a voltage above 12V. For this project, I have used a PCB (because wiring is boring), and I am now using 7805 ICs in a SOT-89 package, which is very small (and not hobby-friendly).

 

The transmitter

 

Please understand that high voltages are DANGEROUS and WILL KILL if mishandled or abused. DO NOT use this project in a mains environment if you are neither competent to install electrics safely or not able to ensure that the circuit will be safely installed and safely operate. Always remember to switch lives, keep neutrals unbroken (unless an isolation switch is needed), use fuses on the live wire, and have earths connected when needed.

 

The receiver

The 433MHz receiver module

The 433MHz transmitter module

 

Downloadable Files

 

 

Related Articles

Recommended Posts
Showing 2 comments
  • Robin Mitchell
    Reply

    Hi,

    A working one is not shown because making videos is demanding work. When I make videos of projects, I have to choose then carefully as I can only get one out a week (I try to). However, NONE OF THESE PROJECTS ARE RELEASED UNTESTED!

    Now, what do you mean by “if you know where to get this stuff”? Are you saying that you want to be told where you can get parts? On your comment on “I just haven’t seen the end product”, the circuits are right there in the photo and the schematic clearly shows where the live wires are to be attached to. All components used have been listed including all code needed.

    But as you said, I will make more effort next time to show projects working (despite that being pointless as it would not help with construction). But saying a comment like “Why do they allow this to be written without even showing one working?” is insulting and unhelpful.

    All the best,
    Robin

  • meesphht
    Reply

    Just as usual. This, I guess, is just fine if you know where to get this stuff and what it is but for me, this’ll never even be attempted because I just haven’t seen the end product.
    Why do they allow this to be written without even showing one working?

Leave a Comment

81 + = 88

Start typing and press Enter to search