Your shopping cart is empty!
Measure Soil Moisture Sensor Using Raspberry Pi Pico And Maker Soil Moisture Sensor
- Hussien Jawhar Sathik
- 25 Jun 2022
- Tutorial
- 1992
Introduction
In this tutorial we shall see how to measure the soil moisture using Raspberry Pi Pico and Maker Soil Moisture sensor. To build this project is very straight forward as it does not require complicated interfacing. The data obtained is then is displayed on the RGB lcd. Moving forward, the data obtain can be used in IoT projects such as automated plant watering system, smart garden and so forth.
Video
Hardware Setup
This are the devices used in this tutorial
The connection between the devices are done as shown in the figure below
Coding
Below is the code in this tutorial
#include
#include
SerLCD lcd;
int soil_moisture = A0;
void setup() {
Wire.begin();
Serial.begin(9600);
lcd.begin(Wire);
//By default .begin() will set I2C SCL to Standard Speed mode of 100kHz
Wire.setClock(400000); //Optional - set I2C SCL to High Speed Mode of 400kHz
lcd.setBacklight(0, 0, 0);
lcd.clear();
lcd.print(" RPi Pico Soil ");
lcd.setCursor(1,1);
lcd.print(" Moisture Sensor");
delay(3000);
}
void loop() {
int sensor_value = analogRead(soil_moisture);
delay(1000);
Serial.println(sensor_value);
if(sensor_value > 950){
lcd.setBacklight(255, 0, 0); //bright red
lcd.clear();
lcd.print("Soil is dry");
delay(3000);}
if(sensor_value < 950 && sensor_value > 800){
lcd.setBacklight(0, 255, 0); //bright green
lcd.clear();
lcd.print("Soil is Moist");
delay(3000);}
if(sensor_value < 800){
lcd.setBacklight(0, 0, 255); //bright blue
lcd.clear();
lcd.print("Soil is Wet");
delay(3000);}
}
Resources
Thank You
Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.
"Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for a better application."