Introduction: Arduino Programable Thermostat

Picture of Arduino Programable Thermostat

This project uses an Arduino Nano, a RTC, a rotary encoder, a Nokia 5110 display and a relay. It allows manual and programmed setting of temperature, and furnace control.

You can see a video of the system, a breakdown of the code, and how I put it together here: Arduino Programmable Thermostat

Step 1: The Real Time Clock

Picture of The Real Time Clock

The DS3231 RTC is an I2C device. So in addition to needing +5V and ground, it has a clock pin (SCK) that connects to A5 and a data pin (SDA) that connects to A4.

The clock is set in the setup() function the first time you run the program with the following code:








Make sure to comment them out and reset the Arduino after setting the clock.

Step 2: The Relay

Picture of The Relay

The relay's + pin is connected to +5V, the - pin goes to ground. The "S" pin (signal) goes to digital 6 on the Arduino. The furnace control wires are connected between the normally open (NO) and common posts on the relay. The relay used here is a Songle 30VDC10A.

Step 3: The Display

Picture of The Display

We are using a Nokia 5110 display in this project. It uses the Adafruit PCD8544 library. The 5110 is a 3.3V device with 5V tolerant signal pins. So the Vcc must connect to the Nano's 3.3V pin, the ground of course, goes to ground. Also note that the LED pin goes to 3.3V. The signal pins connect as follows:

pin 7 - Serial clock out (SCLK)

pin 6 - Serial data out (DIN)

pin 5 - Data/Command select (D/C)

pin 4 - LCD chip select (CS)

pin 3 - LCD reset (RST)

Step 4: The Rotary Encoder

Picture of The Rotary Encoder

The rotary encoder is user front end to this system. The rotation function is used to adjust both time and temperature. The clickable button is used to select modes, toggle between features, and make selections. It connects as follows:

Arduino pin 8 - Rot Enc switch

Arduino pin 9 - Rot Enc Clock

Arduino pin 10 - Rot Enc data

Step 5: Modes

Picture of Modes

The system has two basic modes of operation:

Manual and Program

In the manual mode, turning the rotary encoder clockwise will increase the temperature. Counter-clockwise with decrease the temperature. Finally clicking the switch will send the system to the program menu.

In the program menu, clicking the switch will move the cursor to each selection: hour, minute, temperature. When the cursor is under one of the selections, turning the knob will adjust that selection. Clicking again will move the cursor to the next selection. When all adjustments have been made, a final click will activate the Program Mode.

In program mode, the system will change to the programmed temperature at the time selected.

Step 6: The Code

My code is available to download here:


IonutM10 (author)2017-11-28

Can you say what library do you use for rtc?

martyjk (author)2017-06-07

Nice project want to build one but would be nice to get the exact part numbers for the relay and rotary encoder. The relay is on a PCB but could not find it. All rotary encoders are not the same so part number is needed.

deki (author)2017-03-16

any plans for a cooling cycle option?

Yes, in the 2nd iteration.

avrgotcha (author)2017-03-21

Hi, the code to download link seems to does'nt work

smartrem (author)2017-03-21

Hi, very good project. I was just wondering about the accuracy of your thermostat. Including a PID mode would make it totally professional, I think there's an Arduino library for that. Keep up!

onion2 (author)2017-03-17

the real time clock is a little useless and expensive, you can use the fonction millis() in your code.
however it's a nice project :p

VicenteG16 (author)2017-03-16

Muy interesante tu trabajo. Felicitaciones.

Swansong (author)2017-03-16

Good instructable :) I wish our thermostat was more reliable. It tends to overshoot the set temperature.

Swansong, I believe that most commercial thermostats have +/- 2 deg dead zone to keep them from switching on and off all the time. Thanks for your kinds words.

MESHprj (author)2017-03-16

Cool project!

About This Instructable




Bio: EE Educator, Pink Floyd fan, father, human,from Earth
More by learnelectronicsyoutube:Arduino Programable Thermostat
Add instructable to: