Project 2.6.29: Smart Seedling Monitoring Kit
Intermediate Embedded Systems Project Using Raspberry Pi Pico 2 W and MicroPython
Overview
This project builds a nursery monitor designed around the narrow temperature and moisture range that seedlings need during early growth.
Students will combine an analog soil sensor, a BME280 sensor module, LED indicators, and a buzzer alert into one early-warning system.
The final system should report live seedling conditions, flag soil that is too dry or too wet, and warn when the temperature moves outside the recommended band.
Required Components
![]() Soil moisture sensor |
![]() Buzzer |
![]() Raspberry Pi Pico 2 W |
![]() BME280 sensor module |
![]() Green LED and 220 Ω resistor |
![]() Red LED and 220 Ω resistor |
![]() Breadboard and jumper wires |
Circuit Connections
| Component terminal | Connect to | Pico physical pin | Notes |
|---|---|---|---|
| Soil sensor AOUT | GPIO 26 | GPIO 26 / physical pin 31 | ADC moisture input |
| Green LED anode | GPIO 16 through 220 Ω resistor | GPIO 16 / physical pin 21 | Normal-state indicator |
| Red LED anode | GPIO 17 through 220 Ω resistor | GPIO 17 / physical pin 22 | Alert indicator |
| Buzzer positive | GPIO 18 | GPIO 18 / physical pin 24 | Short warning chirps |
| All LED cathodes and buzzer negative | GND | Any GND pin | Common return path |
| BME280 VCC | 3.3V | Physical pin 36 | Sensor power |
| BME280 GND | GND | Any GND pin | Common ground |
| BME280 SDA | GPIO 2 | GPIO 2 / physical pin 4 | I2C data |
| BME280 SCL | GPIO 3 | GPIO 3 / physical pin 5 | I2C clock |
Wiring Diagram

Step-by-Step Assembly
Step 1: Place the Raspberry Pi Pico 2W
Place the Raspberry Pi Pico 2W on the breadboard so it sits across the center gap. Keep the USB port facing outward so you can easily connect it to your computer.
Step 2: Position the Soil Moisture Sensor
Place the soil moisture probe so the sensing end can enter the seedling soil sample. Check the module labels and identify VCC, GND, and AOUT / AO / Signal on the sensor module.
Step 3: Connect the Soil Sensor
Connect soil sensor VCC to 3.3V. Connect soil sensor GND to GND. Connect soil sensor AOUT, AO, or Signal to GPIO 26 (ADC0).
Step 4: Place the BME280 Temperature Sensor
Place the BME280 so its leads are easy to identify and do not touch each other. Identify VCC, GND, and SDA/SCL using the printed label or datasheet for your exact BME280 package.
Step 5: Connect the BME280
Connect BME280 VCC to 3.3V. Connect BME280 GND to GND. Connect BME280 SDA/SCL to GPIO 2 (SDA) and GPIO 3 (SCL).
Step 6: Place the Green and Red LEDs
Place the green LED and red LED on the breadboard. For each LED, identify the long leg as the anode (+) and the short leg as the cathode (-).
Step 7: Connect the Green LED
Connect the green LED long leg through a 220Ω resistor to GPIO 16. Connect the green LED short leg to GND.
Step 8: Connect the Red LED
Connect the red LED long leg through a 220Ω resistor to GPIO 17. Connect the red LED short leg to GND.
Step 9: Place and Connect the Buzzer
Place the buzzer on the breadboard and identify its positive (+) and negative (-) pins. Connect the buzzer positive pin to GPIO 18. Connect the buzzer negative pin to GND.
Wiring Check
- [x] Pico 2W is placed correctly across the breadboard center gap
- [x] Soil sensor AOUT / AO / Signal connects to GPIO 26
- [x] BME280 VCC connects to 3.3V
- [x] BME280 GND connects to GND
- [x] BME280 SDA connects to GPIO 2
- [x] BME280 SCL connects to GPIO 3
- [x] Green LED long leg connects through a 220Ω resistor to GPIO 16
- [x] Red LED long leg connects through a 220Ω resistor to GPIO 17
- [x] Both LED short legs connect to GND
- [x] Buzzer positive pin connects to GPIO 18
- [x] Buzzer negative pin connects to GND
- [x] No loose jumper wires
Intermediate Note
Test dry soil and wet soil before trusting the moisture percentage. Let the BME280 reading settle before judging a seedling temperature alert.
Safety Note
Do not pour water onto the Pico, breadboard, USB cable, BME280 leads, or jumper wires. Add water to the soil sample away from the electronics.
Testing Individual Components
Before running the full project, test each part separately. This makes it easier to find wiring, library, or code problems.
Hardware setup
- Build the soil and BME280 sensor wiring first, then add the LEDs and buzzer
- Keep the analog sensor wires short so the readings stay stable
Test the input sensors
- Record dry and wet soil readings so the moisture percentage is believable
- Run a short BME280 test and confirm the temperature is close to room temperature
Test the output devices
- Test the LEDs and buzzer separately before relying on the full alert logic
- Confirm that the red LED and buzzer respond only during alert conditions
Run the full system
- Place the soil sensor in the nursery sample and observe the live readings
- Create one issue at a time, such as drying the soil or warming the BME280 slightly, and confirm that the correct alert appears
Save the project
- Save the final code and record the moisture and temperature bands used in your test
- Note which condition caused the most alerts during your seedling trial
Full Project Code
from machine import ADC, I2C, Pin
import bme280
import time
i2c_bme = I2C(1, sda=Pin(2), scl=Pin(3), freq=400000)
bme = bme280.BME280(i2c=i2c_bme)
def number_from_bme(text_value):
cleaned = "".join(ch for ch in str(text_value) if ch.isdigit() or ch in ".-")
return float(cleaned)
def read_bme280():
temp_text, pressure_text, humidity_text = bme.values
return number_from_bme(temp_text), number_from_bme(humidity_text), number_from_bme(pressure_text)
soil = ADC(26)
green_led = Pin(16, Pin.OUT)
red_led = Pin(17, Pin.OUT)
buzzer = Pin(18, Pin.OUT)
soil_dry = 52000
soil_wet = 22000
moisture_min = 55
moisture_max = 80
temp_min = 20.0
temp_max = 30.0
alert_repeat_s = 20
last_alert = time.time() - alert_repeat_s
def clamp(value, low, high):
return max(low, min(high, value))
def soil_percent():
raw = soil.read_u16()
span = soil_dry - soil_wet
if span == 0:
return 0
percent = int(((soil_dry - raw) * 100) / span)
return clamp(percent, 0, 100)
def issues_for_seedlings(moisture, temp_c):
issues = []
if moisture < moisture_min:
issues.append("soil too dry")
if moisture > moisture_max:
issues.append("soil too wet")
if temp_c < temp_min:
issues.append("temperature too low")
if temp_c > temp_max:
issues.append("temperature too high")
return issues
def chirp():
buzzer.on()
time.sleep(0.15)
buzzer.off()
print("Smart seedling monitoring kit ready")
while True:
moisture = soil_percent()
temp_c, humidity_pct, pressure_hpa = read_bme280()
temp_c = round(temp_c, 1)
issues = issues_for_seedlings(moisture, temp_c)
now = time.time()
if issues:
green_led.off()
red_led.on()
print("Seedling alert:", ", ".join(issues))
if now - last_alert >= alert_repeat_s:
chirp()
last_alert = now
else:
green_led.on()
red_led.off()
print("Status OK | Moisture:{}% Temp:{}C Hum:{:.1f}%".format(moisture, temp_c, humidity_pct))
time.sleep(5)
How the Code Works
| Code Section | What It Does | Why It Matters |
|---|---|---|
soil_percent() |
Converts the raw soil reading into a calibrated percentage | Seedling watering decisions should not be based on raw ADC values |
read_bme280() |
Converts BME280 voltage into degrees Celsius | Students practice turning analog voltage into a physical measurement |
issues_for_seedlings() |
Checks the nursery conditions against the seedling-safe range | Seedlings need tighter limits than mature plants |
| Alert timing | Limits how often the buzzer chirps | A repeated warning should be noticeable without sounding constantly |
Expected Result
When the soil and temperature stay inside the seedling-safe band, the green LED should stay on and the Shell should report an OK state. If the soil becomes too dry, too wet, too cold, or too hot, the red LED should turn on and the buzzer should chirp at the configured interval.
Troubleshooting
| Problem | Possible cause | Solution |
|---|---|---|
| Temperature seems unrealistic | The BME280 is wired incorrectly or powered from the wrong voltage | Check the BME280 pinout and confirm it is powered from 3.3V |
| The red LED is always on | One threshold is too strict or the calibration is wrong | Compare the live readings with the set limits and recalibrate the soil sensor if needed |
| The buzzer never sounds | The buzzer wiring is wrong or the alert interval never expires | Test the buzzer separately and confirm the alert branch is being reached |
| Soil percentage does not change | The soil sensor is not connected to the correct ADC pin | Recheck GPIO 26 wiring and confirm the sensor output changes in dry and wet conditions |





