Timing is Everything: Controlling Lights based on time

>

I have had this thing for a long time and I have been sitting on the idea ’cause this project is in the testing phase. The problem to which this solution come to is as follows. Every evening, my mom would repeatedly ask me to turn the porch lights on and almost every other day, the lights would still be on because no one switched them off. Well I thought it was an incredible waste of energy(and my time) to manually control the lights. So I decided to put a little microcontroller in-charge of it.
I have been really busy in the office for the last year and when I came back home last winter, I found a box full of microcontrollers and other stuff lying around. About an hour spent on paper, I was happily coding away with my laptop as I tested out my routines for the RS232 UI and I2C Bus.
For this project I used
  1. An AT89C4051 -20 Pin uC(8051 Core) with 11.0592 Mhz Crystal,
  2. DS1307 RTC and
  3. A relay with the driver TIP122

The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I²C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator. The DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply. Timekeeping operation continues while the part operates from the backup supply.


A Tutorial is given at http://www.sixca.com/micro/mcs51/rtc_51/ and a link to the keil sample code for the I2C bus is also given, I used a slightly modified code which I will put up on code.google.com once I get everything together. For now it’s on my CVS server at my home office where I working from.

I made the prototype by hand soldering the PTH components on a general purpose PCB and the housing is… well … less than conventional.

I wanted to get a working prototype ASAP and put it to testing(and see if it blows up). Well its been up there for a while and its doing ok for now. I did not want to spend on LCD and keyboards etc, so I wrote a text based UI to read inputs from the user. char to int etc were done on the fly and no programmers were hurt in the process 🙂
The MAX232Lvl converter and USB to serial converter are separate and were provided courtesy of some very generous people at Moxa. http://www.moxa.com

I will put up the block diagram, routines etc in a later entry. Cheers for now.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s