Project Intro
This project is aimed to create a plant monitoring and watering system. The main task is to control the servo, relay and collect the soil humidity data from the plants. Huge amount of the sensors use analog signal as output but the Raspberry Pi doesn’t have an analog-to-digital converter. To solve this problem, I used an outer ADC module and an Arduino gateway because they have built in ADC. When we want to interact with the environment we usually need pulse width modulation. I found 3 ways to solve this problem. The first one is the software PWM, the second one was the Arduino gateway and the last one was to use a PWM capable module/IC. I implemented the first two methods because I’ve implemented an I2C device before. The ADC and PWM are used very often in the Arduino world so if we want to use GPIO on Raspberry Pi we usually want at least one of these features to run on our Raspberry.
The application has two modes: an automatic mode when it detects if the plant need some water and a manual mode where you can control the servos and relays manually. Because the servo can rotate approximately 180 degrees one servo can water only 2 plants. The automatic mode is the default. When we read soil humidity sensors we categorize its value. There are 5 categories. The driest one is in categories 5 and marked with red on the GUI. Its opposite the category 1 is marked with green. A timer will check periodically these values and if the category of ‘plant A’ or ‘plant B’ higher than acceptable (so the ground is too dry) it waters the drier one. In the same period the program checks and waters the other two plant (‘plant C’ and ‘plant D’) in a similar way and do this in every period.
The components
- Servo SG90:
Driving a servo usually requires large GPIO clock frequency. The default provider is not good enough so I used the lightning provider. There was an issue with the first power supply of the Pi. I’ve read it somewhere that the Pi might need a better performing one and servo consume a lot of power compared to other sensors. These two resulted performance issues. Now with the iPad’s charger it works much better but sometime it still hesitates. A servo circuit with outer power supply could solve the problem like this one:
And as I thought this has solved the problem and now it works perfectly. I’ve connected the servo’s Vcc to the power supply’s 5V and the signal remains the same and we have common ground. Here is the new connection:
Read More: Windows 10 IoT Plant Monitoring System