Moisture Sensor
|
![Moisture-Sensor](/w/A6Y79bcq/Kdy80nYY.php?f=Moisture-Sensor_l.jpg&width=300)
Moisture Sensor
|
|
|
|
|
|
|
|
|
|
|
Overview
- Fork-like design, make it easy to insert into the soil.
- Output voltage boosts along with the soil moisture level increases.
Specification
- Detection depth: 38mm
- Power: 2.0V ~ 5.0V
- Dimension: 20.0mm * 51.0mm
- Mounting holes size: 2.0mm
Pinouts
PIN |
Description
|
VCC |
Power input (2.0V~5.0V)
|
GND |
Ground
|
AOUT |
Analog data output
|
Working priciple
This module uses the current amplification principle of the triode. When soil moisture conducts the transistor's base and the positive pole, the triode will produce a certain size between the base and the emitter current, at this point, in the collector of a transistor between the emitter and it will certainly produce a magnification of current, the current through the resistance of the emitter voltage for the AD converter.
Configure Pico
MicroPython and C examples are provided for this sensor, to use it with Pico, you need to first flash firmware to the Pico according to the example.
Please refer to the guides of Raspberry Pi about how to flash the firmware. We recommend you use the firmware from the Demo codes archive.
Hardware connection
Moisture |
Pico |
Description
|
VCC |
3.3V |
Power input
|
GND |
GND |
Ground
|
AOUT |
GP26 |
Analog data output
|
Examples
Download the example
Open the terminal of Raspberry Pi and run the following command to download the example:
sudo apt-get install p7zip-full
cd ~
sudo wget https://files.waveshare.com/upload/5/59/Moisture-Sensor-code.7z
7z x Moisture-Sensor-code.7z -o./Moisture-Sensor-code
cd ~/Moisture-Sensor-code
cd Pico/c/build/
C
Here we use the Raspberry Pi board to flashing the Pico.
- Compile the c examples
- Go into the directory of C examples
cd ~/Moisture-Sensor-code/Pico/c/
- Go into the build folder and add the sdk; ../../pico-sdk is the path of the SDK, if may be different if you have saved the SDK in other path.
cd build
export PICO_SDK_PATH=../../pico-sdk
- Generate Makefile by cmake command
cmake ..
- Compile the codes by command make
make -j9
- Note: If you use Pi zero, please run make only.
- After compiling, a uf2 file is generated.
- Hold the button of Pico board, connect the Pico board to Raspberry Pi by USB cable
- After connecting, release the button and a portable disk (RPI_RP2) is recognized.
- Copy the main.uf2 file generated which locates in build folder to the portable disk (RPI-RP2)
cp main.uf2 /media/pi/RPI-RP2/
Python examples
- In windows PC
- Hold the BOOTSET button of the PICO board, connect the Pico board to Raspberry Pi by USB cable
- After connecting, release the button and a portable disk (RPI-RP2) is recognized.
- Copy the rp2-pico-20210418-v1.15.uf2 file to the portable disk (RPI-RP2).
- Open the Thonny IDE (Please install the newest version which supports Pico board or update).
- Choose Tools -> Options ->Interpreter, choose the Pico and the port
![Pico-lcd-0.96-img-config.png](/w/A6Y79bcq/Kdy80nYY.php?f=Pico-lcd-0.96-img-config.png&width=500)
- Download the demo codes, unzip and find the MicroPython example
- Choose File -> Open -> Moisture Sensor.py and run it.
![Pico-lcd-0.96-img-run.png](/w/A6Y79bcq/Kdy80nYY.php?f=Pico-lcd-0.96-img-run.png&width=400)
- In Raspberry Pi
- Flash the uf2 file to the Pico board just like in the Windows PC
- Open the Thonny IDE of Pi, make sure that it is the newest version, or update it.
- Choose Tools -> Options... -> Interpreter
- If your Thonny IDE cannot support the Pico board, you can update it and try again.
sudo apt upgrade thonny
- Choose File -> Open... -> python/Moisture Sensor.py and run it.
Expected result
Insert the sensor into the soil and gradually add water to the soil. The output data of the serial port changes accordingly
The examples provided are based on the STM32F103RBT6 and the STM32H743, the connection provided is based on the STM32F103RB.
If you want to use other STM32 boards, please change the connection and you may need to port the codes yourself.
Hardware connection
Hardware connection-STM32
Connect to STM32F103RBT6
Moisture |
STM32 |
Description
|
VCC |
3.3V |
Power input
|
GND |
GND |
Ground
|
AOUT |
PA6 |
Analog data output
|
Examples
The examples are based on the HAL library. Please download the demo codes, unzip them and find the STM32 examples.
- Open the project from Moisture-Sensor-code\STM32\STM32F103RB\MDK-ARM by Keil.
- Build the project and program it to the STM32 board.
- connect the UART1 of the STM32 board to the PC and check the serial data by SCCOM software.
![Moisture STM32 3.png](/w/A6Y79bcq/Kdy80nYY.php?f=Moisture_STM32_3.png&width=500)
Expected result
Insert the sensor into the soil and gradually add water to the soil. The output data of the serial port changes accordingly
The examples provided are based on the Arduino UNO, if you need to use other Arduino boards, please check if the board is compatible with the UNO.
Hardware connection
Hardware connection-Arduino
Connect to Arduino UNO
Moisture |
Arduino |
Description
|
VCC |
5V |
Power input
|
GND |
GND |
Ground
|
AOUT |
A0 |
Analog data output
|
Examples
- Please download and install Arduino IDE to your PC.
- Download the demo codes, unzip and find the Arduino examples
- Open the Moisture_Senso.ino file by the Arduino IDE
- Build and upload the codes to the UNO board
- After uploading, you can open the Serial Monitor of IDE and check the data
Expected result
Insert the sensor into the soil and gradually add water to the soil. The output data of the serial port changes accordingly
Resources
FAQ
Answer:
The possible reason may be the threshold voltage is set too large. In this case, please modify the threshold voltage setting to a proper value.
{{{3}}}
{{{4}}}
{{{5}}}
Answer:
The moisture sensor outputs analog data. And an AD convertor is required for sampling.
{{{3}}}
{{{4}}}
{{{5}}}
Answer:
Perhaps you'd like:
Color Sensor
|
|
{{{2}}}
|
{{{3}}}
|
{{{4}}}
|
{{{5}}}
|
{{{6}}}
|
{{{7}}}
|
{{{8}}}
|
{{{9}}}
|
{{{10}}}
|
{{{11}}}
|
{{{12}}}
|
{{{13}}}
|
{{{14}}}
|
{{{15}}}
|
{{{16}}}
|
{{{17}}}
|
{{{18}}}
|
{{{19}}}
|
{{{20}}}
|
{{{21}}}
|
{{{22}}}
|
{{{23}}}
|
{{{24}}}
|
{{{25}}}
|
{{{26}}}
|
{{{27}}}
|
{{{28}}}
|
{{{29}}}
|
{{{30}}}
|
{{{31}}}
|
{{{32}}}
|
{{{33}}}
|
{{{34}}}
|
{{{35}}}
|
{{{36}}}
|
{{{37}}}
|
{{{38}}}
|
{{{39}}}
|
{{{40}}}
|
{{{41}}}
|
{{{42}}}
|
{{{43}}}
|
{{{44}}}
|
{{{45}}}
|
{{{46}}}
|
{{{47}}}
|
{{{48}}}
|
{{{49}}}
|
{{{50}}}
|
Flame Sensor
|
|
{{{2}}}
|
{{{3}}}
|
{{{4}}}
|
{{{5}}}
|
{{{6}}}
|
{{{7}}}
|
{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}}}
|
{{{16}}}
|
{{{17}}}
|
{{{18}}}
|
{{{19}}}
|
{{{20}}}
|
{{{21}}}
|
{{{22}}}
|
{{{23}}}
|
{{{24}}}
|
{{{25}}}
|
{{{26}}}
|
{{{27}}}
|
{{{28}}}
|
{{{29}}}
|
{{{30}}}
|
{{{31}}}
|
{{{32}}}
|
{{{33}}}
|
{{{34}}}
|
{{{35}}}
|
{{{36}}}
|
{{{37}}}
|
{{{38}}}
|
{{{39}}}
|
{{{40}}}
|
{{{41}}}
|
{{{42}}}
|
{{{43}}}
|
{{{44}}}
|
{{{45}}}
|
{{{46}}}
|
{{{47}}}
|
{{{48}}}
|
{{{49}}}
|
{{{50}}}
|
UV Sensor
|
|
{{{2}}}
|
{{{3}}}
|
{{{4}}}
|
{{{5}}}
|
{{{6}}}
|
{{{7}}}
|
{{{8}}}
|
{{{9}}}
|
{{{10}}}
|
{{{11}}}
|
{{{12}}}
|
{{{13}}}
|
{{{14}}}
|
{{{15}}}
|
{{{16}}}
|
{{{17}}}
|
{{{18}}}
|
{{{19}}}
|
{{{20}}}
|
{{{21}}}
|
{{{22}}}
|
{{{23}}}
|
{{{24}}}
|
{{{25}}}
|
{{{26}}}
|
{{{27}}}
|
{{{28}}}
|
{{{29}}}
|
{{{30}}}
|
{{{31}}}
|
{{{32}}}
|
{{{33}}}
|
{{{34}}}
|
{{{35}}}
|
{{{36}}}
|
{{{37}}}
|
{{{38}}}
|
{{{39}}}
|
{{{40}}}
|
{{{41}}}
|
{{{42}}}
|
{{{43}}}
|
{{{44}}}
|
{{{45}}}
|
{{{46}}}
|
{{{47}}}
|
{{{48}}}
|
{{{49}}}
|
{{{50}}}
|
|
{{{3}}}
{{{4}}}
{{{5}}}
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)