Difference between revisions of "S14: Smart Planter"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Acknowledgement)
(Acknowledgement)
Line 247: Line 247:
 
== References ==
 
== References ==
 
=== Acknowledgement ===
 
=== Acknowledgement ===
Carlos Fernandez-Martinez for providing parts and advice
+
Thank you to Carlos Fernandez-Martinez for providing parts and advice,
Professor Ozemek for changing our lifestyles
+
Professor Ozemek for changing our lifestyles, and to
Preet for providing a solid background in FreeRTOS and drivers so we could complete everything
+
Preet for providing a solid background in FreeRTOS and drivers so we could complete everything!
  
 
=== References Used ===
 
=== References Used ===

Revision as of 05:31, 22 May 2014

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Project Title

Smart Planter

File:Plantproject.jpeg
Smart Planter Set-Up

Abstract

Most people just don’t have the time in the day to remember to water a garden and when they do they over-water, wasting resources and hurting the plant. The solution is a system that takes in data on the moisture of the soil, the temperature, and the humidity of the environment and pumps the necessary water accordingly.

Objectives & Introduction

This system will be achieved using two different types of sensors: the first will be soil hygrometer inserted into the bottom of the planter to detect the amount of water the plant currently possesses in its soil. This will be the highest priority in determining whether the plant needs additional water. The second sensor is a combination humidity and temperature sensor attached to a peg (for security and to keep the wires safe) that will relay the data back to the SJSUONE board. In order to conserve energy, the system will collect data twice a day (8 am and 3:30 pm) and determine how much water needs to be added. A real-time clock along with an Alarm timer will be used to determine when to trigger the sensors and collect data. In addition, a push-button was implemented as a alternate way to activate the sensors to check if the plant needs to be watered. It will only water the plant if the algorithm determines that the plant needs to be watered to prevent drowning the plant. A drip system was chosen because this method has shown it is the most effective in not wasting water as opposed to a spray sprinkler system that loses more water to evaporation. Finally, information including the last time checked, whether the plant was watered at this time, and the temperature at this time will be displayed on an LCD screen for the user to view. The LCD displays the last time watered, the temperature of the air, the soil moisture level, and the current time, each on their own line.

Team Members & Responsibilities

  • Carissa Labriola
    • Driver Development for sensors, Peripheral Device Hardware Integration, Software Layout
  • Sovist Thou
    • LCD Driver Display, DC Motor Control, Physical Layout, Circuit Board Design
  • Leeladithya Avala
    • FreeRTOS Software Design, Physical Layout, Circuit Board Design

Schedule

Week# Date Task Description
1 3/23 Research and order parts A total of 6 hours were spent just researching which parts would fit into the project such as the right DC motor, a dependable hygrometer (many corrode too quickly), an accurate temperature sensor, an LCD screen that isn't too big and doesn't need more than 12V, etc.
2 3/30 Write drivers for peripherals and environment Initial FreeRTOS environment complete, peripherals started
3 4/6 Finish hardware set up, continue peripherals Hardware set-up for individual modules, LCD screen progress,
4 4/13 Finish drivers and FreeRTOS environment LCD screen, DHT22 drivers complete
5 4/20 Test and Edit environment DHT22 still experiencing issues, hygrometer complete, Motor module complete, adding modules to FreeRTOS
6 5/3 Continue Testing DHT22 still experiencing issues, assembly of protoboard begins
7 5/10 Final Testing Moving to on-board temperature sensor, compiling individual modules into main environment, implemented push button logic
8 5/17 Final testing and set up All modules added to environment and protoboard, last fine tuning of software and hardware
9 5/21 Demo Complete

Parts List & Cost

Item Description Qty Unit Cost Total Cost Source
1 Hygrometer 1 $6.00 $6.00 http://www.amazon.com/gp/product/B00CKWMLC6/
2 7mm Silicon Tubing 1 $8.00 $8.00 http://www.amazon.com/gp/product/B0094FZCIW/
3 Submersible Water Pump 1 $15.00 $15.00 http://www.amazon.com/gp/product/B007XHZ25G/
4 LCD Screen 1 $25.00 $25.00 New Heaven
5 Plant Pot 1 $2.00 $2.00 Orchard Supple Hardware
6 Water Basin 1 $4.00 $4.00 Target
7 Plant 1 $3.00 $3.00 Trader Joe's
8 Temperature And Humidity Measurement Sensor 1 $7.00 $7.00 http://amzn.com/B00CDHH3WQ
Total $79.00

//ADIYTHA, ADD THE PARTS

Design & Implementation

Hardware Design

The hardware for the project is broken down by the needs of the different sensors. To have the design function as expected, the team required circuitry to provide the appropriate power to each peripheral as well as the CPU. The Basic System Design, shown in the Figure below, shows how each component will be laid out onto the base board. The LCD, SJSUONE board and prototype board will be set inside a clear box to protect the circuitry from any water spills as well as allow for the user to view the embedded design. The prototype board was used to build the circuitry, including the power unit for the system so that there could be a 12V and 5V power line supplied by a 12 DCV wall supply, a ground line, and a 3.3V line supplied by the SJSUONE's Vout pin. The water supply includes of a submersible DC water pump that will be sitting at the bottom of the bucket since it is not self-priming and needs to be completely submerged. The silicon tubing will be coming out of the bucket and will be fed to the plant' s soil as a drip system. A single push button was also added to allow the user to check the parameters at any given time in the day while not allowing them to over-water the plant.

File:DIAGRAM.jpg
Basic System Design


The Figure below shows the circuit design for our system. As mentioned above, majority of this of will be enclosed inside the box, to keep it away from water.

File:System Block Diagram.png
Circuit System Design

//SOVIST, PLEASE UPDATE CIRCUIT

Hardware Interface

Each of the peripherals utilized a different type of BUS communication. The soil hygrometer works by sending voltage through the pegs, measures the resistance between them, a value dependent on the moisture level, and translates this information into an analog output. Therefore, the pin is attached to one of the analog to digital pins on the board in order to translate the signal into a number that will determine the appropriate level. While the original intent for the project was to use the DHT22 temperature/humidity sensor, the protocol was more complicated than initially anticipated so the sensor was exchanged for the on-board I2C sensor. Since significant strides were made in the development of the DHT driver, its description has been included. The DHT22 utilizes a custom single-line open collector communication BUS connected to +5v and ground and a 10kohm resister connected from voltage to the communication pin to pull it high. The sensor waits for the microcontroller to pull the line low for 1-20ms, the pull the line actively high for 20-40us. The microcontroller then needs to switch to an input to receive the acknowledge signal followed by 40 bits. The bits are determined 0 or 1 by the length of how long that segment of data is high or low. The sensor needs to wait 2s in between reads and critical read times need to be protected from being interrupted in order to be successful.

File:SensorWaveform.jpg
DHT22 Sensor Waveform for acknowledge

The on-board temperature sensor utilizes a I2C communication which has two data lines: SDA for the address, acknowledge, and data and SCL for the clock to time the information. The read temperature class has the microcontroller acting as the master and reading from the slave device, the temperature sensor. The clock is provided by the master device to the slave so that the communication can be in sync. The connections for this device are internal and can be seen below:

File:Temperature sensor.JPG
I2C Temperature Sensor Set Up, Credit to SJSUONE_V2 Schematics

The DC motor is a food-safe motor that takes 10-12DCV and has two inputs: the voltage and a signal that needs to be ~3-5V to activate. This system was set up by attaching an output GPIO pin on the board that when the motor needs to be activated is driven high, passed through SN1708 AND gate with a high on the other input so that the output is high enough to activate the motor. The AND gate logic was added when the pin was not providing enough voltage to activate the motor and the AND outputs a higher output signal.

//SOVIST, PLEASE ADD INFO ON THE LCD SCREEN The LCD screen utilizes SPI communications...

Software Design

The software for the planter used FreeRTOS as a base with two main tasks for the scheduler: a standby task that passed the information to the LCD to be printed on the board and a check reading task. The standby task was not passed a semaphore but since the check reading task was only activated if either alarm semaphore handler or the button press handler was taken, the standby was run automatically. The standby task reads as follows: while (1)

get current time
send the last time plant was watered to first line of LCD
send the last temperature read to the second line of the LCD
send the last soil moisture read to the third line of the LCD
send the current time to the fourth line of the LCD
delay loop for 50ms

The check reading task, when activated, updates the temperature and soil moisture and fetches the current time. If the moisture level, which ranges from ~14-50 is below 20 or the temperature is above 90*F, then the motor is activated for three seconds and the time last watered is updated. The motor is activated for two seconds is the temperature is between 80*F and 90*F or is the moisture level is less than 30. The motor is activated for one second if the temperature is between 70*F and 80*F or the moisture is below 40. If it does not fit into these parameters, than the plant is deemed to not need water and the power is not powered nor is the time watered updated.


//SOVIST, PLEASE DESCRIBE HIGH LEVEL FOR THE LCD SCREEN

Implementation

//This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation. //

Temperature/Humidity Sensor: The temperature/humidity sensor (officially named the AM2302) utilizes the tri-state properties of the ...

Hygrometer:

DC Motor: The DC motor is a submersible food-grade water pump that is placed at the bottom of the water basin instead of needed to be primed. The output is attached to a silicon tube that then transports the water to the plant. The inputs for the motor are ground and power, which have been placed through a mosfet in order for the microcontroller to be able to control the power through an output GPIO pin. ...

LCD Screen:

Testing & Technical Challenges

For testing this project, each of the sub-modules was completed individually and then compiled together to work in unison. The temperature/humidity sensor required the majority of the debugging time since it utilizes microsecond-precision in transferring the data. Across the board, the team found that when testing that making a separate project folder just for testing sub-modules made the debugging process more efficient. The team's procedure was to write the drivers for each of the devices with their own test code then one by one start to integrate each one into a main test program. Starting with the hygrometer being placed into the FreeRTOS frame, a button interrupt was integrated. Once this procedure was successful, the temperature sensor's input was added in. This was followed by the integration of the motor pump and lastly the LCD screen. The issues that were encountered along the testing procedure can be seen below:

Temperature Sensor Issues #1

The first issue encountered was in writing the driver for the temperature and humidity sensor. The DHT22 works off of a single line for data transfer using the tri-state of an open collector to send start and acknowledge signals back and forth between the microcontroller and the device. The timing for sending the data is down to the microseconds so the driver timing has to be very precise or data would be missed. Hours were spent debugging a delay-based version that would hang while waiting for the end of the acknowledge from the

Temperature Sensor Issues #2

While the documentation for the DHT22 temperature sensor says that the minimum voltage level is 3.3V and the board is supposed to output 3.3V, in reality this does not work. This was found to be a combination of the sensor really needing +5V to work properly and the board was found to only output 3.2V (tested using a multimeter). The fix for the issue was to alter the power line portion of the circuitry such that we now have the initial +12V set up to drive the DC motor then a +5V line for the microcontroller and the temperature/humidity sensor to connect to for power.

Hygrometer Issue #1

Programming the analog signal from the hygrometer sensor required a little research and debugging. Since this type of communication had not been experimented with before, it took a few hours completely of research to make sure that all of the correct bits were being set but ultimately this extra time spent double checking all of the inputs meant only a few trials on the board before it worked successfully.

LCD Issue #1

//Sovist Input//

DC Motor Issue #1

//Sovist Input//

Protoboard Issue #1

//Adithya Input//

Water container #1

The plastic water container for the project needed to have two holes drilled in for the silicon tubing and the wires for the DC motor. While the sealing for the silicon tubing held up, the wires produced a small leak, which became a hazard around all of the electronics. The solution for this issue was to add more hot glue whenever a drip was noticed and to seal both sides of the hole for extra support. As a result the container is now successfully sealed.

Conclusion

The Smart Planter utilized a breadth of knowledge acquired in the embedded systems course to become successful. This included implementing I2C, SPI, GPIO, FreeRTOS, interrupts, Real-Time Clock alarms, analog-to-digital conversions, single line communications, and DC motors. Clean hardware implementation was reinforced as well as proper use of voltage regulators, MOSFETs, and setting up power lines. In the software portion of the project an understanding of interacting tasks and being conscious of the real-time operation was invaluable to the success of the project. How to troubleshoot problems across software and hardware modules was also in important learning lesson in this project. Being able to identify a problem, such as why the time function isn't updating on the LCD screen, and follow the logic of the code to discover the RTC gettime function was not properly implemented is an important skill to cultivate in engineering since the ones encountered in this project are minor compared to industry issues. All of this technical experience was combined with the soft skills of division of labor, communication across a team, time management with other on-going projects, and verbal and written explanation of technical concepts. A few improvements could have been made: for example, a water level sensor could have been added to the water tank so that if the water level got too low then the user could be warned, especially since the motor is damaged if it tries to run without water. A battery for the RTC would also be nice since currently it is reset to a specified time and date every time it loses power. Had there been more time, a wireless connection to receive weather predictions from weather.com would have been a nice addition for the plant that the tea did not have time to implement as an extra. Overall, this project was abundant in learning opportunities for the entire team so while the concept of the project was simple there was still plenty of valuable knowledge to gathered and problem solving to be had.

Project Video

Upload a video of your project and post the link here.

Project Source Code

Send me your zipped source code and I will upload this to SourceForge and link it for you.

References

Acknowledgement

Thank you to Carlos Fernandez-Martinez for providing parts and advice, Professor Ozemek for changing our lifestyles, and to Preet for providing a solid background in FreeRTOS and drivers so we could complete everything!

References Used

List any references used in project. http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf

http://blog.ringerc.id.au/2012/01/using-rht03-aliases-rht-22.html

Appendix

You can list the references you used.