Skip to content

Project 1.12.21

Bluetooth Weather Display

Project 1.12.21: Bluetooth Weather Display

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

Overview

Build a Bluetooth weather display that sends temperature, humidity, and pressure readings to your phone.

This project demonstrates how one digital sensor can act like a simple wireless weather station.

The final result should let a phone request the current weather readings and view them in the BLE app.

Required Components

Pico 2 W
Raspberry Pi Pico 2 W
BME280_Sensor
BME280 Sensor Module
Breadboard
Breadboard
Jumper Wires
Jumper Wires
BLE App
Phone with BLE App

Circuit Connections

Component Pin Connects To Pico GPIO / Physical Pin Number Notes
BME280 VIN / VCC 3.3V Physical Pin 36 Use 3.3V
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

Step-by-Step Assembly

Step 1: Place the Raspberry Pi Pico 2 W

Place the Raspberry Pi Pico 2 W 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.

Pico Placement


Step 2: Place the BME280 Module

Place the BME280 module on the breadboard.

Identify:

  • VIN / VCC
  • GND
  • SDA
  • SCL

before wiring.

Check the printed labels because module pin order may vary.

BME280 Placement


Step 3: Connect BME280 Power

Connect:

  • BME280 VIN / VCC -> 3.3V
  • BME280 GND -> GND

Power Wiring


Step 4: Connect BME280 I2C Pins

Connect:

  • BME280 SDA -> GPIO 8
  • BME280 SCL -> GPIO 9

I2C Wiring


Wiring Check

    • Pico 2W is placed correctly across the breadboard center gap
    • BME280 VIN / VCC connects to 3.3V
    • BME280 GND connects to GND
    • BME280 SDA connects to GPIO 8
    • BME280 SCL connects to GPIO 9
    • No loose jumper wires

Safety Note

Avoid touching the sensor with wet hands during testing.


Testing Individual Components

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

I2C Scanner Test

Check that the Pico can detect the BME280 on the I2C bus.

from machine import Pin, I2C

i2c = I2C(0, sda=Pin(8), scl=Pin(9), freq=100000)

print('I2C devices:', i2c.scan())

Expected Test Result

The Shell should print at least one I2C address, often 118 or 119 for a BME280 module.


BME280 Weather Test

Check that temperature, humidity, and pressure can be read before adding Bluetooth code.

from machine import Pin, I2C
import time
import BME280

i2c = I2C(0, sda=Pin(8), scl=Pin(9), freq=100000)

bme = BME280.BME280(i2c=i2c)

while True:
    print('Temp:', bme.temperature,
          'Humidity:', bme.humidity,
          'Pressure:', bme.pressure)
    time.sleep(1)

Expected Test Result

The Shell should print weather values that update over time.


BLE Advertising Test

Check that the Pico advertises as a BLE device your phone can see.

import bluetooth
import time
from ble_uart import BLEUART

ble = bluetooth.BLE()
ble.active(True)

uart = BLEUART(ble, name='Pico-Weather')

print('Scan for Pico-Weather in your BLE app')

while True:
    time.sleep(1)

Expected Test Result

Your phone BLE app should find a device named Pico-Weather.


Full Project Code

from machine import Pin, I2C
import bluetooth
import time
import BME280
from ble_uart import BLEUART

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='Pico-Weather')


def send_weather():
    uart.write(('Temperature: {}\n'.format(bme.temperature)).encode())
    uart.write(('Humidity: {}\n'.format(bme.humidity)).encode())
    uart.write(('Pressure: {}\n'.format(bme.pressure)).encode())


def on_rx(data):
    command = data.decode('utf-8').strip().lower()
    print('Received command:', command)

    if command in ('read', 'status', 'weather'):
        send_weather()

    elif command == 'help':
        uart.write(b'Commands: read, status, weather, help\n')

    else:
        uart.write(b'Unknown command. Send help.\n')


uart.on_rx(on_rx)

print('Bluetooth weather display ready')
print('Send read, status, weather, or help from the BLE app')

while True:
    time.sleep(1)

How the Code Works

Code Section What It Does Why It Matters
I2C sensor setup Starts the BME280 sensor on the I2C bus The correct pins and driver are needed for weather readings
send_weather() Builds and sends the current sensor readings The phone receives a simple weather report
Bluetooth command handler Waits for read or status requests from the phone Avoids sending repeated data all the time
Main loop Keeps the Bluetooth project running The Pico stays ready for the next request

Expected Result

After running the code, your phone BLE app should find Pico-Weather.

Sending:

  • read
  • status
  • weather

should return the current:

  • Temperature
  • Humidity
  • Pressure

readings from the BME280 sensor.


Troubleshooting

Problem Possible Cause Solution
No I2C device is found SDA and SCL are reversed or the BME280 is not powered Check GPIO 8, GPIO 9, 3.3V, and GND wiring
Import error for BME280 The BME280.py file is missing from the Pico Save BME280.py to the Pico root folder and try again
Phone cannot find Pico-Weather BLE helper files are missing or Bluetooth is not active Verify helper files are installed and rerun the BLE advertising test