Real-Time Clock - Part II: Grow Light Controller

In Part I of this tutorial, you learned how to set up the ChronoDot  with the Arduino and use it to track time.  Part II continues the discussion by creating a timer that can be used to control grow lights.

In a previous post we talked about the importance of light for plants and the role grow lights play in Controlled Environment Agriculture either by monitoring current light levels and providing supplemental light, or by providing all of the light for a fixed time every day.  Part II focuses on the latter, creating a timer which toggles a light on at a certain time of day, toggles it off at another and uses the ChronoDot to track the time.


Parts List
1 x Arduino Uno R3 (IDE 1.0.3)
1 x ChronoDot
1 x PowerSwitch Tail II Relay
6 x Jumper wires


Fritzing Diagram


Figure 1.  Grow Light Timer diagram.

Arduino Libraries
In addition to the libraries from Part I, you will need two new libraries for this sketch:  Time and TimeAlarms.  The Time library is used to set the Arduino's system time as well as to compare times during the initial setup.

TimeAlarms is used to create two alarms, one for the time each day the light is turned on, and a second alarm for the time of day the light is turned off.

Download both zip files, extract them and move a copy into your Arduino's libraries directory.


Arduino Sketch
This sketch takes two times, given as hour, minute and second and creates an alarm for each.  When you first launch the script, the start time and end time are compared to the current time.  If the current time is between the two times, the relay is toggled ON.

During each operational loop, the current time is retrieved from the ChronoDot, the system time is reset and the current time is displayed.


No comments:

Post a Comment