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