Arduino Temperature Monitor and Real Time Clock With 3.2" Display




Introduction: Arduino Temperature Monitor and Real Time Clock With 3.2" Display

About: I am Nick Koumaris from Sparta, Greece. I'm extremely passionate about electronics, making things and design. I love teaching what I know and sharing my experiences with you. I put out new YouTube videos eve...

Dear friends welcome to another tutorial! This is Nick from and today we are going to see how to develop this real-time clock and temperature monitor! Let’s get started!

A few weeks ago, I tested this 3.2” color TFT display for Arduino with both Arduino Mega and Due. The display works fine, and I built a simple project with it. It is a temperature monitor and a real-time clock. As you can see at the top, we can see the current date and time, we can see the temperature right now, and at the bottom, the Arduino records the minimum and the maximum temperature that it has measured. I also tried to design a basic user interface just with simple shapes. As you can see everything works fine, and it is a very easy and useful project to build. Let’s see how to do it!

Step 1: Get All the Parts

The parts needed in order to build this project are these:

The cost of the project is around 24$. You need around 14$ for the Arduino Due, 8$ for the display and about 2$ for the RTC module.

Step 2: The DS3231 Real Time Clock Module

The DS3231 real time clock module is as its name suggest a Real Time Clock. Using its battery it can keep time for years since it has minimal power consumption.

The DS3231 is a low-cost, extremely accurate I2C real-time clock (RTC) with an integrated temperature compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains accurate timekeeping when main power to the device is interrupted. The integration of the crystal resonator enhances the long-term accuracy of the device as well as reduces the piece-part count in a manufacturing line.
The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided. Address and data are transferred serially through an I2C bidirectional bus.

The cost of the module is extremely low, it costs around 2$ including the battery!

Get it here ▶

We are going to use it in order to keep time and get temperature readings from it!

Step 3: The 3.2" Color TFT Display (HX8357C or HX8357B)

I always wanted to have a big display for my Arduino projects. So, a few weeks ago I decided to buy this 3.2 Inch color TFT display for Arduino Mega and Arduino Due because the price is so tempting! Less than 10$ for a 3.2’ color TFT display. With that price, you can’t go wrong.

Get it here ▶

The display has a resolution of 480x320 pixels and has an SD card adapter on the back. I haven’t used SD card functionality so far. I will try to use it in the future. If you look carefully you can see that the display also uses a 3.3V regulator so it works fine with 5V and 3.3V logic levels.

The display comes in two variations. One of them uses the HX8357C controller and the other one the HX8357B controller. Luckily we can use the same library for both of them.

DISPLAY Library:

After downloading the library you have to open the User_Setup.h file comment line 13 and uncomment line 14 if the display you have is using the HX8357C driver, like mine.

Step 4: Connecting the Parts

I am going to use the Arduino Due to build this project, although I could use the slightly cheaper but slower Arduino Mega. Arduino Due is much faster than the Arduino Mega and it has a lot of memory, that’s why I prefer it for this project.

At first, we have to connect all the parts together. I am going to use these male headers in order to connect the RTC module to the Arduino DUE.

We need four header pins. Two for power and two for the I2C interface. We bend them like this and we connect one to 3.3V pin of the Arduino Due board, the other to GND, and the other two to SDA and SCL pin of the board. With some female wires, we connect the module to the board. That’s it.

Now we can attach the display to the board. You don’t have to connect these two pins to the Arduino board so I will leave them floating.

Now we are ready to power up the project. As you can see, it works fine! It is that easy! Let’s now go to the computer to see the software side of the project.

Step 5: The Code of the Project

Now we are ready to take a look at the code.

We are using two libraries in this project:

Display Library ▶

DS3231 Library ▶

You have to install them and then the project will compile just fine!

The first thing we have to do is to set the time to the real time clock module if it is not already set. In order to do it, enter the current date and time at the void setRTCTime function,

<p>void setRTCTime()<br>{
  DateTime dt(2016, 4, 4, 13, 56, 30, 1); // Year, Month, Day, Hour, Minutes, Seconds, Day of Week

uncomment the call to the function in the Setup function:

<p>void setup()<br>{  
  rtc.begin();</p><p>  tft.init();

and upload the program to Arduino. Now the time is set. But, then we have to comment the call of the setRTCTime function again and upload the program to Arduino once more.

<p>void setup()<br>{  

As you can see the code of the project is simple. We just print the user interface and then display the date the time and the on it.

<p>void loop()<br>{
   float temperature = rtc.getTemperature();
    maxTemperature = temperature;
</p><p>if(temperature<minTemperature)</p><p>  {
    minTemperature = temperature;
  }</p><p></p><p> delay(1000);</p><p>}</p>

You can find the code attached to this step. You can download the latest version of the code from the project's website here:

Step 6: Final Thoughts

As you can see with a few lines of code and with very low cost we can build a very useful project. I am going to work more on this project since it will become an advanced weather station, with more sensors, graphs and wifi capabilities.

Since the Arduino Due is very fast and has a ton of memory I think it is the ideal Arduino board to use. What do you think about this project? How do you want to see it evolve?

Please post your comments or ideas in the comments section below.

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Super-Size Speed Challenge

      Super-Size Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020

    3 Discussions


    Question 1 year ago on Step 6

    I've put the project together again and now I'm having problems with the data displayed.

    All I get is a date of: "Monday 165/165 45:165" and the temperature of: "-1.75C, -1.75C, -1.75C. I've tried other DS3231 modules, switched batteries, I've even unplugged the DS module completely and I always get the same readings.

    Any suggestions out there?


    2 years ago

    Can the temperature be changed to Fahrenheit, and where in the code is it best to do this?