Feedback!

MCP79410 Breakout Board

Views: 7447 Difficulty: 2 Status: Complete
Ds1307_main2

The MCP79410 breakout board gives easy access to this cute little timekeeper.

What is time?! Not sure really... but this quarter-sized clock-shaped PCB help you keep track of it. This cute little clock shaped breakout board is available in our store. While micro-controllers, like the Arduino, count very easily and accurately they start over as soon as they are powered down. To keep track of the time after a chip is turned off you can use and RTC chip, like the MCP79410 or a DS1307, and a small lithium battery. Now, whenever the micro-controller wants to know the time, it can query the clock chip over the I2C (Two Wire Interface). This chip is useful if you want to build watches or clocks that don't need to be reset every time they are powered on.
We switched from the DS1307 clock to the MCP79410 because the MCP79410 can run on lower voltages (You might still notice some silkscreen labels for the DS1307). The DS1307 needs 5 volts. Luckily the two chips are pin compatible. We have written a little Arduino library for working with the MCP79410s which we will describe in this tutorial. This chip and library is also used in our Wearable Wayfinder and our Heart Matrix to keep track of the time. If you want to build one yourself adafruit has a nice DIY soldering Kit for the DS1307.

The MCP79410 Breakout Board

Ds1307_angle
Check out the board wired up and ready to go!

Arduino Code for MCP79410 with Serial Output

This code reads the time from an MCP79410 clock chip and outputs the current time formatted as a string to the serial output. To set the time, you can un-comment the line:
//clock.setDateTime(__DATE__,__TIME__);
However, you should then comment this line out and upload the program to the Arduino again, otherwise every time you power up the Arduino the time on the MCP79410 chip would be reset. There is a way to query the MCP79410 to find out if the time has been set already but this little hack has worked for us. If you get the is running query working let us know in the comments! The full code is below.
/* LucidTronix Real time clock MCP79410 library
 * Serial output example.  See tutorial at:
 * http://lucidtronix.com/tutorials/59
 */
#include <Wire.h>
#include <MCP79410.h>

String stime = "";
unsigned int last_update = 0;

MCP79410 clock = MCP79410();

void setup()
{
   Wire.begin(); 
   Serial.begin(9600);
   // Uncomment this line to set the time
   // Upload code a second with it commented out 
   // so time doesn't always reset at startup
   //clock.setDateTime(__DATE__,__TIME__);
}
 
void loop(){
  if (millis() - last_update > 1000){ // update every second
    stime = " ";
    byte a_hour = clock.hour24();
    String a_hour_s = String(a_hour,HEX);
    int hour_int = a_hour_s.toInt();
    String ampm = "am  ";
    if (hour_int >= 12){
      ampm = "pm  ";
      if (hour_int > 12) hour_int -= 12;
      a_hour_s = String(hour_int);
    }
    if (a_hour == 0 || a_hour == 12 ) stime += String(12); 
    else stime += a_hour_s;  
    stime += ":";
    byte a_min = clock.minute();
    if (a_min < 10 ) stime += String(0);
    stime += String(a_min,HEX);
    stime += ":";
    byte a_sec = clock.second();
    if (a_sec < 10 ) stime += String(0);
    stime += String(a_sec,HEX);
    Serial.println(stime + ampm);
    last_update = millis();
  }
}

MCP79410 Arduino Library

Download the library here! Unzip it and move it into your Arduino libraries folder. Quit Arduino and restart and then check out the example code under File > Examples > MCP79410 > mcl_79410_serial
Click Here to Download: MCP79410 Arduino Library

Parts

Title Description # Cost Link Picture
PCB DS1307 Breakout Board Breakout board for the DS1307 Real time clock chip. Uses I2C protocol. 1 $4.5 Link Ds1307_breakout_pcb
Clock MCP79410 Real-Time Clock Chip I²C, 2-Wire Serial 1.8 V ~ 5.5 V Alarm, Leap Year, Square Wave Output, SRAM, Unique ID Value: I²C 1 $1.08 Link 8-soic
Crystal 32.768KHZ 12.5PF SMD 32.768KHz crystal oscillator for use with DS1307 RTC chip. Value: 32.768kHz 1 $0.94 Link Ecs-2x62_series
Battery Lithium Coin Cell 3V 12.5MM Batteries Non-Rechargeable (Primary) Lithium Coin, 12.5mm 3V 36mAh Value: 3V 1 $0.71 Link Cr1220
HOLDER COIN CELL 12MM SMD Coin Cell, Retainer PCB, Surface Mount SMD (SMT) Tab Value: Coin, 12.0mm 1 $0.49 Link Bk-885-tr
LED SMD LED 3X1.5MM 568NM Green Clear SMD Value: 2.2V Green 1 $0.18 Link Apl3015sgc-f01
Resistor SMD 2.2K 0805 Surface Mount resistor 2.2k ohm, 0805 package. Value: 2.2k 2 $0.1 Link Crsm_pt0805
Resistors RES 300 OHM 1/8W 5% 0805 SMD Value: 300 1 $0.1 Link Screen_shot_2012-12-28_at_7.28.51_pm
Permalink: http://lucidtronix.com/tutorials/49
Build your own clock with the MCP79410 chip and 4 7-Segment LED modules....
The Wearable Wayfinder is a totally programmable, beautiful little computer for your wrist packed wit...
Standalone programmable Heart-Shaped LED display....
A wearable real-time clock with vibrant color display....
A breakout board for an electret condenser microphone shaped like an ear....
Connecting the MCP79410 real-time clock chip and our Heart Matrix you can show the time with love....
Use the Wearable Wayfinder and the MCP79410 Real time clock chip to make an Arduino alarm clock....
The 74HC595 shift register controls a 10 LED Bar Graph....