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

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
  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 ;)

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


Thanks for reading, and good luck for your experiment