"Do you have a holiday and worry about the plants in your home? The project will bring you an automatic irrigation system to help you manage the plants in your home.
The Planting4U irrigation system is a newly developed platform that controls watering procedures, and provides users with basic information through their own websites. This allows full control and overview from anywhere in the world. This product is easy to expand and can be further developed to meet all your needs.
The following instructions will show you all the steps and methods needed to copy the automatic irrigation system. This DIY project can also be used as guidance if you like to take risks and want to use different components and / or supplies to create your own intelligent irrigation system.
The CAD design and software components of the irrigation system can be found in the following Github repository: https://github.com/patrick2428/p4u
Supplies
Raspberry Pi Zero
2 channel relay module
RPI modulus converter
Moisture sensor
Temperature and humidity sensors
Mini piston pump
PVC hose (7-9mm)
Perforated plate (70 x 100 mm)
additional:
Electrical line; welding equipment; 3D printer
Screw: 4x 30mm m3; 8X 10mm M3; 2X 12MM M3
Nut: 14 x m3
Step 1: Electrical hardware settings
The circuit required by the system is shown in the figure above. Raspberry Pi Zero (RPI) is a processing unit for irrigation systems. As long as the moisture content detected by the moisture sensor is too low, it indicates that the piston pump is dispersed into the plant. In addition, the relative humidity and temperature of the environment is obtained using the temperature and humidity sensor.
Since users may be interested in understanding their plant status and water circulation, all important data is saved to the local database, the most relevant data to the local running website.
Overview Different Electrical Connections and Data Paths:
I2C interface
The I2C interface on RPI (SDA and SCL) allows multiple master devices and slave devices. This standard allows you to connect multiple devices, such as temperature sensors, humidity sensors, and ADCs. This allows you to connect a large number of sensing units, depending on the number of plants you have, and what you want to expand your system. It is important to know that each sensor requires a separate address to make the I2C interface. Unfortunately, this limits the use of similar components because most of them have 2-6 different address configurations.
In our example, we can connect,
2 SHT-31D temperatures and humming sensors, available addresses 0x44 and 0x45.
4 ADS1115 ADC, available address is 0x48, 0x49, 0x4a and 0x4b
ADC connection
The humidity sensor has an analog signal output, and the RPI cannot be processed because it does not have a board analog-to-digital converter. To this end, an additional ADS1115 ADC is required, which can connect up to 4 analog devices. The ADC transmits the converted signal to the RPI via I2C. As we have previously established, up to 4 ADS1115 ADCs, which can connect a total of 16 humidity sensors to the system.
Relay connection
2 Module relays are used as switches for opening or closing piston pumps. When the relay receives the HIGH signal from the RPI, it opens the switch to allow current to flow to the pump. When the signal is low, the switch remains closed. By this mechanism, the RPI can freely open or close the pump from the humidity level received from the humidity sensor. The relay is used because you may want to replace the pump with a more powerful pump, which requires a voltage input of 230V / AC.
Step 2: Hardware housing
Since the system involves irrigation, there is a chance to have water splashes, so it is recommended to seal all electrical components in the housing. The figure above describes the CAD design of the system and humidity sensor housing. The CAD and STL files of these housing units can be found in the GitHub repository that can be used to modify or 3D printing housings.
You will find an additional sprinkler header design that can be connected to the end of the hose to better assign water to your plants.
The system housing contains all major electrical components, such as RPI, relay modules, and temperature and humidity sensors. The outer casing is divided into upper cover, middle section and lower cover. All three parts are combined with 4 30 mm M3 screws. RPI and relays are secured in the lower cover using 8x 10mm M3 screws. The middle is equipped with (70x100mm) perforated plate, ADC and temperature and humidity sensors to be connected to the perforated plate.
The humidity sensor housing consists of two parts, upper cover and lower cover. The outer casing unit is responsible for preventing water from causing any damage to the humidity sensor placed next to the plant. It is recommended to cover the electronic device of the sensor itself with a rubber shrink sleeve to allow 100% waterproof. The device is secured together using 2 12 mm M3 screws.
Step 3: Hardware assembly
The above figure shows the final result of welding the electronic components and placed in a 3D print housing after hardware assembly. Cables and connectors can be freely selected. Additional plugs for connecting the pump and humidity sensors can be added to separate the components from each other.
Step 4: Set Raspberry Pi Zero (Processing Unit)
As mentioned in the previous steps, the Raspberry Parts will be used as processing units for automatic irrigation systems. RPI will run the control loop of the irrigation program and the web server that hosts the Irrigation System UI website. However, before we can perform any software components, you first need to configure and correctly set the RPI.
Note: Any text that enters "Body" is the terminal command within the RPI terminal.
Step 4.1: Refresh the SD card using the Raspberry Pi operating system (link) (minimum 8GB)
The official website provides an Imageer tool that allows you to write the SD card without using any external application.
Step 4.2: Start the Raspberry Pi and connect to the Internet.
To interact with RPI, there are several options, such as using standard mouse, screen, and keyboard connections, or use SSH connections. To enable SSH for the first time, you only need to create an empty SSH folder in the boot directory of the flash image. The following website provides a detailed overview of the steps involved.
If you are like me and only limited accessories (no additional mouse, keyboard or OTG Ethernet adapter), you may want to know how to connect to your RPI using SSH without having to connect it to Ethernet. Ok, thank you, you can create a headless WiFi connection with the home router by configuring the boot directory on the SD card. Create a WiFi connection in accordance with the guidelines on this website.
Step 4.3: After starting and connected, run the "Sudo Apt Update" and "Sudo Apt Upgrade" for fast update in the terminal to get all the latest packages.
Step 4.4: Causes the supplied Git repository to your RPI: https://github.com/patrick2428/p4u
Go to the primary directory on the RPI and enter the following command
'git initialization'
'git cloning https://github.com/patrick2428/p4u.git'
Note: Free to delete all documents, CAD, and STL files because they only take up unnecessary space.
Step 4.5: Enable interface configuration.
Enable GPIO and I2C:
'sudo raspi-config' -> Interface options -> i2c -> Enable
'sudo raspi-config' -> Interface options -> Remote GPIO -> Enable
In the next section, two different software components of irrigation controllers and websites will be discussed and used.
Step 5: Run irrigation control software
Irrigation control software is encoded with Python. Python is an excellent universal scripting programming that is running well on the Raspberry PI processing unit.
Irrigation control software is located in the cloned Git warehouse: Planting4U / Code / IrRiguration_system /
The main executable script is "irrigation_control_system.py", which will run the full irrigation control loop. However, before we start the software, we need to install some extra python packages:
(Note: PIP is a package management system, you should be installed by default)
You can now test the irrigation control script and see if all electrical connections are correct.
Use the following command in the IRRIGATION_SYSTEM directory: 'Python Improvement_Control_System.py'
If everything is normal, the system will give you a start message, then output information per second.
To learn more about past irrigation cycles or data, you can view the log part: Planting4U / code / irrigation_system / logs /
Step 6: Set the irrigation UI website
The website that publishes the basic data from the user consists of two web pages, a login page and a home page. These are all created from HTML, JavaScript, and CSS from the head to define the layout, design, and dynamic behavior of the website.
The login page only needs the user to fill in the correct credentials (see step 6.2) and then navigate to the home page. The home page shows all related data for the irrigation system, and allows the user to change the humidity level setting value (pump trigger level).
The site's software is located in the cloned Git repository: Planting4U / Code / Website /
To set the site and publish it from the Raspberry Pi to your local network, follow these steps:
Step 6.1: Install node.js for the server-side handler.
Node.js is an open source JavaScript running environment for running the server side of the website (backend). The server is responsible for publishing and processing the client (front end).
Note that only a particular version of the node can work on RPI zero. For more details, see the official node.js website.
You can use the following Installation Guide to install the appropriate software version. The version used by the project is: 'wget https://nodejs.org/dist/latest-v10.x/node-v10.24.1-linux-armv6l.tar.xz'
Please note that some olders do not support the latest library for website application server-side code.
After the installation is complete, navigate back to the website directory Planting4U / Code / Website /.
Step 6.2: Install the Node Bcrypt module
An additional node module must be installed before you can perform the JavaScript software in the website / directory.
The Bcrypt module needs to encrypt the password to prevent any data leakage. Just run the following command
'npm I bcrypt'
Note that if you seem to have any other module errors in the next step, see the Readme file in the Website / directory to learn all the modules installed first, and try to reinstall them.
Step 6.3: Create a username and password
The default user name and password of the site are:
Name: User
Pass: 1234
These login credentials are stored in the /Data/user_info.json file. Because the password is encrypted, you cannot simply enter the file and change the variable as needed. To change login credentials, you must use nodes to run the following JavaScript files:
'Node Create_New_User.js'
Reset your username and password according to the instructions displayed on the terminal
Step 6.4: Install apache server
Apache HTTP Server is a free open source web server software that will be used to publish our website. We just passed the server handler (Server_Handler.js) agent we created to Apache to publish a Planting4u website on our RPI local host.
To install server software, use the following command:
'Sudo Apt Install Apache2 -Y'
After installation, you can test the web server. Simply browse 'http: //
' on the local machine. The default HTML file of Apache should be described. If you don't try to restart the server.
Step 6.5: Set the Apache and proxy delivery Our custom server handler
In order to release our website (client), we need a proxy to pass our server handler (port: 3000). This will allow Apache to access custom web pages and publish it to your local or public network.
Agent Pass the back-end server (localhost: 3000) to Apache2:
First, navigate to / etc / apache2 / sites-available / in the RPI terminal. Then open the file 000-default.conf
'Sudo Nan O 000-Default.conf'
And enter the following line: 'proxypass / http: // localhost: 3000 /'
Second, the agent is enabled in Apache2.
Navigate to / etc / apache2 / sites-enabled /And run the following command:
'Node Create_New_User.js'
This command allows you to enable a variety of Apache modules. The two modules to be enable are proxy and proxy_http. Follow the instructions to run A2ENMOD twice to enable both modules.
Third, restart the APACHE server using the following command:
'Sudo Apt Install Apache2 -Y'
Step 6.6: Start the server handler script.
The last step is to start the server_handler.js script under the Planting4U / Code / Website / directory.
Just enter the command: 'Node Server_Handler.js' to start the JavaScript file. You should pop up a text and say "listen in 3000"
Your server is now running on the local Internet connection, which means that all devices connected to your home router can be connected to the site by browsing: http: // http: //192.168.2
Note: To publish the site to the public network, some additional steps are required, which will be discussed in the last step of this tutorial.
Step 7: Complete and run automatic irrigation system
Be
In the previous step, we have covered all the hardware and software of the system, and provide DIY drills for setting all content. Now we can complete the system and execute all software units as an integrated system.
In the current system state, you can perform server_handler.js and iling_control_system.py scripts separately, and the system will run in the case of the website and the irrigation control cycle. However, this will become bored and you need to log in to RPI every time you have to start the system. Another method is to use cron to start and stop scripts.
CRON is a software utility on the RPI operating system that acts as a time-based scheduler. You can use cron to start the application at startup or at the specified date and time. For the sake of simplicity, we will configure CRON to start the website and irrigation software when starting the RPI.
Open crontab: 'crontab -e' and select an editor, such as NANO.
Enter the following two lines below the comment section:
1: @reboot python /iration_control_system.py #NPY #Noot Irrigation Control Cycle Script
2: @Reboot Node /server_handler.js # Start the server handler script
After you turn off and save your file, you can use "crontab -l" to carefully check your command.
Now restart your system, it should be fully launched and run. You can check the crontab log file using the following command: 'grep cron / var / log / syslog'
The system is now fully set, it can be used. Please note that the site is still running on your local network and cannot connect to external access from home routers. View the next additional section to publish the website to the public network.
Step 8: Conclusion
The Planting4U automatic irrigation system is a starting prototype, which can be easily modified and expanded according to your needs. The simplicity and limited resources of the design are to encourage you to further develop systems.
With the current version, you can use the website interface to control and observe the water circulation of home plants. This interface is simple and user-friendly design, which can add more features, such as data graphs, original data overview, and even webcam interfaces for viewing factory status. For systems that control many plant water cycles, more sensing units and more powerful pumps are needed. These extensions are easy to apply, just plus the software and hardware.
Although many other modifications can be added, in the current state, it can be used as a functional system, which can be used to control the plant's irrigation procedure.
Step 9: Additional - Transplant the site to the public network
There are several alternatives to publish your website to a public network. The main requirement for this is to set a static IP address for your system, you can get the address by contacting your Internet service provider. "
Our other product: