Build Yourself a Clock and Thermometer




Introduction: Build Yourself a Clock and Thermometer

Hello Guys,
In this step by step instruction,
I want to share my experiment on creating a clock and thermometer with
Arduino Mega 2560, LCD 16 x 2, thermal resistor sensor and DS1307 real time clock

More projects :

Step 1: Preparing the Material

Prepare all the needed materials :
1. Arduino Mega 2560
2. LCD 16x2
3. RTC DS1307 module
4. NTC ( Negative Temperature Coefficient ) thermistor
I used 10K with lug
5. USB cables for PSU, you can use your own connector too...
6. Some male to male breadboard wires
7. Some female to female breadboard wires
8. 10 K 1/4W resistor
9. 1 K Trimpot
10. Arduino compiler, you can find it on arduino website
I used Arduino 022

Step 2: Connect Your Arduino to LCD,RTC and NTC

Here're the connection list to Arduino Mega 2560 for this project :

* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground

* ends to +5V and ground
* wiper (1K Trimpot) to LCD VO pin (pin 3)

RTC module :
connect to pin
pin 20 Arduino = pin SDA on RTC module
pin 21 Arduino = pin SCK on RTC module

Thermistor connection :
connect thermistor to A0 on arduino board series with 10K 1/W resistor.
Please see the schematic for thermistor

Step 3: Create the Sketch or Arduino

Next step is creating skecth on arduino compiler,
I used LCD, math and DS1307 library,

Here's the code , I assume that you know on how to upload it into your board:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)

#include <LiquidCrystal.h>
#include <DS1307.h>
#include <math.h>

// Init the DS1307
DS1307 rtc(20, 21);

// Init the LCD
//LiquidCrystal lcd(22, 24, 26, 28, 30, 31);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
  // Set the clock to run-mode

  // Setup LCD to 16x2 characters
  lcd.begin(16, 2);

  // The following lines can be commented out to use the values already stored in the DS1307
  //rtc.setDOW(SATURDAY);        // Set Day-of-Week to SUNDAY
  //rtc.setTime(13, 21, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(11, 05, 2013);   // Set the date to October 3th, 2010

  // Set SQW/Out rate to 1Hz, and enable SQW

double Thermister(int RawADC) {
  double Temp;
  // See for explanation of formula
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 273.15;           // Convert Kelvin to Celcius
  return Temp;

void loop()
  // Display time centered on the upper line
  //lcd.setCursor(4, 0);
  lcd.setCursor(0, 0);
  //Read temp sensor
   double temp = Thermister(analogRead(0));  // Read sensor
   //print screen

  // Display abbreviated Day-of-Week in the lower left corner
  lcd.setCursor(0, 1);

  // Display date in the lower right corner
  //lcd.setCursor(6, 1);
  lcd.setCursor(3, 1);
  lcd.setCursor(4, 1);


Step 4: Enjoy Your Own Clock and Thermometer ;)

Enjoy your own clock and thermometer ;)
Please see the video

Thanks for reading, and good luck for your experiment
Epilog Challenge V

Participated in the
Epilog Challenge V

Pocket Sized Electronics

Participated in the
Pocket Sized Electronics

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge

    7 Discussions

    smabdullah ahmed
    smabdullah ahmed

    4 years ago

    hi your code is not working for me and I donot undersatand the word wiper could you elaborate


    4 years ago


    5 years ago

    Can you help me using your code? The first screen using buttons and this would not shield the menu with more options as an alarm and etc. Thank you very much.


    Reply 5 years ago on Introduction

    hello and thanks! For this project clock and thermometer, but with your code in first screen and menu options , like, option 2, adjust alarm to day, hour, option 3 another code. Thank You very much, and sorry for my Bad English, i'm try learn more, lol.


    6 years ago on Introduction

    Hi Arick,

    Would you provide a download link for the DS1307 Arduino library, which you use?. I have found a lot of versions and implementations, but I would like to try with something which is proven on Arduino Mega 2560.

    Best Regards