Description | Introduction | Electronics | User Interface | Software | Acknowledgements | Download | My Homepage

EE281 Embedded System Design Project

Worry-Free Automatic Timed Plant Feeder

Gang Xie

Department of Electrical Engineering
Stanford University

December 8, 2002


Do you often forget to irrigate your plants? Do you have to ask your neighbors to take care of them when your whole families are out for a vacation? Donít worry any more! Here is a solution. This embedded system, worry-free automatic timed plant feeder, can do all the services for you. It can: You can set your desired feed pattern, and change all options at any time. It is easy, low-cost, and safe. It makes your worry free while you still enjoy your plants.


The following diagram shows the system schematic.

It contains the several major blocks: Some key blocks will be explained in detail later on.


The AVR processor used in this project is an ATmega323. It has two 8-bit Timer/Counters and one 16-bit Timer/Counter. Meanwhile, it supports the real-time counter. These features satisfy the system's demands. More detailed information can be founded in data sheets at Atmel. The following picture shows the pin configurations of the ATmega323.

The programming control circuit is shown in AVR basic system schematic. With this circuit, the code can be easily read and written by software PonyProg.

The regulator circuit uses an LM7805. A heat sink helps it cool down. This block of circuits is also shown in AVR basic system schematic.

The system has lots of functions heavily depending on a real-time clock. Thus, a 32768 Hz crystal works here. With a prescale of 128 and Timer2's overflow interrupt service, the crystal finally offers a 32768/128/(2^8) = 1 Hz frequency. Circuits for both the RTC crystal and the 8MHz crystal are shown in AVR basic system schematic.

A 2*24 HD44780 LCD is used as a display.

A 0.2W speaker makes sound.

The following diagram shows how push buttons work. When the button is pressed, the output signal is connected to GND. When it is released, the output is connected to VCC. Thus, it simulates push buttons in AVR STK500 kit. Push buttons are nominally open.

A R40-11D2-5 relay plays an important role in this project, since it is the relay that changes a control signal from the AVR into turning on or off the water pump. Its contact arrangement is shown as following.

In the system schematic as shown previously, there is an additional circuit for the relay to protect the AVRís pins from being damaged. As we know, U=LdI/dt. There could be as large as 100 volts introduced from coils in the relay when the current flow in the coils are suddenly stopped or allowed. This high voltage can easily break through the AVR ports. In order to protect the AVR, the following circuit is used to limit the voltage applied on the AVR pins.

With this circuit, about 5 volts will be applied if the input control signal at B is high, which is large enough to trigger the relay.

The water pump (CAL P60) is in serial with a fuse for safety.

The speak makes sound of a certain tone when it is fed with a rectangular wave of a certain frequency in the project.

User Interface

The system provides a variety of UI functions. It has a pump, a LCD, a speaker and five push buttons.

The pump irrigates plants, which is our goal. Constrained by the water pump, the system uses a semi-volume control method by pumping for a specified amount of time. Water flow can be manually off-line adjusted by rotating a plastic valve in the pump. So please do some check and make sure that the pump supplies a desired amount of water in the specified time duration, before you leave the system to work.

The speaker will make sound when alarming or pumping. It actually gives a segment of music at the following frequencies in circular order:
f [Hz] Note
880 A5
987 B5
1046 C6
1174 D6
1318 E6
1397 F6
1568 G6
1760 A6
Timer1 compare interrupt is used to generate these frequencies.

The LCD tells us the system status. It implements features such as displaying normal characters, blinking the cursor, shifting strings, and displaying a progress bar. A total of 6 pages can be shown in the LCD.
  1. First page is the one shown in normal mode. It shows the real-time date and time information in the first line. Different strings are shown in sequence in the second line.
  2. Second page is to show whether the clock alarm is set off or on at your specified time.
  3. Third page is to show whether the pump system is active or not, and whether sound is on or off during pumping.
  4. Page 4 shows the pumping duration, i.e., how many minutes and seconds of water will be pumped. Its range is from 1 second up to nearly 100 minutes.
  5. Page 5 shows the pumping frequency, i.e., how often you want to pump. Its range is from 1 second (not recommended) up to nearly 100 days.
  6. Page 6 shows the next pumping time.
Page 4, 5, and 6 together specify the pattern of pumping water.

A user can click five push buttons to communicate with the system. Timer0 is used to filter out electrical and mechanical noises. One of five buttons is used to reset the system. The other four, from left to right, are:
  1. Button Next: turn to next page if in non-editing mode, or swithches the blinking cursor the next changeable field if in editing mode.
  2. Button Edit: switches between non-editing and editing modes.
  3. Button +: increases the value of the current blinking field when in the editing mode.
  4. Button -: decrease the value of the current blinking field when in the editing mode.
Because of safety, conventions, and other issues, the system will stop alarming and/or stop pumping when any one of the buttons is clicked.


The project is written in C, and compiled by AVRGCC. Meanwhile, it is heavily based on AVRlib function libraries, courtesy of the instructor Prof. Pascal Stang. About 45 percent of code deals with real-time clock and time-related stuffs. It considers practical issues, such as 29 days, instead of 28 days, in February every four years. It need calculate and update the next pump time when necessary, since the next pump time is always larger than the current RTC time. About another 45 percent of code deals with the LCD.

Please click the following files to view the source code:


The water pump was on-line purchased from Pump World. Most of other electric components were bought from HSC. The project has been hard-wired on a PC board from Jameco, and fits nicely in a plastic box from TAP Plastics. The whole system has been fully tested and works successfully. Here is how the system looks like:

Atmelís shipping me two free AVR samples is appreciated.

Thank David Black-Schaffer, the TA of this course, for his continued help throughout the whole autumn quarter.

The author especially appreciates Pascal Stang, the instructor of this course, for his patient support and valuable directions. This great project could not have been finished in three weeks without his insightful ideas.

Finally, the author would like to thank all wonderful people who helped to finish this piece of art.

Thanks, microcontroller!