Alert System of Low Moisture Soil for Your Plant
by silicioslab in Circuits > Arduino
791 Views, 4 Favorites, 0 Comments
Alert System of Low Moisture Soil for Your Plant
In several residences, it is common to find jars with different types of plants. And with the great number of day-to-day activities, people forget to water their plants and they end up dying for lack of water.
As a way to avoid this problem, we decided to create a system to inform when a plant has no water. In this way, you will never forget to irrigate your plant and it will stay alive for a long time. Next, we will present the whole development of this project.
Supplies
Project Development
One of the ways that we use to detect the quantity of water in the plant is through the moisture parameter. So, the less water is in the jar of our plant, the lower the soil moisture.
Therefore, we must use a humidity sensor to analyze the state of moisture in our plant.
Through it, we set up a circuit mounted in the breadboard with Arduino, to carry out the monitoring and indication of low humidity of the cactus jar. So, by means the display LCD to inform our user about the moisture, as is shown in Figure 1.
Inserting the Moisture Sensor Into the Circuit
From the above circuit, we will insert the probe for humidity measurement in the plant that we wish to monitor. In our project, we insert a probe into a small cactus, as shown in Figure 2.
Now, We will see how to project work step-by-step and hereafter, will learn how to create the controlling code.
Initially, when we do not connect the sensor inside the jar, the device has a low moisture content of 2% outside the cactus jar. This can be seen in Figure 3.
Understand the Moisture Values
This low percentage value represents a low humidity. Now, after inserting the sensor into the soil of the cactus jar, a value of 36% will be displayed, as is shown in Figure 4. That is, our humidity is low and the system displays the message Low Moisture because the value is less than 60%.
The next step is to irrigate the soil of the pitcher of our cactus and we can verify the increase of the value of the humidity to 69%.
After understanding the working of the project, we will present all the construction logic to create this monitoring system. Let get started!
Logical Programming
Hereafter, the programming logical will be presented through the code constructed.
Initially, was declared the library of Display LCD, variables and was created an object LCD with its pins of connection with Arduino UNO.
<p>#include <br>#define sensor A0 bool LCDControl = 0, LowUmid = 0, HighUmid = 0; byte UmidityPercent = 0, moisture = 0, PreviousValue = 0; int ValUmidade = 0, AnalogValue = 0; const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7; LiquidCrystal lcd(rs, en, d4, d5, d6, d7);</p>
After this, the setup function and display LCD 16x2 were initialized and the pin of the sensor was configured as an input.
Finally, we made the first reading of our sensor and we used as a reference for variable PreviousValue, as is shows below.
<p>{<br>Serial.begin(9600); lcd.begin(16,2); pinMode(sensor, INPUT); PreviousValue = analogRead(sensor); }</p>
With the variables created and the commands in the void setup function, we will explain all logical programming in the loop function.
<p>//Le o valor do pino A0 do sensor<br>AnalogValue = analogRead(sensor); //Mostra o valor da porta analogica no serial monitor Serial.print("Analog Port: "); Serial.println(AnalogValue); UmidityPercent = map(AnalogValue, 0, 1023, 0, 100); moisture = 100 - UmidityPercent;</p>
In the loop function, the analog value was read and the value was mapped in a range of 0 and 100. This value represents a percentage of moisture of soil. When the moisture is high world, the value approaches 0 and if the moisture is low the value approaches 100.
To facilitate the representation of the value and to prevent the user's reading confusing, we reverse this logic and represent that 0% will be low humidity and 100% high humidity. This was made by means of the calculation performed after the mapping.
<p>moisture = 100 - UmidityPercent;</p>
After to read the moisture value is need to present in the Display LCD. The next step is to verify if moisture value is different from its value plus 1 or its value minus 1, according to the condition below.
<p>if( (moisture > (PreviousValue)+1) || (moisture < (PreviousValue)- 1))</p>
This condition is used to prevent the system to present the same value several times in the Display LCD. But, when the condition is true, the system will present the value in the LCD and will verify if the value is more or equal than 60% ou less than 60%.
If the value was more or equal than 60%, the system present the message High Moisture, otherwise, present the message Low Moisture, as is shown below.
<p>if( (moisture > (PreviousValue)+1) || (moisture < (PreviousValue)- 1))<br> { lcd.setCursor(1,0); lcd.print("Moisture: "); lcd.print(" "); lcd.setCursor(11,0); lcd.print(moisture); lcd.print("%"); if(moisture < 60 && LowUmid == 0) { lcd.setCursor(1,1); lcd.print(" "); lcd.setCursor(1,1); lcd.print("Low Moisture"); LowUmid = 1; HighUmid = 0; } if(moisture >= 60 && HighUmid == 0) { lcd.setCursor(2,1); lcd.print(" "); lcd.setCursor(1,1); lcd.print("High Moisture"); HighUmid = 1; LowUmid = 0; } PreviousValue = moisture; }</p>
Finally, the system will be store the value of moisture variable in the PreviousValue variable to actualize its value. Each time of a new value is presented in the display the variable PreviousValue is actualized to be used in others cycles of processing of the code.
Therefore, this is a simple system used to monitoring the moisture of plants in our residances and inform at users about the soil moisture level.
Acknowledgments
The Silícios Lab thanks PCBWay for its support and work together. And we have many benefits for you. Earn 10 free PCBs and lots of bean coins (Know more) to trade for products on the PCBWay website.
In addition to them, the Silícios Lab thanks UTSOURCE for its support, for offering us the low cost electronic components of great quality and good service.