Project 2.3.6: Bluetooth Room Monitor
Intermediate Embedded Systems Project Using Raspberry Pi Pico 2 W and MicroPython
Overview
This project builds a BLE room monitor that reads temperature and humidity from a BME280 sensor and classifies the room condition.
The Pico uses threshold logic to decide whether the room is too cold, too hot, too humid, or comfortable.
A similar system could support classroom comfort checks, server room monitoring, or basic greenhouse observation.
Required Components
![]() BME280 sensor module |
![]() Raspberry Pi Pico 2 W |
![]() Breadboard |
![]() Jumper wires |
Phone with BLUETOOTH app |
Circuit Connections
| Component terminal | Connect to | Pico physical pin | Notes |
|---|---|---|---|
| BME280 VCC | 3.3V | Physical pin 36 | Sensor power |
| BME280 GND | GND | Physical pin 38 | Common ground |
| BME280 SDA | GPIO 8 | GPIO 8 / physical pin 11 | I2C0 SDA |
| BME280 SCL | GPIO 9 | GPIO 9 / physical pin 12 | I2C0 SCL |
Wiring Diagram

Raspberry Pi Pico 2 W
┌─────────────────────┐
│ │
│ GPIO 8 ───────────┤──── BME280 SDA
│ GPIO 9 ───────────┤──── BME280 SCL
│ │
│ 3.3V ───────────┤──── BME280 VCC
│ GND ───────────┤──── BME280 GND
│ │
└─────────────────────┘
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 BME280 Sensor
Place the BME280 module on the breadboard or hold it beside the breadboard with jumper wires. Check the printed labels and identify VCC, GND, SDA, and SCL before wiring.
Step 3: Connect BME280 VCC
Connect BME280 VCC to 3.3V.
Step 4: Connect BME280 GND
Connect BME280 GND to GND.
Step 5: Connect SDA to GPIO 8
Connect BME280 SDA to GPIO 8.
Step 6: Connect SCL to GPIO 9
Connect BME280 SCL to GPIO 9.
Step 7: Check the I2C Bus
Make sure SDA and SCL are not crossed before powering the Pico.
Wiring Check
- [x] Pico 2W is placed correctly across the breadboard center gap
- [x] BME280 VCC connects to 3.3V
- [x] BME280 GND connects to GND
- [x] BME280 SDA connects to GPIO 8
- [x] BME280 SCL connects to GPIO 9
- [x] No loose jumper wires
Intermediate Note This project uses BLE on the Raspberry Pi Pico 2W. Use a BLE app such as nRF Connect, LightBlue, or a BLE UART terminal to connect to
AIDER_RoomMonitorand send commands. If readings do not appear, run an I2C scanner and confirm the BME280 address before running the full monitor code.
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 I2C sensor wiring and check the pin labels twice
- Power the board and make sure the BME280 stays cool and stable
Test the Input Sensor
- Run
i2c.scan()to confirm the sensor is visible on the bus - Run a short BME280 script and make sure the temperature and humidity values look realistic for the room
Test the Output Data
- Upload the final code and watch the Shell messages first
- Confirm that the room state changes when you temporarily lower or raise the thresholds for testing
Test Communication
- Connect to
AIDER_RoomMonitorfrom the BLE app - Send
status,cold 19,hot 27, orhum 65to confirm the threshold commands are accepted
Run the Full System
- Leave the monitor running for a few minutes
- Watch for any state-change message and compare it with the actual room conditions
- Return the limits to sensible values after the classroom test
Save the Project
- Save the working code on your computer
- Record the threshold values you decided were comfortable for your test room
Additional Testing and Calibration Checks
Calibration and tuning notes
- Compare the BME280 temperature reading with how the room feels or with another thermometer if available
- Temporarily narrow the hot or cold limits for testing, then return them to sensible values
- Remember that comfort thresholds may differ between a classroom, greenhouse, and equipment room
Quick testing checklist
- [ ] BME280 is detected on the I2C bus
- [ ]
AIDER_RoomMonitorappears in the BLE app - [ ]
statusshows temperature, humidity, and pressure - [ ] Changing limits changes the room-state decision
- [ ] State-change messages appear when expected
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 I2C, Pin
import bluetooth
import time
import BME280
from ble_uart import BLEUART
DEVICE_NAME = "AIDER_RoomMonitor"
i2c = I2C(0, sda=Pin(8), scl=Pin(9), freq=100000)
bme = BME280.BME280(i2c=i2c)
ble = bluetooth.BLE()
ble.active(True)
uart = BLEUART(ble, name=DEVICE_NAME)
cold_limit = 20.0
hot_limit = 28.0
high_humidity_limit = 70.0
last_state = ""
command_queue = []
def send_line(message):
print(message)
uart.write((message + "\n").encode())
def on_rx(data):
command = data.decode("utf-8").strip().lower()
if command:
command_queue.append(command)
def first_number(text):
digits = ""
for char in text:
if char in "-0123456789.":
digits += char
elif digits:
break
return float(digits)
def room_state(temp_c, humidity_pct):
if temp_c < cold_limit:
return "TOO COLD"
if temp_c > hot_limit:
return "TOO HOT"
if humidity_pct > high_humidity_limit:
return "TOO HUMID"
return "COMFORTABLE"
def current_report():
temp_text = bme.temperature
humidity_text = bme.humidity
pressure_text = bme.pressure
temp_c = first_number(temp_text)
humidity_pct = first_number(humidity_text)
state = room_state(temp_c, humidity_pct)
return temp_text, humidity_text, pressure_text, state
uart.on_rx(on_rx)
send_line("Bluetooth room monitor ready")
while True:
temp_text, humidity_text, pressure_text, state = current_report()
if state != last_state:
send_line("Room state changed: {}".format(state))
last_state = state
if command_queue:
command = command_queue.pop(0)
if command in ("status", "read"):
send_line("Temp:{} Hum:{} Press:{}".format(temp_text, humidity_text, pressure_text))
send_line("State:{}".format(state))
elif command.startswith("cold "):
cold_limit = float(command.split()[1])
send_line("Cold limit set to {}C".format(cold_limit))
elif command.startswith("hot "):
hot_limit = float(command.split()[1])
send_line("Hot limit set to {}C".format(hot_limit))
elif command.startswith("hum "):
high_humidity_limit = float(command.split()[1])
send_line("Humidity limit set to {}%".format(high_humidity_limit))
elif command == "help":
send_line("Commands: status, read, cold <value>, hot <value>, hum <value>, help")
else:
send_line("Unknown command. Send help.")
time.sleep_ms(500)
How the Code Works
| Code Section | What It Does | Why It Matters |
|---|---|---|
| BME280 reading block | Collects temperature, humidity, and pressure text from the sensor | Provides the room data for every decision |
room_state() |
Classifies the room as too cold, too hot, too humid, or comfortable | Turns numbers into an engineering decision |
| State-change check | Sends a message only when the room condition changes | Makes the monitoring output easier to follow |
| Threshold commands | Let the user tune cold, hot, and humidity limits over BLE | Supports calibration for different rooms or climates |
Expected Result
The BLE app can request room readings and adjust comfort limits. When the room condition changes, the Pico sends an updated state such as TOO HOT or COMFORTABLE.
Troubleshooting
| Problem | Possible cause | Solution |
|---|---|---|
| Readings are missing | BME280 wiring or library file is incorrect | Check GPIO 8, GPIO 9, 3.3V, GND, and confirm BME280.py is on the Pico |
| Room state looks wrong | The threshold values are unrealistic for the test room | Review the cold, hot, and humidity limits and tune them again |
| No state-change messages appear | The room never crossed a threshold or the limits are too wide | Temporarily tighten the limits to verify the change-detection logic |
| Phone cannot find the BLE device | The Pico is not advertising or the BLE helper files are missing | Confirm ble_uart.py and ble_advertising.py are saved on the Pico, restart the board, and scan again from nRF Connect or LightBlue |
| Commands do not change the system state | The phone is connected to the wrong service or the command text is different from the expected command | Reconnect to the BLE UART service and send the exact command shown in the test section |



