Bird
0
0
Arduinoprogramming~30 mins

Soil moisture sensor in Arduino - Mini Project: Build & Apply

Choose your learning style9 modes available
Soil moisture sensor
📖 Scenario: You want to monitor the moisture level of your garden soil using an Arduino and a soil moisture sensor. This helps you know when to water your plants.
🎯 Goal: Build a simple Arduino program that reads the soil moisture sensor value and prints it to the Serial Monitor.
📋 What You'll Learn
Create a variable to store the analog pin number connected to the soil moisture sensor.
Create a variable to store the moisture sensor reading.
Read the sensor value from the analog pin.
Print the sensor value to the Serial Monitor.
💡 Why This Matters
🌍 Real World
Gardeners and farmers use soil moisture sensors to know when plants need watering, saving water and improving plant health.
💼 Career
Understanding sensor reading and Arduino programming is useful for jobs in electronics, IoT, and environmental monitoring.
Progress0 / 4 steps
1
Set up the sensor pin
Create an integer variable called sensorPin and set it to A0 to represent the analog pin connected to the soil moisture sensor.
Arduino
Hint

The soil moisture sensor is connected to analog pin A0. Use int sensorPin = A0; to store this.

2
Prepare to read sensor values
Create an integer variable called sensorValue to store the reading from the soil moisture sensor.
Arduino
Hint

You need a variable to hold the sensor reading. Initialize it to 0.

3
Read the sensor value
In the loop() function, read the analog value from sensorPin using analogRead() and store it in sensorValue.
Arduino
Hint

Use sensorValue = analogRead(sensorPin); inside the loop to get the sensor reading.

4
Print the sensor value
Use Serial.println(sensorValue); inside the loop() function to print the soil moisture sensor value to the Serial Monitor.
Arduino
Hint

Use Serial.println(sensorValue); to print the value. Add delay(1000); to wait 1 second between readings.