In this tutorial, we’ll be using a Raspberry Pi Pico With Moisture Sensor to monitor the moisture levels in your soil. This is a great project for anyone who wants to get started with monitoring their plants or garden, as it is a simple and cheap way to get started.
You’ll learn how to wire up the sensor, and write a micro_pyton program to read the sensor data.
First, you’ll need to gather your materials.
For this project, you’ll need a Raspberry Pi Pico, a moisture sensor, and some jumper wires. You can find all of these items at your local electronics store, or online.
In this tutorial, we’ll be setting up a Raspberry Pi Pico with a moisture sensor to detect when our plants require watering. This is a truly simple and quick project that’s excellent for anyone new to working with the Raspberry Pi Pico.
This moisture sensor can be used to measure the moisture content of the soil. By using this sensor, you can determine if your plants are getting enough water. Moisture sensors are used in a variety of applications, including weather monitoring, agricultural irrigation, and building moisture control.
Moisture Sensor Pinout
The sensor has four pins: power, ground, signal, and a fourth pin that is not used. Connect the power and ground pins to the 3.3V and GND pins on the Pico, respectively.
Circuit Diagram – Raspberry Pi Pico With Moisture Sensor
Next, you’ll need to connect your moisture sensor to the Raspberry Pi Pico. The sensor has three pins: power, ground, and signal. Connect the power and ground pins to the right power and ground pins on the Pico, and connect the DATA pin to the GPIO pin 26.
Once your Circuit is connected, open up the Thonny IDE and create a new file. We’ll be using MicroPython for this project, so make sure to save the file with a .py extension. Now it’s time to write some code!
from machine import ADC, Pin
# use variables instead of numbers:
soil = ADC(Pin(26)) # Connect Soil moisture sensor data to Raspberry pi pico GP26
readDelay = 0.1 # time between readings
moisture = (max_moisture-soil.read_u16())*100/(max_moisture-min_moisture)
# print values
print("moisture: " + "%.2f" % moisture +"% (adc: "+str(soil.read_u16())+")")
utime.sleep(readDelay) # set a delay between readings
With this project, you will be able to monitor the moisture content of the soil with your Pico.
It can help you to monitor the moisture range of your plants and assure that they are properly hydrated. This will help you to avoid over or under-watering your plants.