Garden Monitor V1
My fiancé loves plants, but maintenance can be overwhelming. To combat this, I wanted to design a scalable system that could provide water and light in controlled amounts with an intuitive user interface. At the time I was learning how to create PCBs with KiCAD on the Mars rover design team and I was studying the ATmega microcontroller platform in my classes. Using the combination of these skills the first version of the garden monitor began.
Planning.
To help eliminate ideas and refine the user interface the project required planning:
The controller was designed to attach to the side of a 10-gallon tank and needed to be sized appropriately.
A 16x2 LCD was the primary display, this worked well with a text scroll menu system.
The RTC with a dedicated backup battery helped trigger program flow events such as watering and lighting.
Capacitive soil sensors were used to set thresholds for event flags while the temperature sensor was used to alert the user of unfavorable conditions for the plants.
A rotary encoder was used for selections and page navigation.
Before I began the firmware to run the system, I designed a method of flag-based event handling.
System Flags ensured less memory usage while keeping the control functions non-blocking in the main execution loop.
The icons and menus were created to be dynamically used for each page by reusing assets from memory.
Program flow was worked out with pseudo code that related all embedded components together.
PCB Design.
The next part of the project was component selection and PCB layout:
Power came from a prepackaged buck converter that knocked 12V down to 5V to create the main VCC net.
The MCU is an ATmega328P with a rich set of peripherals available to interface with the temperature sensor, soil sensors, and RTC.
A common BJT was used to amplify interface sounds through a small speaker and a pair of irfz44n MOSFETs were used to control the LED light strip and the pump.
The rotary encoder used serval digital inputs to measure the change between waveforms. This waveform difference defined user input direction.
The 16x2 LCD utilized I2C to draw custom characters and text on screen.
The idea for the layout was to create sections of the PCB that served one purpose and arrange each module around the MCU.
Firmware.
To tie this all together custom firmware was needed to control the embedded devices:
Using the Arduino IDE each subsystem was broken down into an appropriate .C and .H file to provide a layer of abstraction to the main functions.
The menu functions utilized flags to display pre-programmed menus while keeping track of submenus through an additional local flag.
A watchdog timer was used to poll the sensors and compare the data to user defined values. If a sensor becomes unresponsive or the data is invalid the system halts to prevent accidental watering.
3D Printing.
To support all the electrical components an enclosure needed to be designed:
Using Fusion 360 I designed an enclosure that contained all electrical parts while keeping an organized front fascia.
A removable plug was created to seal the top of the enclosure once the supporting wires were installed.
The models were sliced using Cura and printed on my custom ender 3 pro.
The result is a small footprint package that can automatically control watering and lighting using user set variables to simplify plant care.