Arduino Programable Thermostat

11,734

110

15

Introduction: Arduino Programable Thermostat

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

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

    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    15 Discussions

    0
    onion2
    onion2

    3 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
    sonerkuzucu
    sonerkuzucu

    Reply 8 months ago

    RTC is required in order not to lose the set time when power is off. Otherwise, the time must be adjusted after each power is turned on / off. NTP can be an alternative for RTC.

    0
    omiyo
    omiyo

    Question 2 years ago

    class DS3231' has no member named 'getTime'

    0
    omiyo
    omiyo

    2 years ago

    class DS3231' has no member named 'getTemperature'

    0
    JohnM653
    JohnM653

    2 years 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
    IonutM10
    IonutM10

    3 years ago

    Can you say what library do you use for rtc?

    0
    martyjk
    martyjk

    3 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
    deki
    deki

    3 years ago

    any plans for a cooling cycle option?

    0
    avrgotcha
    avrgotcha

    3 years ago

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

    0
    smartrem
    smartrem

    3 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
    VicenteG16
    VicenteG16

    3 years ago

    Muy interesante tu trabajo. Felicitaciones.

    0
    Swansong
    Swansong

    3 years ago

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

    0
    learnelectronicsyoutube
    learnelectronicsyoutube

    Reply 3 years ago

    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
    MESHprj
    MESHprj

    3 years ago

    Cool project!