Skip to content

4.1.7 Smart Environment Policy Tool

Overview

Build and prototype a smart environment policy tool using the Raspberry Pi Pico 2 W and MicroPython.

This expert project is designed as an open-ended research and prototype challenge. Learners should use the concept, suggested components, and starter code as a guide, then conduct further research, improve the design, and build a working prototype.

The final result should demonstrate a working embedded system prototype with clear documentation, testing evidence, and a short presentation of design decisions.

Required Components

Pico 2 W
Raspberry Pi Pico 2 W
Gas Sensor
Air-quality sensor
Water Level Sensor
Water-quality sensor
Gas Sensor
Carbon-emission sensor
Breadboard
Breadboard
Jumper Wires
Jumper wires

Component Image
Raspberry Pi Pico 2 W
Air Quality Sensor
Water Quality Sensor
Carbon Emission Sensor
Breadboard
Jumper Wires

Circuit Connections

Component Pin Connects To Pico GPIO / Physical Pin Number Notes
Sensor Power 3.3V Physical Pin 36 Use 3.3V-compatible modules
Sensor GND GND Physical Pin 38 Use a common ground for low-voltage modules
Signal Pins Selected GPIO Pins As defined in your design Document your selected pin numbers
Actuators Driver/Relay Module GPIO control pin Do not power actuators directly from GPIO

Step-by-Step Assembly

Hardware Setup

Step 1: Plan the System Architecture

Identify the required sensors, actuators, communication interfaces, and system layers before wiring the hardware.


Step 2: Connect the First Input Sensor

Wire one sensor to the Raspberry Pi Pico 2 W and verify that it produces valid readings before adding additional components.


Step 3: Add Output or Actuator Modules

Connect relays, drivers, or other output devices one at a time, testing each module after installation.


Step 4: Verify the Circuit

Confirm that:

  • All sensors are connected correctly.
  • 3.3V power is supplied where required.
  • Ground connections are common across modules.
  • GPIO pin assignments are documented.
  • External loads are connected through a relay or driver module rather than directly to the Pico GPIO.

Step 5: Final Documentation

Record the final circuit layout, GPIO assignments, hardware modifications, and any design improvements made during testing.


Testing Individual Components

Before running the full project, test each subsystem separately. This makes it easier to find wiring, code, or logic problems.

  • Test each sensor reading in the Thonny Shell.
  • Test each actuator using a safe low-power test.
  • Verify communication between system layers.
  • Record results and adjust the prototype before final integration.

Full Project Code

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

Starter Code


# Starter code placeholder

from machine import Pin
import time

print("Expert project ready")

while True:
    # Add your system logic here
    time.sleep(1)

How the Code Works

Code Section What It Does Why It Matters
Pin Setup Creates input and output objects The Pico needs to know how each GPIO pin will be used
Main Loop Runs the system repeatedly Embedded systems usually monitor and respond continuously

Expected Result

The system should collect data, process it, control the required outputs, and show clear evidence that the prototype solves the intended problem.


Troubleshooting

Problem Possible Cause Solution
No readings appear in Thonny Incorrect wiring, wrong pins, or missing library Recheck the circuit, confirm pin numbers, and test each module separately
Import error appears Library file is missing or saved in the wrong location Check the Pico file structure and save libraries exactly as instructed
Actuator does not respond Relay/driver wiring or external power issue Verify driver input, external power, and shared ground where required
Results are unstable Sensor noise, loose wiring, or poor calibration Secure the wiring and add calibration or averaging in code
Prototype works only sometimes System is too complex to test all at once Return to subsystem testing and integrate one part at a time