Arduino Programable Thermostat

10,054

107

14

About: EE Educator, Pink Floyd fan, father, human,from Earth

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

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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:

Clock.setSecond(00);

Clock.setMinute(05);

Clock.setHour(11);

Clock.setDoW(06);

Clock.setDate(11);

Clock.setMonth(03);

Clock.setYear(17);

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

Step 2: 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

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

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

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: https://www.dropbox.com/sh/h32im1d69f4wa8j/AADeOMpEy-bH18nSkWa2H0M9a?dl=0

Sensors Contest 2017

Participated in the
Sensors Contest 2017

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    14 Discussions

    0
    None
    omiyo

    Question 10 months ago

    class DS3231' has no member named 'getTime'

    0
    None
    omiyo

    10 months ago

    class DS3231' has no member named 'getTemperature'

    0
    None
    JohnM653

    1 year ago

    Hi, just the project I was looking for, I have probably missed something, but I can't see where the actual room temperature is being sensed, where is the temperature sensor IC. Thank you.

    0
    None
    IonutM10

    1 year ago

    Can you say what library do you use for rtc?

    0
    None
    martyjk

    2 years ago

    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.

    0
    None
    deki

    2 years ago

    any plans for a cooling cycle option?

    1 reply
    0
    None
    avrgotcha

    2 years ago

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

    0
    None
    smartrem

    2 years ago

    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!

    0
    None
    onion2

    2 years ago

    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

    0
    None
    VicenteG16

    2 years ago

    Muy interesante tu trabajo. Felicitaciones.

    0
    None
    Swansong

    2 years ago

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

    1 reply

    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.

    0
    None
    MESHprj

    2 years ago

    Cool project!