loading
Picture of 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 : http://rickelectronicproject.blogspot.com.au/

 
Remove these adsRemove these ads by Signing Up

Step 1: Preparing the material

Picture of Preparing the material
IMG_20130522_090415.jpg
IMG_20130522_090352.jpg
IMG_20130522_090346.jpg
IMG_20130522_090335.jpg
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

Picture of Connect your arduino to LCD,RTC and NTC
IMG_20130522_092215.jpg
IMG_20130522_092149.jpg
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

Picture of 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
  rtc.halt(false);
  Serial.begin(9600);
 
  // 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
  rtc.setSQWRate(SQW_RATE_1);
  rtc.enableSQW(true);
}

double Thermister(int RawADC) {
  double Temp;
  // See http://en.wikipedia.org/wiki/Thermistor 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);
  lcd.print(rtc.getTimeStr());
  //Read temp sensor
   double temp = Thermister(analogRead(0));  // Read sensor
   //print screen
   lcd.setCursor(10,0);
   lcd.print(temp);
   lcd.print("C/");
 
  // Display abbreviated Day-of-Week in the lower left corner
  lcd.setCursor(0, 1);
  lcd.print(rtc.getDOWStr(FORMAT_SHORT));
 
  // Display date in the lower right corner
  //lcd.setCursor(6, 1);
  lcd.setCursor(3, 1);
  lcd.print(",");
  lcd.setCursor(4, 1);
  lcd.print(rtc.getDateStr());

}
================

Step 4: Enjoy your own clock and thermometer ;)

Picture of 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
arick (author) 6 months ago

More projects..

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.

alisoneletricista@hotmail.com

arick (author)  curitiba.designers11 months ago

Which code ?

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.

Milen2 years ago
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
Milen