Introduction: Getting Started With Arduino Yún and ChronoDot (v2)

A quick guide to getting started with the ChronoDot (v2) and Arduino Yún.

Step 1: Insert Battery

The battery is a 3V lithium CR1632 coin cell, one is provided with every ChronoDot purchase. You should install the battery before use, to prevent loss of timekeeping during power off cycles. Simply remove the CR1632 battery from its packaging, and slide into the battery holder. Please ensure the top (marked +) side of the battery is facing the top of the battery holder (also marked +).

Quote from http://docs.macetech.com/doku.php/chronodot_v2.0

Step 2: Connect to Arduino Yún

Connect the ChronoDot's pins to the Arduino Yún as follows:

[white] GND to GND (Ground) of the Yún.
[yellow] VCC to 3.3V or 5V (the ChronoDot takes both)
[brown] SCL to SCL
[orange] SDA to SDA

(SDA and SCL should not be connected to A4 or A5 as with Arduino Uno!)

Step 3: Add Some Code

Import the following library by going to: Sketch - Import Library (then choose the .zip file) in the Arduino software.

https://github.com/adafruit/RTClib
(Download .zip)

When unzipping the file make sure to remove the "-master" because the Arduino Software doesn't take it. Rename the folder to RTClib and choose it then.

Add the following code to your project (credit to IAquaponics):

I also added the .ino file as an attachment for your convenience.

// Date and time functions using a DS3231 RTC connected via I2C and Wire Lib

#include <Wire.h> #include "RTClib.h" // Credit: Adafruit

RTC_DS1307 RTC;

void setup() { // Begin the Serial connection Serial.begin(9600); // Instantiate the RTC Wire.begin(); RTC.begin(); // Check if the RTC is running. if (! RTC.isrunning()) { Serial.println("RTC is NOT running"); }

// This is optional: Force timeset. delay(5000); Serial.println("Forcing TIMESET"); RTC.adjust(DateTime(2000, 1, 21, 3, 0, 0));

// This section grabs the current datetime and compares it to // the compilation time. If necessary, the RTC is updated. DateTime now = RTC.now(); DateTime compiled = DateTime(__DATE__, __TIME__); if (now.unixtime() < compiled.unixtime()) { Serial.println("RTC is older than compile time! Updating"); RTC.adjust(DateTime(__DATE__, __TIME__)); } Serial.println("Setup complete."); }

void loop() { // Get the current time DateTime now = RTC.now(); // Display the current time Serial.print("Current time: "); Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); delay(1000); }

Press upload and open the serial monitor - you should see the current time.