down, which holds the IC in place and ensures that all
other pins on the IC are perfectly placed over their pads.
If the IC is not perfectly centered over all the pads, melt
the solder by placing the tip of the soldering iron on the
pin, and reposition it.
LCD. They are: Display_Time(), Display_Date(), and
dateString() — the latter to concatenate the month, day,
and year into a single string.
There are also functions to initialize, set, and read the
RTC. Here are their prototypes:
Next, press the pin down on the diagonally opposite
corner, melting the solder under the pad. The IC is now
held firmly in place and should be perfectly aligned.
// Set the LCD I2C address for 20x4 LCD
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7,
// Necessary variables
byte second, minute, hour, ampm, dayOfWeek,
dayOfMonth, month, year, f1224;
Next, apply the smallest amount of solder possible to
the top of each pin, without bothering to see if the solder
joint is perfect. The smallest amount of solder will do.
Often, it is all right to go on to the next pin without
adding solder; touching it with the soldering iron tip will
deposit a small amount of solder still adhering to the tip.
// Initialize DS3234
With a small amount of solder on each pin top, go
back and slowly swipe each pin with the soldering iron
tip, moving away from the IC body and melting the solder.
If the solder bridges two pins, place the tip between the
pins and pull it off with the tip.
// day(1-31), month(1-12), year(0-99),
// dayofweek(1-7) Sun = 1,
// ampm(0-1) 0 = am, 1 = pm, hour(0-23),
// second(0-59), 12/24 hr, (0-1) 0 = 24 hr.,
1 = 12 hr.
If this happens, too much solder has been used. If
extra solder accumulates on the tip, wipe the tip with a
slightly wet paper towel. It is important to keep the tip
clean using this method. If the circuit is not working, try
going back over the IC pins with the soldering iron tip.
// Set Time and Date info
void SetTimeDate_DS3234(byte d, byte mo, byte y,
byte dw, byte ampm, byte h, byte mi, byte s,
Sometimes a pin can look well soldered, but is not, or
there is a solder bridge between two pins.
The Arduino software is fairly simple. The main
program loop basically reads the clock and then — given
the current time — checks to see if a relay needs to be
turned on or off.
// Read Time and Date info
void ReadTimeDate_DS3234(byte *second, byte
*minute, byte *hour, byte *ampm, byte
*dayOfWeek, byte *dayOfMonth, byte *month, byte
The SPI library is included for communication with the
The relays are controlled by simply connecting the
input pins on the relay board to digital pins on the Nano,
and setting the digital pin output to HIGH to activate the
relay or LOW to deactivate. These three functions handle
the operation of the relays:
The Wire library allows use of the I2C two-wire bus:
// Set Start Time
// Channel number 1-2, hour, minute, AM or PM
void setStartTime(byte chan, byte h, byte m,
The LCD display is one of several different types
available and comes with a built-in interface for I2C two-wire communication. This model used the
// Set End Time
void setEndTime(byte chan, byte h, byte m, byte
LiquidCrystal_I2C library and compatible settings when
initializing the LCD object. Be aware that these settings do
vary with different LCDs:
// check Time
There are three functions to simplify the use of the
setStart Time sets the channel number (the relay to be
used) and the time to activate it. setEnd Time sets the
channel number and the time to deactivate it. In all cases,
only the hour and minutes are used. check Time checks
the time against set times for activating or deactivating the
relays and acts if necessary.
34 August 2016