How to Build an Automated DIY Irrigation System With App

by patrickhallek1998 in Circuits > Raspberry Pi

12064 Views, 162 Favorites, 0 Comments

How to Build an Automated DIY Irrigation System With App

1_5Gx4DcFLFjBkBh2-EtTBBw.png
1_9K0E8xxZZdqXMtckyG7B_A.gif

In this article I will show you how to build an affordable automated irrigation system so you no longer have to water your plants by hand. The system can be used for house plants, raised beds, but also for plants in the garden or larger green areas, because the number of connected plants is scalable.

Here, the decision as to when to irrigate is not made according to a timer, but rather the soil moisture is measured directly and a decision is made on the basis of this whether irrigation is necessary or not.

The system has the following features, which can be controlled via the web app:

  • Monitor and display time series data at the minute, hour, day, week and month levels
  • Setting the water level from which automatic watering should be triggered
  • Setting how long the pump works during an irrigation
  • Manual activation of irrigation with a button
  • Switching between different sensor profiles
  • Switching between dark and light theme

Part List

The “n” in the amount is due to the number of pumps or different plants. For example, in a raised bed it is usually sufficient to have one pump and one sensor. However, if you have different potted plants, they all need to be watered separately and therefor you have to get one pump and sensor for each potted plant.

Hardware Architecture

1_fJBhjTz0mYcijxr51k59CA.png

To measure the soil moisture, the NodeMCU ESP8266 microcontrollers read the analog signals of the capacitive sensors. The filtered and interpolated measured values are then sent through your local network to the Raspberry Pi. This is where you decide whether or not to trigger the relay associated with the sensor. When the relay is opened, the circuit to the pump is closed and the plants get watered.

The architecture was chosen so that pump logic and recording of measurement data is separate. This makes it possible to control up to 26 pumps with the Raspberry Pi (amount of default available GPIO pins). It is also not possible to read the analog signals of the capacitive sensor with the Raspberry itself, because the Raspberry can only process digital signals. Surely it is possible to read the sensors with an MCP3008 and the serial interface, but this requires more pins and the setup is not as clean as it used to be. The pumps are also separately connected to a power supply, whose circuit is controlled by the relay. So it is also possible to use 12V or higher pumps.

Software Architecture

1_KHRrtK-Xhjnqbcxz35GAyQ.png

For the software architecture the MERN Stack was used. The software consists of a Node.js backend with Express.js, a Mongo database and a React frontend. A C++ script runs on the NodeMCU ESP8266, which sends data to the REST interface of the backend. The data is processed in the backend, where it is decided whether to irrigate or not. In addition, the data is then stored in the MongoDB. With the frontend, this data can also be requested from the backend via REST.

To install the complete software, please follow the instructions on GitHub

3D Printed Box for the Electronics

1_a60TucZlHp-_Mx3bkMI6DA.jpeg

I designed and printed a magnetic box for the Raspberry Pi and the NodeMCU controller. You can download the STL files of the box here.

Congratulations, You No Longer Have to Water Your Plants by Hand!

1_PzjGQa_yb9LrGyCwPFXYtQ.gif

If you have installed the hardware and software correctly, you should now be able to see your first measurement data in the application.

To call up the application in your browser, you must enter the following URL: http://:5000. Of course you have to replace with the IP address of the Raspberry Pi. Now you can enter under preferences in the application the signal pin to which you have connected the pump belonging to the sensor. Afterwards you should plug the capacity sensor into the ground and set a value for minimum soil moisture at which the PIN and thus the relay should be triggered. That’s it! After setting the other preferences, the pump will be activated according to the preferences you have set. If you have several sensors connected, they are listed above as tabs. Select the appropriate tab to set and monitor all sensors individually.

Help to Improve the Software!

I would be very grateful for any feedback you can give. Here you can set issues that might arise during the installation. I will try to solve them as soon as possible. You can also help with further development and create pull requests to improve the software. For further questions you can contact me on LinkedIn.