introduction
A soil moisture sensor is a valuable tool used to determine the moisture content in the soil, crucial for efficient gardening, farming, and agricultural practices. This analog sensor generates varying output values depending on the moisture level present in the soil. Typically, it operates as a two-pin circuit, with these pins responsible for powering up the sensor module. To obtain soil moisture readings, a voltage divider circuit is employed on the negative pin of the sensor, resulting in a signal pin that provides the moisture level data. Alternatively, some sensor modules come with a controller circuit that automatically converts the 2-pin connection into a 3-pin output, simplifying the process of accessing moisture values.
Below is a simple circuit diagram and code to get you started with monitoring soil moisture using an Arduino board. By following these steps, you can create your own moisture monitoring system with ease. Let’s begin!
circuit diagram
Code
- Go to my variables and create a variable and name it “moisture level.” Set its initial value to 0.
- Add a “forever” loop from the control palette.
- Inside the forever loop, add a “set () to ()” block using the “my variable” category. Set the variable “moisture level” to the output value of the next block.
- From the Quarky palette, add the “map () from ()-() to ()-()” block. Replace the placeholder “0” with the map block.
- From the Sensors palette of Quarky, insert the “read analog sensor () at ()” block in place of “50”, and change the data range from 0-4095 to 0-100, as shown below. 0 stands for 100 percent moisture and 100 means completely dry
- Add an “if-else” block from the controls palette. Use it to check whether the value of the sensor is greater than 50% or not.
- If the value is greater than 50%, activate the buzzer connected to pin D2 otherwise the buzzer must remain off.
- Finally, add the “when flag clicked” block at the start of the script to initiate the monitoring process.
Script
With these steps, your script is complete, and you can now monitor the soil moisture effectively using the soil moisture sensor and Arduino board. Happy gardening and farming!
Output