Arduino Soil Moisture Sensor with LED Bar Graph
Level 37 · Wet or Dry · 30 minutes
A soil meter: the probe reads backwards, and ten LEDs fill up as the plant gets its water.

Preview the project free; a course seat is required to run and submit. No hardware kit needed.
Your project challenge
Show how wet the soil is on the bar graph. Wire it up: - Soil sensor: VCC to 5V, GND to GND, AO to A0 - Bar graph: A1-A10 to D2-D11, C1-C10 to GND Dry soil reads 1000 and wet soil reads 300. Light 0 bars when dry, 10 when soaking.
Components you’ll use
- Arduino Uno
- Soil Moisture Sensor (YL-69 probe + LM393 board)
- LED Bar Graph (10 segments)
What you’ll build
A soil meter: ten LEDs that fill up as a plant’s soil gets wetter.
How it works
- The probe has two metal prongs. Water carries electricity between them.
- So this sensor reads backwards. Bone-dry soil reads
1000. Soaking-wet soil reads300. - Neither end is 0 or 1023. Those are the Arduino’s ends, not the sensor’s.
- The bar counts up as the soil gets wetter: 0 bars dry, 10 bars soaking.
The key idea
map() turns a scale round when you name its ends in that order.
map(reading, 1000, 300, 0, 10)
A reading of 650 is (650 − 1000) × 10 / (300 − 1000) = 5 bars.
⚠ Watch out
Copy Level 23’s map(reading, 0, 1023, 0, 10) and the bar shows how dry the soil is. It is fullest when the plant is thirstiest. Soaking-wet soil lights only 2 bars.
The interactive editor includes the wiring guide, code editor and simulation controls.