A fundamental necessity of any controls system is the ability to track time. As far as we are aware, the Arduino has three methods it can employ:
- Serial. Repeatedly get the time over the Serial connection.
- External Hardware. Real-time clocks, like the ChronoDot from Macetech, establish a base time when the Arduino sketch is compiled. When you request the current time in the sketch you actually receive a time based on the time that has elapsed since compilation.
- Ethernet. Access time using the internet NTP service.
This tutorial set focuses on option 2. In Part I we explain the basics of getting the ChronoDot set up and displaying the current time over serial.
The ChronoDot is a high precision real-time-clock (RTC) and boasts a number of features needed for Aquaponics. The V2.1 release introduced the DS3231SN chip, which has an industrial temperature range of -40C to +85C and outputs a temperature compensated time - important for aquaponic control systems that reside outdoors in the heat and direct sun.
|Figure 1. The ChronoDot V2.1, credit Macetech.|
The ChronoDot includes an onboard battery cell for a CR1632 battery, allowing the clock to keep track of time should the Arduino lose power, regain power and restart. Anyone in aquaponics can appreciate the ability of a control system to automatically reboot and resume operation in the event of a power glitch. The disadvantage of the ChronoDot, and RTCs in general is the inability to handle Daylight Savings Time.
The Environment DAQ can be configured with the ChronoDot using the prototyping area, which is exactly wide enough to handle the RTC (coincidence?). If mounting to the shield, you can access the pins from the bottom.
1 x ChronoDot
1 x Arduino Uno R3
4 x Jumper Wires
4 x Jumper Wires
Mounting the ChronoDot
The Fritzing diagram below shows how to connect the ChronoDot to the Arduino. Note that the RTC connections are on the right-hand side - the pins on the other side are not used.
|Figure 2. Connecting the ChronoDot.|
The ChronoDot requires two libraries
- Wire.h - Included with the Arduino
- RTClib.h - Download here.
Download the zip file and extract it. If necessary, rename the extracted folder "RTClib", and then move a copy into your Arduino libraries directory.
Part I of this tutorial simply outputs the current time from the RTC to Serial; part two shows how to set create a toggle time.