You are on page 1of 11

Plantiful Care

ME 507-03
Mechanical Control System Design

Josh Castle
Kylie Fernandez
1. Introduction
The goal of our Plantiful Care project is to create an automated plant care device for small indoor potted
plants. The device uses several sensors to provide information about the plant’s current environment to a
program that actuates physical changes to the given environment. Although there are a variety of
variables in a plant’s environment that can alter its health, our team decided to focus on two basic needs,
water and sunlight. As a result of these more narrowed considerations, the overall automated system can
be divided into two more basic subsystems. The first of these is the water subsystem, which reacts to the
measured soil moisture and responds according to the programmed specifications. The second of these
subsystems is the sunlight subsystem, which measures the amount of light being received by the plant and
reacts accordingly.
In order for the water subsystem to be successful, a moisture sensor is needed to signal to the system
when and how much water is needed. A water storage tank is necessary to store the water. A valve and
piping system is needed to deliver the water to the plant, and a flowmeter is needed to measure how much
water is being delivered to the plant.
For the sunlight subsystem to be successful, a light sensor is needed to measure how much sunlight is
being received by the plant. A shade is needed to block the plant from the sun with a motor to actuate the
covering and uncovering of the plant. Additionally, an encoder is necessary to provide the system with
feedback regarding the location of the shade in reference to the plant.
The ideal customers for a Plantiful Care device are people who own a small indoor plant and are looking
for a simple way to ensure that it receives the proper care. A well-rounded design considers a range of
potential customer operations, from an individual who merely wants to keep their plants alive despite
being forgetful to a more advanced case where a user wants to deliver specific amounts of water and
sunlight throughout the day and knows the proper care that will result in optimum plant growth.
Three things are needed for optimal use and are assumed present in the system:
1. The owner is able to refill the water tank at somewhat regular intervals.
2. The plant has access to a theoretically unlimited light source, whether that be sun from a nearby
window or a type of plant growth lamp.
3. The system is located near a standard power outlet.
Ultimately, the Plantiful Care automated system benefits a variety of potential users but requires some
user-provided environmental attributes to function appropriately.
2. Specifications
In order to quantify a successful design, certain target parameters are specified. These specifications, their
target values, and units where appropriate are tabulated in Table 1. Regarding the water subsystem,
specifications include the size of the water storage tank and moisture sensor style. In addition, the motor
and valve voltage, photocell sensitivity, and microcontroller features are specified.
Table 1. Project design specifications.

Specification Target

Water storage tank size At least 24 fluid ounces

Moisture sensor style Capacitive

DC motor and valve voltage Within range of each other

Photocell sensitivity 400 to 800 nm

Microcontroller features 3 inputs, 2 outputs minimum

The final design meets each of these specifications. The storage tank holds 52 ounces of water and the
moisture sensor is capacitive. The DC motor takes 6 volts and the valve can take anywhere from 6 to 12
volts. We decided to supply them both with 9 volts and saturate the motor duty cycle at 67% to avoid
overheating. The light sensor responds to light between 400 and 600 nm wavelengths. The selected
microcontroller accepts the minimum number of inputs and has the necessary PWM outputs. Further, it is
capable of controlling an extra LED for debugging.

3. Design Development
Before the selection of components, two versions of the Plantiful Care design were developed. The first is
a longer, more horizontal design with a footprint suited for a planter box. The shade structure consists of
two motors that move a shade over top of the plant while keeping the shade level. Water is stored behind
the planter box. An initial sketch of the horizontal design is shown in Figure 1.

Figure 1. Sketch of horizontal design concept.


The second design idea is a more vertical design with a square footprint that better fits a small potted
plant. This design involves a single motor that rotates the shade structure in a horizontal plane above the
plant. Water is stored in a tank on the shaft of the shade structure. A sketch of this design is shown in
Figure 2.

Figure 2. Sketch of vertical design concept.


A drawback to the long planter box design is the water being delivered to a singular location along the
length of the plant’s container. This results in a concentration of water at one particular location. With the
vertical design, there is less of a concern with saturating a particular patch of soil because the potted plant
takes up less space. Also, the ability to use multiple devices of the vertical design along the length of a
longer planter box further displays the modularity of this concept. A sketch of multiple vertical devices is
shown in Figure 3.

Figure 3. Three vertical systems operating collectively on a planter.


One limitation of the vertical design is the space needed to allow for rotation of the shade structure. The
shade structure of the horizontal design is much more compact but does require two motors to operate.
Ultimately, the functionality of the two design ideas is not significantly different. However, the vertical
design suits a wider variety of plants as water is being delivered through one pipe outlet. Ideally, the
inclusion of a telescoping pole to mount the system directly into the soil would make Plantiful Care more
able to adjust to the size of different plants.
Of the two hardware designs that were conceptualized and compared, the second, vertical design more
suited to a potted plant was determined to be superior.
3.1. Hardware Design
3.1.1. Mechanical System

Figure 4. Initial proof of concept project diagram.


Following the proof of concept diagram in Figure 4, mechanical and electrical hardware was found to
fulfill the needs of each essential component.
The system contains two actuators: a DC motor and electric solenoid valve. A 6V DC gear motor from
Amazon is used to rotate the shade over the plant and back out of the way. The motor comes with an
integrated encoder and mounting bracket. A 6 to 12V indirect operated plastic water solenoid valve from
Adafruit is selected to control the flow of water to the plant. This choice is low cost with ½-inch nominal
outlets to easily integrate with PVC piping and joints.
The first of four sensors is shown in Figure 5. A capacitive moisture sensor is chosen over resistive
options to provide greater accuracy of water content in the soil. The 3 to 5V sensor communicates over
I2C and includes a temperature sensor that can be used in future versions of this project.

Figure 5. Moisture sensor in the plant soil.


The second sensor, a basic photoresistor, is chosen for the purpose of detecting sunlight. The photocell
functions well because it is simple and works within the desired light wavelengths. The sensor provides
data that is used to track how long the plant has been in direct sunlight. However, determining the
intensity of the light requires precise calibration. For this design, the sensor is sufficient, but a more
advanced light sensor would be an improvement to future iterations of this system. A picture of the
photocell in the system is found in Figure 6.

Figure 6. Light sensor positioned above the plant.


The selected flowmeter from Adafruit is a 5 to 18V hall effect sensor connected to an internal pinwheel
that gives readings with 10% precision. This low-cost flowmeter is chosen because the outlet diameters
match those of the solenoid valve making additional adaptors unnecessary. A greater precision flow meter
would be an improvement to an updated prototype design. The black flow meter is visible in both Figures
5 and 6.
The encoder included with the DC motor is the last sensor of the project. Using the encoder, the position
of the shade can be tracked in closed loop. The AVR microcontroller selected for this system does not
have internal quadrature decoding capabilities, and therefore, the LS7366R is necessary to count encoder
ticks. The LS7366R comes with a serial interface making communication simple.

Figure 7. Dimensioned prototype drawing.


For demonstration purposes, the system is scaled to match the size of an existing plant growing from a 5.5
by 8 inch diameter pot. Using the CAD assembly shown in Figure 7, we are able to map out appropriate
sizes for the structural components of the project. These include the base, post, water tank, and shade.
This CAD drawing also allows us to determine appropriate lengths for wiring and PVC piping
connections.
It was decided to use wooden components for the base and post structures. The water tank is attached to
the post using two 2-hole straps. The water tank was chosen because it is a watertight container of ample
size with a squared shape that simplifies attachment to the square post. A hole is cut in the center of the
bottom of the container, and a threaded PVC adaptor is inserted. This is first secured with hot glue and
then later sealed with a layer of steel-reinforced epoxy. This adaptor attaches vertically to the solenoid
valve which is connected to the flow meter by a 90 degree adaptor. The flowmeter feeds water directly
into the potted plant. After water flows through the open solenoid valve from the water tank, the volume
of water being released is measured by the flowmeter.
The light sensor is mounted to the outside of the water tank in a location above the center of the pot to
provide the most accurate measurement of light being received by the plant. The motor is attached to the
top of the post using the included mounting bracket. A large rectangular piece of lightweight foam board
is mounted to the motor shaft to provide shade for the plant as determined necessary. A small plastic and
rubber wheel is fixed between the motor shaft and foam board to support the weight of the shade
structure.
3.1.2. Electrical System
Regarding the electrical design, five main ICs are used with four headers to complete the critical
connections for proper functionality of the printed circuit board. Table 2 contains the part numbers and
types of each electrical component. Additionally, a number of passive components, resistors, capacitors,
and ferrite beads, are included to finish the PCB.
Table 2. Circuit board ICs and headers.

IC Header

U1 ATmega328P Microcontroller JP1 AVR ISP Header

U2 DRV8833 Motor Driver JP2 8-Pin Sensor Header

U3 LS7366R Quadrature Decoder JP3 4-Pin Motor Header

U4 LP38691 Voltage Regulator JP4 4-Pin Encoder Header

U5 FT232R UART Bridge

Electrical connections between the sensors, actuators, and PCB are all made through header pins and
wires. The board is powered by a 9V DC barrel jack that is connected to a wall power supply. The 9V
power is needed to supply the motor driver IC, and a linear regulator is used to reduce the voltage to 5V,
the microcontroller logic level. Programming the microcontroller flash memory is done by connecting the
AVR pocket programmer to the 6-pin male AVR ISP header on the board. Serial communication with a
computer terminal is accomplished with a USB to UART interface chip. The fully connected and
mounted PCB is shown in Figure 8.

Figure 8. Mounted PCB and DC motor.


The PCB components are arranged to promote organization, symmetry, and minimized traces. There are
two crystal oscillators providing clocks for the microcontroller and quadrature counter. A reset switch is
present to send reset signals to the microcontroller. Board trace width is not less than 16 mil with larger
traces for logic level connections. The 9V power supply traces are supplemented with polygons to
improve current flow and heat transfer. The motor pin traces are supplemented in the same way. Ground
planes are present on both the top and bottom layer of the PCB with vias distributed throughout to
increase conduction.
A stainless steel stencil was ordered with the board to streamline the soldering process. By applying
solder paste using the stencil and placing components all at once, the PCB is completed in a fraction of
the time.

3.2. Software Design


The software designed for the project began with finding drivers for the multiple sensors. Adafruit
Arduino code is used to control the moisture sensor and flow meter. A C++ driver for the LS7366R
quadrature counter from Github is used to interface with the encoder.
The actuators are controlled more simply with standard Arduino PWM commands. These are sent to the
DRV8833 motor driver to manage the speed of the DC motor and open and close the solenoid valve.
Each subsystem of the project is given a task to handle its functions. FreeRTOS is used to run these two
tasks “simultaneously” using their priorities and delays. A diagram containing parameters for each task is
shown in Figure 9. The water task is given a higher priority due to the need to count pulses coming from
the flow meter more quickly. It also has a lower timing for this reason. The light task is concerned with
measuring sunlight on the plant over time and therefore does not need to run as frequently. In addition,
the quadrature counter keeps track of encoder ticks external to the program running on the
microcontroller.

Figure 9. Task diagram.


The states of the water task are simple. In State 0, the device repeatedly checks the moisture level of the
soil by reading the soil moisture sensor. If the soil moisture drops below 250, the task moves into State 1.
In this state, the solenoid valve is opened and the flow meter begins measuring the amount of water
distributed to the plant. The pulses of the flow meter are checked in each pass through the task and
converted to liters using a calibration provided by Adafruit. Initially, the flow meter pulses were checked
using an interrupt, however, using this interrupt in conjunction with the RTOS created a problem. The
RTOS and interrupt use the same microcontroller timer. This is solved by moving the flow meter function
into State 1 of the water task. Figure 10 contains the state machine diagram of the water task.
There is a timeout programmed into State 1 that triggers a red LED on the PCB. If the flowmeter does not
measure the specified amount of water in a reasonable amount of time, the tank is assumed empty. The
red LED is used to alert the user and remind them to refill the water.

Figure 10. Water task state machine.


The light task states followed a thought process similar to the water task. In State 0, the photoresistive
light sensor is polled to measure the amount of light being distributed to the plant. If the sensor reading is
greater than 400, a counter is incremented to keep track of the amount of time direct sunlight is hitting the
plant. If the amount of light on the plant goes below this limit, the counter is reset. After approximately
two hours of direct light, the task moves into State 1. State 1 begins actuating the DC motor to move the
shade over the plant blocking light. This is accomplished using a control loop that tracks shade movement
with encoder feedback. A proportional duty cycle is calculated for the motor using the difference in
location between the current shade location and target location. After approximately one hour with the
light blocked, the shade will return to its original position. These one and two hour time periods are
estimated by counting the number of FreeRTOS task delays. This gives a minimum estimate of the time.
A state machine for the light task is found in Figure 11.

Figure 11. Light task state machine.


Doxygen generated documentation is located in Appendix C. The entirety of the main program source
code is available online at the following link: ​https://github.com/kyliefern/me507-plantcare

4. Results
After testing the sensors and actuators, constructing the physical system, and assembling the printed
circuit board, we attempt to download and run our main program. This is with the intention of debugging
and optimizing the device through physical testing. We are confident about how to operate the sensors
and actuators due to preliminary testing with an Arduino Uno and sensor breakout boards. However, the
main program assesses how well the components work together. Unfortunately, there are functional issues
with actuation of the physical system.
Troubleshooting the DC motor and valve operation led to discovering that the motor driver is not
outputting signal. We began testing each of the motor driver connections. The input pins receiving PWM
from the microcontroller are checked with an oscilloscope and found to have the appropriate square wave
signal. Power input to the motor driver is measured at the appropriate 9 volts, and the enable pin is
correctly pulled high. The problem is assumed to be one of two things: a faulty chip or faulty board traces.
After visual inspection of the PCB, we first attempt to add solder to the power input pin and create a more
desirable connection. This does not solve the issue. Next, we remove the motor driver entirely and replace
it with an extra DRV8833 chip. The replacement chip does not output signal to the actuators either,
leading us to believe that the board traces are the culprit.
In order to demonstrate sensor functionality without use of the motor and valve, a short program is written
that prints light and moisture readings. Also, when the moisture sensor detects a measurement greater than
900, represented by touching the sensor with fingers, the system responds by turning on an LED. It is
unfortunate that this is the best Plantiful Care could perform during the project demos, but there was not
enough time to use the motor driver breakout board as demonstration due to the PWM pins not having
headers.
The aspects of the project that made it successful are the microcontroller selection and PCB stencil. By
using the microcontroller present on an Arduino Uno board, we are able to write and use code that
includes the Arduino library. This greatly simplifies the process of creating software. It is also easier to
get FreeRTOS working because we can use the Arduino version. The printed circuit board itself is quick
to assemble thanks to applying solder paste over a stencil. We highly recommend ordering from JLCPCB
for affordability and timeliness.
If we were to make improvements for future iterations of Plantiful Care, more accurate sensors would be
an upgrade. Using a folding hand fan style shade to make the structure more compact could increase
modularity. Lastly, the PCB should have been designed with more headers to make debugging and
troubleshooting a lot quicker and easier. Overall, the project was fun and creative. We learned how to use
Eagle, Eclipse, and C++ to operate a variety of sensors and actuators in a short amount of time.

Appendices
Appendix A - Eagle PCB Schematics
Appendix B - Eagle PCB Layout
Appendix C - Doxygen Documentation

You might also like