ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Digital Clock with Temperature Sensor DIY

Updated on August 27, 2013

You can see in stores digital clocks laying around, but it’s too much fun to make one than just to buy. After that every time you look at your clock it will make you proud.

Everything from top to bottom is listed here, and every step what to do. If you still get stuck I will be there to help you.

Digital Clock
Digital Clock | Source

What it will give you

1. Uninterrupted Time.

This means if your power is of for a few days, there is no need to reset you time, just like your computer. It uses the 3v extra battery to keep your time up to date.

2. Date with day.

Shows the day with help of 7 leds.

3. Temperature.

Uses LM35 temperature sensor for sensing room temperature.

LED Displays
LED Displays | Source

What will you need

Mainly some small skills and some electronic components.


  1. Little bit of idea about electronics.
  2. Soldering technique.
  3. PCB making skill (optional).
  4. Drilling skill.


  1. 1 fiberboard depending on the size of your clock that you wish to make, mine was about 6 x 14 inches. Search for a thin and stiff one (3mm thickness max).
  2. ICs:
    1. ATmeag16.
    2. DS1307.
    3. 2 x 74HC138.
    4. 2 x CD4511.
    5. LM7805.
  3. Resistors:
    1. 1 x 10k.
    2. 15 x 100Ohms.
    3. 7 x 68Ohms.
  4. Capacitors:
    1. 8 x 0.1uF.
    2. 1 x 1000uF.
    3. 3 x 10uF.
    4. 2 x 22pF (optional).
  5. IC holder:
    1. 1 x 40pin.
    2. 1 x 8pin.
    3. 4 x 16pin.
  6. 3v Battery and its holder.
  7. Xtal 32.768KHz (One of the most important this controls the heartbeat of your clock, so make sure it’s a good one)
  8. 37 straight berg pins both male and female.
  9. Lots of colored wires, preferably at least 7 colors.
  10. Vero boards depending on your need. (I only used 5 small as my main board was on pcb).
  11. And the last but not the least, an avr programmer. You can buy one or build one, here are two links to build one:
  • USB Programmer.
  • Serial Programmer.

Simple Question

Why do you like electronics?

See results

Finally the steps

There are few simple steps to success, it took me 1 month. Okay, actually I was lazy you can do it in about 1 week.

Board | Source
Sketch on the board
Sketch on the board | Source
Click thumbnail to view full-size
Board 1Board 2Board 3Board 4Board 5Board 6
Board 1
Board 1 | Source
Board 2
Board 2 | Source
Board 3
Board 3 | Source
Board 4
Board 4 | Source
Board 5
Board 5 | Source
Board 6
Board 6 | Source

Step 1: Build the board

My chassis was on a fiber board, cut it in a desirable size you want. It is not necessary to stick to my design, design you own, be creative. So,

  1. Cut it out in a desirable shape.
  2. Glue a white paper on one side of the board.
  3. Mark the shapes and sizes of you 7 segment leds, where you want to place it, by placing it upside down on the board.
  4. Now take a vero board where your 7 segment led fits, and make marking on the hole where the pins of the display passes.
  5. Make markings on your vero board as per size your display.
  6. Place it on top of your fiber board and drill through the holes which of them were marked.
  7. Drill the holes for the leds in the same way, and remember the drill the holes for their resistor too (Use some desirable resistors there it may be from 60 Ohm to 300 Ohm).

It is stinky job, I know. Don’t faint if you make mistakes. I made many mistakes during this step, but those mistakes got hidden under the display.

Connections | Source
Click thumbnail to view full-size
Connection 1Connection 2Connection 3
Connection 1
Connection 1 | Source
Connection 2
Connection 2 | Source
Connection 3
Connection 3 | Source

Step 2: Making the connections

There are few simple steps, don't get afraid by the pictures. I know it's looking like some massive and complex wiring, but actually it's too simple and straight connections.

  1. Firmly put all the displays through the drilled holes.
  2. Now cut the vero board as per required size and place it on the pins of the display on the other side of the board as shown in pictures.
  3. Solder the pins of all the displays.
  4. Now do the same for the rest of the leds and resistors.
  5. Make the connections, it is simple, if you see the schematics you will get to it.

This will take a little bit of time and patience, there are many pins where two wire emerge, so don't make the mistake of soldering one pin twice, just twist one pair of wire and solder it to the pin once.

Remember to use 7 different colored wirer for each segment, this will make your work a lot easier.

We will do the connection to the header later.

Main Board
Main Board | Source
Click thumbnail to view full-size
Borad 1Board 2Board 3PCB 1PCB 2
Borad 1
Borad 1 | Source
Board 2
Board 2 | Source
Board 3
Board 3 | Source
PCB 1 | Source
PCB 2 | Source

Step 3: Making the main board. The Brain

It is the most important part of this project, try to do it very seriously. I did it on a printed PCB made by me by the toner transfer method you can also do it on a vero board, it need to big (maybe 4 by 4 inches). Just make sure that its dimension is less than the fiber board.

  1. (Optional) Make the PCB by using my design or you can design your own.
  2. Place the components (IC Base, capacitors, resistors etc.), don’t solder the ICs you don’t want to get your microcontroller get burned.
  3. Place your male berg headers on the other side of the board by using my method, you can see it on the images.
  4. Check your connections carefully.

NOTE: While putting the resistance in between the CD4511 IC, 100 Ohm resistance will not work always your display may get dim, you have do some experiment with it. As you see in the images I used no resistance between the first IC which controls my bigger displays (but that is not a good practice). Bigger displays will need less resistance than smaller one to make it look as bright as the other. But I think 100 Ohms between smaller one and 40 -60 Ohm will be perfect. If you are using the same size displays all over there’s no need to worry about this.

Done! Quick description but a long process. If you do it on a printed PCB things will be neat and you don’t have to do all the messy connections beneath it, but if you do it do it carefully, because mine was not so neat, I faced the problem of connection breakage when I debugging my code, it was really frustrating.

Connectors | Source
Connector | Source

Step 4: Making the connectors

It is a simple step but needs concentration, you will need this headers for connecting your main board to the displays. You will need about 40 female header in this, be specific with female headers because we used male header on the board.

  1. Map your headers of the board.
  2. If you followed my PCB diagram you can divide your headers into 4 different parts and solder it to a vero board, just make that sure if the fits firmly side by side, so for safety first insert the female one to the males and the solder the females to the vero board. Or, if you made your own board just find a way to fit it on the fiber board just make sure that they fit and been placed firmly.
  3. Now take the help schematic diagram of the displays and connect the respective header to the anode pins of the displays, there will be 14 pins of these.
  4. Now time to connect the cathode pins, you have to know the pins of the IC 74HC138, see the image. The Y0 – Y7 is the selector pins, connect the cathode pins of the big displays respective from left to right to the selectors pins of first 74HC138 IC from Y0 to Y5. There should be 6 pins.
  5. Now by the same way connect the pins of the smaller display, there should be 8.
  6. Now the pins of the leds (AM, PM and day indicators) connect the cathode that is from the resistors to the respective headers.
  7. Connector the powers pins to the power supply.

We will take about powers supply and temperature sensor after this.

Do this step correctly by using the help of the pictures I provided if there is any problem you are always free to comment.

The Temperature Sensor
The Temperature Sensor | Source

Step 5: Connecting the temperature sensor

It is a very very simple step.

  1. You can see the output pins for the temperature sensor in the main board, just connect those header by the side of the power pins to another 3 pin of female berg pins so that you can move your sensor anywhere and remove it any time.

Done! :-)

Power Supply
Power Supply | Source

Step 6: Connecting the power supply

As you see the circuit there are two inputs of power. We have to supply the circuit exactly +5V, 1Amp. If you give a little less the displays will become dim, and if you give much more than that your microcontroller may blow up because they don’t like voltages above 5.5V. So you have to build a power supply and use a suitable to work properly.

  1. Place the components of the circuit of the power supply that I provided on a vero board and cut it down.
  2. Now solder the components on it and make the connections.
  3. Now for connecting it to the board you can use headers or you can connect it directly.
  4. Now place all the circuits (headers for the main board and power supply) with the help of Velcro or double sided tape.


You must use an adaptor of 12V,1 Amp rating don’t use less or more than that.

You must use a big heat sink for the LM7805 IC as it is not an LDO it will produce a hell lot of heat, and it is required for supplying 1Amp current to the circuit.

Though it is a digital circuit it does many switching jobs between few microseconds so eventually if you don’t give the required current to the circuit it will become dull.

Step 7: Programming the microcontroller

It is like teaching the circuit how to work. As all the hardware jobs done now time for the software. You will need some of the extra things to do this like a breadboard and a avr programmer. If you followed my whole tutorial and did all the things what I have done then you will be burn the firmware directly to the microcontroller or tweak with my code to match your own circuit.

  1. Buy a avr programmer. Like USBasp.
  2. Learn to program a avr by following this site. Site: NewbieHack
  3. There are several files in my firmware, if you are using programmer’s notepad then copy and paste the whole of Digital_Clock.c in a new project and save it.
  4. Now copy the rest of the file in the same folder where you saved it.
  5. Now open DS1307.c in notepad and uncomment the _ds1307_timer_initialization(); function by removing the two slashes before it.
  6. Now go to the end of that file you will see that there are field for date time and everything but it is in BCD format. You got to fill the time in that way like if the minute is 52 you have write there 0x52.

Example code: For 12th August 2013 Monday 11:27:00AM

  i2c_start_wait(DS1307_ADDRESS + I2C_WRITE);
  i2c_write( DS1307_SECONDS );
  i2c_write( 0x00 );          		//seconds
  i2c_write( 0x27 );         		//minutes
  i2c_write( 0x11 | 1<<6 | 0<<5 );      //12-hour mode, hours
//i2c_write(0x40 | 0x23 );   		//24-hour mode, 11PM
  i2c_write( 0x02 );         		//day
  i2c_write( 0x12 );         		//date
  i2c_write( 0x08 );         		//month
  i2c_write( 0x13 );         		//year
  i2c_write( 0x90 );         		//output 1Hz squarewave 


The day ranges between 01 – 07.

The AM PM is denoted by 0<<5 place in the hour field, 0<<5 means AM, 1<<5 means PM. Don’t mess with the 1<<6 value.

Set 5 minutes past your time like if your time is 1:30 PM set it as 1:35 PM.

7. Save the file.

8. Make the make file.

9. Make the hex file.

10. Program it.

11. Place it in the main board.

12. Power it for a second when your time got there what you had programmed, you should see your time. Then remove it again.

13. Program it again with the _ds1307_timer_initialization(); function commented out by giving the two slashes again before it.

14. Save it, program it and you are done.

If you are a newcomer it would seem a little bit tough to you, but if you do some simple programming before this, it would be a lot easier. I will recommend you to do some simple programming before doing this job.

Click thumbnail to view full-size
Digital clockDigital clockDigital clockDigital clockDigital clockDigital clock
Digital clock
Digital clock | Source
Digital clock
Digital clock | Source
Digital clock
Digital clock | Source
Digital clock
Digital clock | Source
Digital clock
Digital clock | Source
Digital clock
Digital clock | Source


So, we are all done. Lastly if you are creative design a beautiful frame for it or leave it like that.

Just make sure your 3v battery don’t get off, if it happens then your whole clock will be reset and you will have to program it again.

And if your clock runs slow or fast then the only problem is with your crystal, buy a good one then and program it again.

If you do anything with your DS1307 part you will have it to program it again otherwise if you mess around with the other component with your board it will still work fine after you put back it again.

Let your clock run at least 4 hours a day otherwise your 3v battery will discharge fully and after you replace it you will have to program it again.

Leave your comments and I will be always there to help you.


This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

Show Details
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)