My first Arduino project - A clock

Hey guys I decided to start my first Arduino project! I also just joined this forum today so I'm a newbie here. I was hoping if you guys can provide some guidance along the way for my project, I'm planning to make a clock. The clock I'm making is very important to me, not only because it's my first project but I also want to give them as gifts to two friends of mine for their birthdays. I'm hoping to learn from this intelligent community of people and hopefully one day contribute to ideas of others. So without further ado here's what I'm using and what features I want for my clock:

Project : Clock Microcontroller (mc): ATmega328 - Arduino Uno platform

EDIT After taking suggestions from you guys I came up with a parts list, most of which I already have. I would just like some advice on coding and a good way to put it together.

[u]Parts:[/u]

  1. DS321 Module - http://dx.com/p/high-accuracy-ds3231-module-w-temperature-battery-blue-168974
  2. Basically an RTC with a temperature sensor, just need help on coding and how to retrieve both time and temperature reading.

  3. Standard 16 x 2 LCD screen - http://www.engineersgarage.com/electronic-components/16x2-lcd-module-datasheet

  4. I think I'm just going to read up on the library on how to use this but would love to hear any suggestions or ideas.

  5. Infrared Sensor - http://www.creatroninc.com/index.php/sensors/distance-sensors.html

  6. Use this to shut off an alarm with the wave of a hand, any useful hints on coding would be greatly appreciated.

  7. Buzzer - Self explanatory

5 . Buttons - Haven't bought enough, but I want a smart way to change the alarm settings, change pre -programmed text to show on LCD, another way to to shut off an alarm and go into various mode settings. Any help in this aspect is greatly appreciated.

As for the power supply, should I use a wall mounted one or a standard 9V battery? Would everything reset if I change the battery, I understand the RTC chip itself has it's own battery but not sure about the rest. Thank you guys!

You haven't told us on what you intend to display the current time. Analog clock face, LCD, LED array or VGA monitor?

Has an alarm function - I have a buzzer, I'm guessing the rest is done with programming. I'm guessing interrupts.

No need for interupts if (current time >= alarmSetTime) while(alarmReset not pressed) sound the alarm.

Welcome to the community Dan.

It's all doable. I'd use and RTC module as the Arduino by itself might not be accurate enough to bother broadcasting it's time around the world. I do not see the need for interrupts in this application. Memory might be a tad tight to run an RTC library, an Ethernet library and a WiFi library, but it should all fit if care is taken.

Thank you for the alarm idea, I will certainly use that. I think my biggest challenge is going to be WiFi, would I still need an Ethernet library if I’m going to go wireless on this project?

Not too sure. While I've done lot's of projects that use Ethernet, I've not added WiFi. Perhaps the WiFi libraries also contain teh IP stack. We'll need to wait for people with actual WiFi experience to chime in.

I'll be waiting for them! I'll try doing some research aswell. Thanks!

Since I'm on a tight budget I am making two of these clocks, I think number 4 (WiFi) is too costly to implement. But would love to learn how for future projects.

Hi Dan,

I can reccomend one of these:http://www.google.co.uk/url?sa=t&rct=j&q=deal%20extreme%20ds3231&source=web&cd=1&cad=rja&ved=0CEEQFjAA&url=http%3A%2F%2Fdx.com%2Fp%2Fhigh-accuracy-ds3231-module-w-temperature-battery-blue-168974&ei=hHzRUbGnKIvY9ASRy4CoAw&usg=AFQjCNGndZSbBZC0bCv21TxNLZHF4QW4iA&bvm=bv.48572450,d.eWU

I've used one on a clock project and they are highly accurate and also have a built-in temperature sensor and alarm functions. It connects to the Arduino via an "I2C" interface. The library for this called WIRE I believe.

For power, the simplest option could be 3xAA or maybe 4xAA cells. If using 4, only rechargeables should be used. 4 non-rechargeable cells might be more volts than the Arduino will be happy with. Alternatively, a "wall-wart" type adaptor could be used if you build a voltage regulator circuit into your board. A 78L05 regulator should provide enough current for what you are describing (except for the WiFi stuff, which is too complex for a first project anyway). You will need some 10uf and 100nf capacitors to help with smoothing the supply also.

What kind of display were you thinking of? LED, LCD...

Paul

Hey PaulRB,

Thank you for your reply, I just noticed its free shipping in Canada which is awesome! I'll check with my local hobby shop if they have it stock as well. Is there any sample code for this piece of hardware to help me understand how to code the alarm functions or read temperature? I want an LCD since to give both temperature reading and the current time. I do have a 4 -digit seven segment display but I think I'll need shift registers to save on pins possibly but it may complicate the design. I think going with a AC adapter and voltage regulator circuit is a good approach, also do you have any advice on how to set the time, should I do it via buttons and how? Thank you for advice and showing the site!

DanT29: Is there any sample code for this piece of hardware to help me understand how to code the alarm functions or read temperature?

I don't have any Arduino code, Dan, I used this RTC with a different micro-controller, but I will do my best to help. It was pretty straight-forward with the other uC, so I expect it will be easy with Arduino also. Google for the datasheet for the 3231 chip that the RTC uses. The datasheet is a long and complicated document, but don't worry. The only things you really need to know are the address that the chip uses on the I2C bus, and the locations of the registers for the day/month/year, hour/minute/second, temperature, alarm hours/minutes etc. They will be on a table on one page of the data sheet. Then read some of the Arduino tutorials on using the I2C bus (WIRE or TWI libraries) and ask any questions. I know all the theory, but not the details of how to do this stuff with Arduino, but I'm sure others will help. Also Google for "Binary Coded Decimal". You will need to understand that to write your sketch to set or read the time from the RTC chip.

DanT29: I want an LCD since to give both temperature reading and the current time.

A 16x2 character LCD with an I2C interface may be your easiest option. You won't need any more pins at all, as both the RTC and the LCD can share the same connection to to the Arduino. They will have different "addresses" on the I2C bus.

DanT29: I do have a 4 -digit seven segment display but I think I'll need shift registers to save on pins possibly but it may complicate the design.

You may not need a shift register for the LED display, or any other driver chips. Probably just 12 pins, using "multiplexing". Multiplexing is where it appears to the eye that all 4 digits are lit, but if you had a high speed camera you could see that actually only one of the 4 is lit at any one instant in time. This is a little more advanced technique from a programming point of view compared to the LCD, and its important to keep things simple for your first project, then build your skills up.

DanT29: do you have any advice on how to set the time, should I do it via buttons and how?

You may not need to set the time again, once it has been set once, because the RTC is very accurate. Maybe a button to reset the seconds and minutes to zero once per year or so as needed. You will need buttons to set the alarm time, or maybe a potentiometer and a button to allow the user to "dial-up" the hours/minutes and press the button to enter.

DanT29: Thank you for advice and showing the site!

That site is not the only one that sells that RTC. Check out eBay also. Shop around!

My advice would be to work on breadboards while you are working out your design. That's just because I happen to like them. I use the smaller ones that I can clip together into different configurations for each project. My first Arduino is a Nano instead of an Uno for example, so I can plug it straight into the breadboard.

Paul

Thank you Paul! I will try searching for that RTC, it seems to do all I want in one chip. I'll also look for an LCD with an I2C interface, I'm guessing there's cheap ones online. I like your idea of the potentiometer to dial through the numbers, it should save the user time from clicking. I would probably need help setting up the alarm set up but hopefully everything goes well. I'll keep you updated on which parts I ended up buying, probably order/buy them this week! I appreciate the help!

This one is not i2c, but it does say it works with one of the Arduino libraries, so that may make things easier. Also has some buttons!

http://dx.com/p/lcd-keypad-shield-for-arduino-duemilanove-lcd-1602-118059

This one is i2c:

http://dx.com/p/funduino-iic-i2c-1602-lcd-adapter-board-w-2-5-lcd-screen-black-green-red-173588

And the rtc on ebay:

http://www.ebay.co.uk/itm/mini-RTCpro-DS3231-high-precision-clock-module-environment-temperature-measure-/390521397685?pt=LH_DefaultDomain_0&hash=item5aece3a1b5

Thank you for the links, just out of curiousity does first LCD (with buttons) you showed doesn't it only connect to the duemilanove board only or can the Uno work? I will be removing my microcontroller from my board so I can put on a smaller breadboard or solder it with other components. I want to keep the the arduino board as a programming circuit so I can just buy the microcontrollers that already have the bootloader (not sure if this is correct terminology). As for the I2C is there any references you have on how to make it work? I know its different from a regular one, from what I read finding the address is the hard part.

I also think this board is good, just need to solder headers in, its cheap too!

http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356

DanT29: I also think this board is good, just need to solder headers in, its cheap too!

http://dx.com/p/16-x-2-character-lcd-display-module-with-blue-backlight-121356

This may be a better choice... http://dx.com/p/arduino-iic-i2c-serial-blue-backlight-lcd-2004-module-display-138616

It already has the I/O expander attached and ready to go. (A way to control all 16 pins of display with just a few from Arduino.)

Dan, I don't think the duemilanove is any different to the uno, or most other arduino boards, when using components like lcds. I don't know why seller chose to mention that particular model, I suspect they dont know either!

That other lcd should be fine but will use more pins on the Arduino: probably 6 or 7 vs. 2 for i2c. This may nof be a problem for you. The lcd library will take care of the complex details for you, I suspect. There are also libraries for i2c and rtcs. But like I said before, I'm a newbie to Arduino too.

Paul

Paul you seem to very knowledgeable about arduino :), thinking about it now an i2c LCD would be good, if I want to add a way the user can input a message to be shown later. I was thinking probably inputting it from their smartphone via bluetooth? Not sure if that's too much at this point.

1ChicagoDave: This may be a better choice... http://dx.com/p/arduino-iic-i2c-serial-blue-backlight-lcd-2004-module-display-138616

It already has the I/O expander attached and ready to go. (A way to control all 16 pins of display with just a few from Arduino.)

That is looks really good, the only thing stopping me is the price, since I would need to buy two (trying to make two clocks). I'll consider it for future projects. According to reviews the display is really nice as well.

DanT29: thinking about it now an i2c LCD would be good

Can someone more experienced with Arduino than me please comment on this? Should a newbie stick to connecting a 16x2 character LCD via parallel connections or would I2C be just as easy? I don't know the libraries well enough yet to be sure.

DanT29: if I want to add a way the user can input a message to be shown later. I was thinking probably inputting it from their smartphone via bluetooth? Not sure if that's too much at this point.

I would say that is too advanced for a first project. Get the basic stuff working first. If you try to run before you can walk you will only loose enthusiasm when you can't get it all to work together.

I'll keep it simple at this point, I think the main objective is to learn and walk as you said! Just felt like I can do more with the LCD like write a message instead of just showing numbers! I will post a part list before I start ordering just to double check.

BUMP - I changed my initial post I made, please have a read I appreciate any help you guys can give!