Raspberry Pi Powered IOT Garden

by Technovation in Circuits > Raspberry Pi

138652 Views, 605 Favorites, 0 Comments

Raspberry Pi Powered IOT Garden

cover attempt 6.jpg
IMG_8893.JPG
IMG_8951.JPG
IMG_8892.JPG
IMG_8895.JPG
IMG_8907.JPG
IMG_8916.JPG

One of the primary objectives of this project was to be able to maintain the well-being of a garden using the power of the Internet of Things (IoT). With the versatility of the present tools and software, our planter is integrated with sensors that monitor the real-time status of the plants. We built a smartphone app that let's one access the data and take needed actions if necessary.

The design of our planter is scalable, low-cost and easy to build, making it the perfect option to add greenery to one's terrace or backyard. The smart garden has proven to be more efficient in water consumption and facilitates maintenance and monitoring.

Follow on to learn how to make your very own database and app, by creating a garden that can be monitored by a click of a button!

Overview of the IOT System

iot explanation 2.png
Screenshot_2019-05-31-09-03-51-516_appinventor.ai_kousheekc.IOT_garden_monitoring_system.png

The Iot system functions through the following processes. A Raspberry Pi is used to relay useful information of the garden, such as luminosity, humidity and the moisture content in the soil from various sensors into a cloud database. Once the information is in the cloud, it can be accessed from anywhere using a smartphone app that we built. This process is reversible too, the user can send instructions, such as the state of the water pump, back to the garden which will execute the required commands.

The following are some of the key features of our garden :

  • Real-time feedback of the garden's various sensors
  • Database of the garden's health status
  • Global monitoring and operating capacities
  • Drip irrigation system
  • App controlled water system
  • Automatic watering schedules

We decided to use Google's Firebase as the intermediary of our IOT system, to create our own free cloud database. We then used MIT's App Inventor to create a smartphone application which is compatible with the Firebase database and the Raspberry Pi. It can also communicate with the database with the help of a free Python library.

Materials Needed:

IMG_8926.JPG
IMG_8765.JPG

The materials needed to make the iot planter can be easily found in local or online shops. The following list is a description of all the parts needed.

HARDWARE :

  • 1" Pine Wood Plank - dimensions; 300cm x 10cm (as the wood will be outdoor, we would recommend treated wood)
  • 1/4" Plywood - dimensions; 120cm by 80cm
  • Tarpaulin Sheet - dimensions; 180cm x 275cm
  • PVC Pipe - dimensions; length 30cm, Dia 2cm
  • Surgical Tube - dimensions; 250cm

  • Elbow Joint x 2
  • Wood Screw x 30

ELECTRONICS :

  • Rasberry Pi 3 Model B
  • Grove Pi + Sensor Shield
  • 12V Solenoid Valve
  • Humidity and Temperature Sensor (dht11)
  • Moisture Sensor
  • Luminosity Sensor
  • Relay Module
  • 12V Power Supply

The total cost of this project is roughly 50 USD

3d Printed Parts

IMG_8779.JPG
IMG_8827.JPG

Various components that needed to be customised for this project were made with the help of 3d printing. The following list contains the complete list of parts and their printing specifications. All the STL files are provided in a folder attached above, allowing one to make their needed modifications if necessary.

  • Pipe Joint x 1, 30% infill
  • Nozzle Adaptor x 3, 30% infill
  • Tube Plug x 3, 10% infill
  • Hook x 2, 30% infill
  • Sensor Mount x 1, 20% infill
  • Valve Adaptor x 1, 20% infill
  • Wiring Cover x 1, 20% infill

We used our Creality Ender 3 to print the parts, which took around 8 hours for the 12 parts.

Downloads

The Plans

iot_garden_monitoring_system_2019-May-29_04-27-30PM-000_CustomizedView30938047944.png
iot_garden_monitoring_system_2019-May-29_04-32-05PM-000_CustomizedView909737120.png

One is not restricted to the dimensions that we chose to make our planter, but attached above are all the details required to make the project. In the following steps one can refer do these images to cut the wood.

Building the Sides

IMG_8764.JPG
IMG_8731.JPG
IMG_8732.JPG
IMG_8735.JPG
IMG_8750.JPG
IMG_8757.JPG
IMG_8752.JPG
IMG_8762.JPG
IMG_8767.JPG

To hold the plants we decided to make a planter structure out of wood. The inner dimensions of our box is 70cm by 50cm with a height of 10cm. We used pine wood planks to build the sides.

Using a circular saw we cut the four pieces to length (dimensions attached above). We drilled pilot holes at the marked spots and countersunk the holes so that the screw heads sat flush. Once done, we drove in 8 wood screws while making sure the sides were square which secured the frame.

Fitting the Bottom Panel

IMG_8772.JPG
IMG_8770.JPG
IMG_8768.JPG

To make the bottom panel we cut a rectangular piece of 5mm plywood, which we then screwed in place to the side frame. Make sure the holes are countersunk so that the screws are flush with the base. The needed dimensions can be found attached above.

Holes for the Pipe

IMG_8778.JPG
IMG_8785.JPG
IMG_8790.JPG
IMG_8789.JPG
IMG_8796.JPG

Our planter is made to accommodate three rows of plants. Therefore for the drip irrigation system one side needs to hold the pipes for the water input.

Start by measuring the diameters of the connectors and draw them out equidistantly on the shorter side of the frame. As we didn't have a forstner bit, we drilled a 10mm hole and then widened it with a jigsaw. To smooth out the rough edges one can use a Dremel till the connectors fit.

Connecting the Water Pipes

IMG_8808.JPG
IMG_8800.JPG
IMG_8799.JPG
IMG_8806.JPG
IMG_8810.JPG
IMG_8813.JPG
IMG_8814.JPG

To connect the joints simply cut two pieces of PVC pipe 12 cm long. Dry fit the set up to check if everything fits snuggly.

Then push in the 3d printed joint in the central hole and the two PVC elbow connectors on the opposing ends till they are flush. Attach the panel back to the frame and cap the connectors from the inside with the 3d printed adaptors. All connections are friction fit and should be watertight, if not, one could seal the joints with hot glue or Teflon tape

Solenoid Valve

IMG_8879.JPG
IMG_8855.JPG

To control the flow of water into the drip irrigation system we used a solenoid valve. The valve acts as a gate that opens when an electrical signal is sent making it controllable automatically. To incorporate it, we attached one end to the water source and the other to the planter's water input pipe using an intermediary adaptor. It is important to connect the valve in the right orientation generally tagged as "IN" for the water input (a tap) and "OUT" for the water output (the planter).

Wiring the Electronics

Untitled-1.png
IMG_8930.JPG

Below is a table with the various modules and sensors with their respective ports on the grovepi+ shield.

  • Temperature and Humidity Sensor ==> port D4
  • Relay Module ==> port D3
  • Moisture Sensor ==> port A1
  • Light Sensor ==> port A0

Use the wiring diagram attached above as a reference.

Sensor Compartment

IMG_8860.JPG
b6862850-edf9-45bd-ad57-c4f09c663eef.png
IMG_8828.JPG
IMG_8824.JPG
IMG_8825.JPG
IMG_8832.JPG
IMG_8858.JPG
IMG_8862.JPG

We built a compartment box that held all the electronics with the leftover plywood. We cut the wood according to the layout of the electronics and glued the pieces together. Once the glue had dried we mounted the power supply and Raspberry Pi into the compartment box, feeding the wires of the sensors through a slot. To cover the slots we pushed in printed covers to seal any gaps.

The Sensor Mount has holes to attach pegs on which you can mount the sensors. Attach the luminosity and humidity sensor on the top and the moisture sensor on the adjustable slot. To make the compartment box easily removable we screwed 3D printed hooks and the sensor mount which allowed the box to clip onto the main structure. This way, the electronic and iot system unit can be easily integrated to any planter.

Creating the Database

IOT Smart Garden – Overview – Firebase console - Google Chrome 5_25_2019 5_18_22 PM.png
IOT Smart Garden – Overview – Firebase console - Google Chrome 5_25_2019 5_19_02 PM.jpg
IOT Smart Garden – Overview – Firebase console - Google Chrome 5_25_2019 5_19_11 PM.jpg
IOT Smart Garden – Overview – Firebase console - Google Chrome 5_25_2019 5_19_19 PM.jpg
IOT Smart Garden – Overview – Firebase console - Google Chrome 5_25_2019 5_20_02 PM.jpg
IOT Smart Garden – Overview – Firebase console - Google Chrome 5_25_2019 5_20_15 PM.jpg
IOT Garden – Database – Firebase console - Google Chrome 5_25_2019 5_35_38 PM.jpg
IOT Garden – Settings – Firebase console - Google Chrome 5_25_2019 5_38_01 PM.jpg
IOT Garden – Settings – Firebase console - Google Chrome 5_25_2019 5_38_51 PM.jpg
IOT Garden – Settings – Firebase console - Google Chrome 5_25_2019 5_39_36 PM.jpg

The first step is to create a database for the system. Click on the following link (Google firebase), which will lead you to the Firebase website (you will have to log in with your Google account). Click on the "Get Started" button which will take you over to the firebase console. Then create a new project by clicking on the "Add Project" button, fill in the requirements (name,details,etc) and complete by clicking on the "Create Project" button.

We just require Firebase's database tools, so select "database" from the menu on the left-hand side. Next click on the "Create Database" button, select the "test mode" option and click on "enable". Next set the database to a "realtime database" instead of the "cloud firestore" by clicking on the drop-down menu at the top. Select the "rules" tab and change the two "false" to "true", finally click on the "data" tab and copy the database URL, this will be required later on.

The last thing that you will need to do is to click on the gear icon next to project overview, then on "project settings", then select the "service accounts" tab, finally click on "Database Secrets" and note down the security code of your database. With this step complete, you have successfully created your cloud database which can be accessed from your smartphone and from the Raspberry Pi. (Use the pictures attached above in case of certain doubts, or just drop a question or comment in the comment section)

Setting Up the App

MIT App Inventor - Google Chrome 5_25_2019 7_04_25 PM.jpg
MIT App Inventor - Google Chrome 5_25_2019 6_43_10 PM.jpg
MIT App Inventor - Google Chrome 5_25_2019 6_50_28 PM2.jpg
MIT App Inventor - Google Chrome 5_25_2019 6_50_28 PM3.jpg

The next part of the IoT system is the smartphone application. We decided to use the MIT App Inventor to make our own customized app. To use the app that we created first open the following link (MIT App Inventor), which will lead you to their webpage. Next click on "create apps" towards the top of the screen and log in with your Google account.

Download the .aia file that is linked below. Open the "projects" tab and click on "Import project (.aia) from my computer" next select the file that you just downloaded and click "ok". In the components window, scroll all down till you see "FirebaseDB1", click on it and modify the "FirebaseToken", "FirebaseURL" to the values that you had kept a note of in the previous step.

Once these steps are complete you are ready to download and install the app. You can download the app directly onto your phone by clicking on the "Build" tab and clicking on "App (provide QR code for .apk)" then scanning the QR code with your smartphone or clicking "App (save .apk to my computer)" you will download the apk file onto your computer which you need to shift onto your smartphone to then install.

Programming the Raspberry Pi

_firebase_motor_sensors.py - C__Users_kousheek_Documents_projects_IOT gardening system_code_firebase_motor_sensors.py (3.6.6)_ 5_26_2019 6_38_57 PM.jpg

The Raspberry Pi needs to be flashed with the latest version of Raspbian (Raspbian). In case you plan on using the GrovePi+ shield as we did, flash your Raspberry Pi with the latest version of "Raspbian for Robots" instead (Raspbian for Robots). Once you have flashed your Raspberry Pi you will need to install an additional python library. Open the terminal and paste the following commands:

  1. sudo pip install requests==1.1.0
  2. sudo pip install python-firebase

Once that is done, download the file attached below and save it onto a directory on your Raspberry Pi. Open the file and scroll down to line 32. On this line replace the part that says "paste your URL here" with your database's URL that you had noted earlier, make sure to paste the URL in between the ' 's. With this, you are done, open the terminal and run the python script using the "python" command.

Downloads

Using the App

Screenshot_2019-05-26-18-40-46-331_com.miui.home.jpg
Screenshot_2019-05-31-09-03-51-516_appinventor.ai_kousheekc.IOT_garden_monitoring_system.png

The interface of our app is quite self-explanatory. The top four boxes display real-time values of luminosity, temperature, humidity and the soils moisture content in percentages. These values can be updated by clicking on the "get values" button which instructs the Raspberry Pi to update the cloud database followed by the "refresh" button which refreshes the screen once the database has been updated.

The lower section of the screen is for the drip irrigation system. The "on" button turns on the water pump while the "off" button switches it off. The "auto" button utilizes the various sensor values to calculate the exact water needed on a daily basis and waters the plants twice per day at 8 AM and 4 PM.

Tarpaulin Liner

IMG_8838.JPG
IMG_8836.JPG
IMG_8840.JPG
IMG_8842.JPG
IMG_8875.JPG

As the soil's moisture might rot the wood over time, we cut down a sheet of tarpaulin to size and lined it on the inner surface of the planter. Make sure to pull it over the sides and then finally hold it in place with some glue. Once done we filled in soil that we got from a local farm. Spread the soil evenly till the top and then embed the three rows of the drip irrigation tubing.

On the corner near the water pipes fit the electronic box and embed the moisture sensor into the soil. These makes the wiring job easier as the solenoid valve is near to the electronics and can be easily connected.

Drip Irrigation System

IMG_8865.JPG
IMG_8866.JPG
IMG_8848.JPG
IMG_8868.JPG
IMG_8870.JPG

Cut three pieces of the surgical tube stretching along the length of the planter (around 70cm) this will act as the main drip line for the plants. Therefore plan out the needed spacing between the plants and drill a 1mm hole and the intervals. Test if the water drips easily and enlarge the holes if needed. Use the three plugs to close the ends making sure the water is restricted to come out only from the drip holes.

Slightly embed the tubes in the soil and your ready to water your plants!

Planting Results

IMG_8893.JPG
IMG_8891.JPG
IMG_8895.JPG
IMG_8911.JPG
IMG_8913.JPG
IMG_8916.JPG

The pictures above are the results of the iot garden working for a month. The plants are healthy and we managed to grow herbs such as mint and coriander.

Through experimentation, we have noticed that the auto-mode saves close to 12% of water per day. As the plants are watered through drip irrigation, their roots grow straight giving more space to grow more plants in the planter. The only drawback that we observed was that the bigger plants need more soil depth. That said due to the modular construction one can easily add a deeper base to their requirements.

To conclude, this system not only makes your garden more efficient but also ensures the well-being of your plants as the real time data feedback provides a robust method to give the right amount of water and sunlight. We hope that the instructable was useful and that it will help you grow your very own iot garden.

Happy making!