Introduction: Automated Plant Pot - Little Garden
I am a student from Multimedia and Communication Technology at Howest Kortrijk. For our final assignment, we had to develop a IoT project of our own choice.
Looking around for idea's, I decided to make something usefull for my mother who loves growing plants and began working on an automated plant pot.
The main tasks for this automated plant pot, Little Garden, are to:
- Measure the
- Light intensity
- Soil moisture
- Save the measurements to a database
- Improve the conditions for the plant growth if a certain value is too low
- Let the device be monitored and managed through a website
Not every step has to be followed to the mark. A lot of what happens can
be your personal preference or be improved upon. This build was made in a way so parts could be recuperated afterwards, so you might want to approach your itteration differently to make it more permanent
Step 1: Supplies
Most supplies for this project aren't very difficult to acquire, though in my case I worked with a lot of recycled materials. I also had to ensure I could recuperate some materials afterwards.
- Raspberry Pi 4 model B
- Raspberry Pi power supply
- Raspberry Pi T-cobbler
- 16GB micro SD card
- Breadboard power supply with 3.3V and 5V
- 12V power supply
- DHT11: Humidity and Temperature Sensor
- BH1750: Light intensity sensor
- Soil moisture sensor
- 220V Water pump
- 12V LED strip
- Relay module Velleman
- TIP 50: NPN transistor
- 16X2 LCD-moduke display
- 3 x 330 Ohm resistors
- 1 x 5k Ohm resistor
- 2 x 10k Ohm resistors
- 1 x 1k Ohm resistor
- 1 x 10k Potentio resistor
- Prefabricated greenhouse/plant pot
- Junction box
- Plastic water bottle
- Jumper wires + regular wire
- Soldering tin + heat shrink tubing
- Double sided ducktape
- Glue gun
- Soldering iron
- Box cutter
- Paint brush
The neat thing about this project is that it can be expanded upon or simplified, by adding/removing components and slightly tweaking the code. For instance, by replacing the 220V pump with a 12V pump, you can remove a power adapter from the device.
Step 2: Fritzing Schematic
The breadboard and electric schemes for the device are shown above. Here you can see how all the components are connected together.
A general explanation of how the components works:
- The DHT11 measures the air moisture in % and the temperature in °C. The communication with it is handled by a I2C bu.
- The BH1750 measures the light intensity in lux. The communication is handled by a I2C bus
- The soil moisture sensor creates a digital signal that is converted by the MCP3008 to a readable digital signal for the Raspberry Pi
- The 16x2 LCD-module displays the IP addresses from the Pi, one after the other. It is connected to a PCF8574a that receives a signal from the Raspberry Pi that will convert it to a number of signals for the bit pins of the display. The E and RS pins from the LCD are connected directly to the Pi.The potentio resistor determines the brightness of the screen.
- The water pump is connected to a relay that is between it and it's 220V power supply/socket. The Raspberry Pi can send a signal to the relay to close the electric circuit and turn the pump on.
- The LED strip is connected to the 12V power supply and the TIP 50 (NPN transistor) that toggles the electric current. The 1k Ohm resistor is used to limit the drawn power from the Raspberry Pi, otherwise it would be fried extra crispy.
Step 3: Prepare the Raspberry Pi
If you haven't got one yet, you will need to put one of the Raspberry Pi OS images on the SD card. I do not recommend using Lite, as this caused me issues at the start. Afterwards you will have to make sure your Pi is up to date by using the following commands while the Pi is connected to the internet:
- sudo apt-get update
- sudo apt-get upgrade
After which you can enable or install the packages for the project to work, either through raspi-config or commands.
- MySQL: next step
- SocketIO: pip install flask-socketio
Step 4: Database Model - MySQL
Above you can see the ERD diagram which is hosted through MariaDB. I recommend following this MariaDB installation guide, not only to install MariaDB, but also to make sure your Pi is protected.
For people who'd like to understand, the database works as following:
The measurements and actuator toggles are stored as rows within the Metingen table.
- metingId = ID of the measurement/toggle row
- deviceId = ID of the device responsible for this row in the table
- waarde = value of the sensor measurement or actuator toggle
- sensor: value of the measurement in the corresponding units
- actuators: 0 = OFF and 1 = ON
The settings for the device are stored within Settings.
- settingId = ID of this row and the setting value
- deviceID = ID of the corresponding device/sensor
- waarde = value of the setting
- type = type of the settin, is it maximum or minimum?
Last but not least, the Devices table holds information on the sensors and actuators.
- deviceId = ID of the device in this table
- naam = name of the device/component
- merk = brand
- prijs = price of the component
- beschrijving = summary of the component
- eenheid = unit for the measured values
- typeDevice = specifies whether the component is a sensor or actuator
Step 5: Frontend: Setting Up the Webserver
The Pi will require you to install the Apache webserver in order to run the webserver for this device. This can be done with the following command:
sudo apt-get install apache2.
Once this is done, you can navigate to the folder: /var/www/html. Here you will need to place all the code of the frontend. Afterwards, you can access the website by browsing to the IP address.
Step 6: Backend
To run the backend, you will need to run the app.py file, either manually or by creating a service for it on the Pi so it starts up automatically.
As you might notice, there are quite a few files. I separated the code as much as I could to have a clear overview and organization of the code.
A brief explanation:
- app.py: The main file where the database, hardware code and backend code is joined.
- config.py: The configuration file for the databaseRepositories.
- Repositories: For access to the data repository
- devices_id: classes to help identify the device information in the database
- lcd: to run the PCF and LCD
- Actuators: classes for running the actuators
- Sensors: classes for running the sensors
Step 7: Placing the LED Strip
I cut a piece of the LED strip and glued it to the top of the greenhouse box. The strip I used could be cut at multiple positions and reconnected, so you could place multiple strips and connect them again afterwards through wires, allowing more space to be lit up.
Step 8: Placing the Tubes.
The tubes could be placed in a number of ways, but in my case I attached them to the side of the bottom, keeping them as far from the other electronics as possible and letting the water simply flow into the dirt.
Step 9: Placing the LCD
I cut a whole in the lid of the junction box with a sawblade, creating an opening large enough for the display to get through, but small enough so the PCB would stay behind it. Afterwards, it was attached to the lid using skews.
The LCD displays the IP addresses of the Raspberry Pi, making it possible to know what address you can use to surf to the website.
Step 10: Placing the Sensors and Connecting the LED Strip
Using the fritzing schemes, I soldered connections between the wires and placed the resistors inside the wires, using heat shrink tubes to isolate them.
Holes were cut in the sides of the greenhouse's lid and bottom to attach the swivels, through which I pulled the wires for the sensors and LED strip.
I grouped the wires by function. The tension from the wires and shrink tubes itself held up the sensors. I only had to use glue on the wires for the DHT11 since this extended further.
Step 11: Wiring Up the Pi
I cut holes in the side of the junction box to allowe the wires to come through later.
After that, I placed the breadboard (with the T-cobbler, PCF8574a, MCP3008, adjustable resistance and TIP50), relay and Raspberry Pi on the bottom of the junction box, which was covered with double sided ducktape. The power supply did not fit on the breadboard, so I had to put it on the side and used jumper wires to connect it to the breadboard.
Finally I pulled the adaptor, sensor and actuator wires through the holes connected the wires to the breadboard, Raspberry Pi and other components. The wire of the pump was cut open so I could place the ends inside the relay so it could be used as a switch.
Step 12: Making a Container for Water
I made a water container from an 1l plastic water bottle by cutting the top of with a box cutter and painting it for a better look. The water pump was then placed inside. Cause of the rule of communicating vessels, the water could potentially flow through the pipes on it's own, but holding the tube up fixes the issue.
Step 13: Final Result
The moment you have been waiting for. Now you can place the dirt and seeds inside the greenhouse box and let the device take over. You can monitor the status of the device from the website and set the optimal values for the lighting and soil conditions.
I recommend watering the soil first manually, as some dirt can be pretty dry at first. Some pumps also seem to water quite slowly, but you do need to be very carefull as it will fill up faster then you'd expect. A saturation of above 80% can make the ground very soggy. And do make sure the soil moisture sensor is deep enough.
Participated in the
2 years ago
this is amazing!
I alwas wanted to make somthing like this
Reply 2 years ago
Thank you :D. If you have some issues while building, feel free to message me.