MySQL for the Internet of Things

(Steven Felgate) #1
Chapter 4 ■ Data transformation

An RTC is needed to ensure accurate time keeping because the clock (a special crystal or similar
mechanism that generates a pulse) that is used to advance instructions in the processor (microcontroller)
does not pulse or cycle at a frequency that can be used to accurately calculate time. Furthermore, RTC
circuits have a battery to power a small amount of memory to store a value for the time (sometimes seconds
since a specific epoch). Thus, boards without an RTC must be either programmed with a starting date and
time or instructed to get the date and time from a time server on the Internet.
Fortunately, there are several excellent products that perform well and include an onboard battery that
powers the clock even when the board is powered down. Adafruit’s DS1307 Real Time Clock breakout board
kit (www.adafruit.com/products/264) is an outstanding module to add to your project. Sparkfun also has a
product named Real Time Clock Module (www.sparkfun.com/products/99) that uses the same DS1307 chip
and interface as the Adafruit offering. You can use either with your Arduino, Raspberry Pi, or any board that
has an IC2 interface.


Using a Real-Time Clock Module


The RTC module uses an I2C interface that is easy to connect to the Arduino. Simply connect 5V power to
the 5V pin, ground to the GND pin, the SDA pin-to-pin 4 on the Arduino, and the SCL pin-to-pin 5 on the
Arduino. Figure 4-1 shows the wiring diagram for connecting the RTC module to an Arduino.


Figure 4-1. Arduino with an Ethernet shield and RTC module


■Note if you are using the Leonardo board, you have to use the new sCL/sCa pins located next to aref,


GnD, and pin 13 nearest the UsB connector.

Free download pdf