Skip to content

Project 2.6.8: Smart Fertilizer Reminder

Intermediate Embedded Systems Project Using Raspberry Pi Pico 2 W and MicroPython


Overview

This project builds a timed reminder system for fertilizer or crop-maintenance tasks instead of a sensor-driven automation system.

Students will build a visual and audio reminder with a reset button, a due-state indicator, and a test mode that makes the timing easy to validate in class.

The final system should count down to the next reminder, switch to a due state when the interval expires, and reset the timer only when the student presses the acknowledgment button after the task is done.

Required Components

Green LED and 220 Ω resistor
Green LED and 220 Ω resistor
Breadboard and jumper wires
Breadboard and jumper wires
Raspberry Pi Pico 2 W
Raspberry Pi Pico 2 W
Red LED and 220 Ω resistor
Red LED and 220 Ω resistor
Buzzer
Buzzer
Push button
Push button

Circuit Connections

Component terminal Connect to Pico physical pin Notes
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 Due-state indicator
Buzzer positive GPIO 18 GPIO 18 / physical pin 24 Short chirps when due
Reset button one side GPIO 21 GPIO 21 / physical pin 27 Uses internal pull-up
Reset button other side GND Any GND pin Button active-low path

Wiring Diagram

Circuit Diagram

  Raspberry Pi Pico 2 W
  ┌─────────────────────┐
  │                     │
  │  GPIO 16 ────220Ω───┤──── Green LED (+)
  │                     │
  │  GPIO 17 ────220Ω───┤──── Red LED (+)
  │                     │
  │  GPIO 18 ───────────┤──── Buzzer (+)
  │                     │
  │  GPIO 21 ───────────┤──── Push Button ──── GND
  │                     │
  │  GND     ───────────┤──── Green LED (-)
  │  GND     ───────────┤──── Red LED (-)
  │  GND     ───────────┤──── Buzzer (-)
  │                     │
  └─────────────────────┘

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: Place the Green LED

Place the green LED on the breadboard. Identify the long leg as the anode (+) and the short leg as the cathode (-).

Step 3: 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 4: Place the Red LED

Place the red LED on the breadboard. Identify the long leg as the anode (+) and the short leg as the cathode (-).

Step 5: 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 6: Place 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.

Step 7: Place the Reset Button

Place the push button across the breadboard center gap. This keeps each side of the button on separate breadboard rows.

Step 8: Connect the Reset Button

Connect one side of the push button to GPIO 21. Connect the opposite side of the push button to GND. The code uses the Pico internal pull-up, so the button reads LOW when pressed.

Wiring Check

  • [x] Pico 2W is placed correctly across the breadboard center gap
  • [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] Push button sits across the breadboard center gap
  • [x] One button side connects to GPIO 21
  • [x] Opposite button side connects to GND
  • [x] No loose jumper wires

Intermediate Note Use the classroom test interval first so the reminder can be observed quickly. After testing, set a realistic reminder interval before using the project as a schedule demo.


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 LEDs and button first because they are easy to test safely
  • Keep the button wiring short so the active-low input remains stable

Test the Input Sensor

  • Test the reset button in a short script and confirm that pressing it changes the GPIO state

Test the Output Device

  • Test both LEDs and the buzzer separately before running the full reminder logic
  • Confirm that the buzzer only sounds briefly instead of staying on continuously

Run the Full System

  • Use TEST_MODE first so the reminder becomes due within a short classroom period
  • Wait for the red LED and buzzer chirp, then press the reset button and confirm that the timer restarts

Save the Project

  • Save the final code and record whether TEST_MODE is enabled or disabled
  • Choose a realistic final interval before using the project outside class

Additional Testing and Calibration Checks

Calibration and tuning notes

  • Keep TEST_MODE enabled until you have verified that the reminder and reset cycle works correctly
  • Do not judge the full-day interval behaviour from a classroom session; use the short test mode first
  • If the reminder seems to reset by itself, check the button wiring for a loose ground connection
  • If the buzzer becomes annoying, lengthen CHIRP_INTERVAL_S rather than removing the alert entirely

Quick testing checklist

  • [ ] Green LED shows the not-due state
  • [ ] Red LED shows the due state
  • [ ] Buzzer chirps when the reminder is due
  • [ ] Reset button restarts the timer
  • [ ] TEST_MODE makes the full workflow easy to observe in class

Full Project Code

After completing and checking the circuit connections, open Thonny IDE. Copy and paste the code below into a new file, or upload the project file to the Raspberry Pi Pico 2 W, then run it from Thonny.

from machine import Pin
import time

TEST_MODE = True

REMINDER_DAYS = 7
REMINDER_INTERVAL_S = 30 if TEST_MODE else REMINDER_DAYS * 24 * 60 * 60
CHIRP_INTERVAL_S = 10

green_led = Pin(16, Pin.OUT)
red_led = Pin(17, Pin.OUT)
buzzer = Pin(18, Pin.OUT)
reset_button = Pin(21, Pin.IN, Pin.PULL_UP)

last_done = time.time()
last_chirp = time.time() - CHIRP_INTERVAL_S

green_led.off()
red_led.off()
buzzer.off()


def chirp():
    buzzer.on()
    time.sleep(0.15)
    buzzer.off()


def reset_reminder():
    global last_done
    last_done = time.time()
    print("Reminder reset after fertilizer task")


print("Smart fertilizer reminder ready")

while True:
    now = time.time()
    elapsed = now - last_done
    remaining = REMINDER_INTERVAL_S - elapsed
    due = remaining <= 0

    if due:
        green_led.off()
        red_led.on()
        print("Reminder due now")
        if now - last_chirp >= CHIRP_INTERVAL_S:
            chirp()
            last_chirp = now
    else:
        green_led.on()
        red_led.off()
        print("Next reminder in {} seconds".format(int(remaining)))

    if reset_button.value() == 0:
        reset_reminder()
        while reset_button.value() == 0:
            time.sleep(0.05)

    time.sleep(1)

How the Code Works

Code Section What It Does Why It Matters
TEST_MODE and REMINDER_INTERVAL_S Switch between classroom timing and real-use timing Long real intervals are hard to validate without a short test mode
reset_button Acknowledges task completion A reminder is only useful if the user can reset it intentionally
due logic Determines whether the interval has expired This separates the NORMAL and DUE states
CHIRP_INTERVAL_S Limits how often the buzzer sounds Frequent alarms are distracting and less useful

Expected Result

During the countdown, the green LED should stay on. When the interval expires, the red LED should turn on and the buzzer should chirp at spaced intervals. Pressing the reset button after the reminder is due should restart the timer and return the system to the normal state.


Troubleshooting

Problem Possible cause Solution
The reminder never becomes due TEST_MODE is off or the interval is too long Enable TEST_MODE or shorten the reminder interval for testing
The reminder resets by itself The button input is floating or wired incorrectly Check that the button goes cleanly from GPIO 21 to GND only when pressed
The buzzer sounds constantly The chirp spacing is missing or the loop is too fast Confirm CHIRP_INTERVAL_S logic and keep the main loop delay in place
The wrong LED stays on LED pins or polarity are mixed up Recheck the LED wiring and the GPIO assignments in the code