The block maps the specified value from the first range to the second range.
Learn about soil moisture sensors and how they work to measure the moisture level in the soil.
introduction
The 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
- Goto 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 Arduino palette, add the “map () from ()-() to ()-()” block. Replace the placeholder “0” with the map block.
- From the sensor palette, insert the “read analog sensor () at ()” block in place of “50”, and change the data range from 0-1023 to 0-100, also add “when flag clicked” at the start of the script, from event palette. As shown below.
- Add an “if-else” block from the controls palette. Use it to check whether the value of the sensor greater than 50% or not.
- If the value is greater than 50%, activate the buzzer connected to pin 13.
- And if the value if less then 50% then the buzzer must remain OFF.
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
Read More