Build a Smart Home Sensor Using Raspberry Pi Pico 2 W and Bluetooth

In today's world, smart homes are no longer a luxury — they’re a DIY reality. Whether it's turning lights on from your phone or checking room temperature while you're away, automation has never been more accessible.

And with the Raspberry Pi Pico 2 W, building smart home devices is easier than ever. In this tutorial, we’ll walk you through creating a Bluetooth-enabled home sensor using this compact yet powerful microcontroller.

Let’s get started!


Why Use Raspberry Pi Pico 2 W for Smart Home Projects?

The Raspberry Pi Pico 2 W is the latest upgrade in the Pico lineup. What makes it stand out?

  • Built-in Bluetooth 5.2 and Wi-Fi

  • Low power consumption – ideal for always-on smart sensors

  • Dual-core Arm Cortex-M0+ processor

  • Affordable and beginner-friendly

This board is perfect for home automation projects that need wireless communication, and today, we'll focus on using Bluetooth 5.2.


What Are We Building?

basic smart temperature and humidity sensor

We’re going to build a basic smart temperature and humidity sensor that communicates with your smartphone via Bluetooth. You’ll be able to read real-time room data using a mobile app.

Core Functions:

  • Collect room temperature & humidity

  • Transmit data over Bluetooth

  • View live data on your smartphone

What You’ll Need:

Before diving in, let’s gather the components.

Hardware:

  • Raspberry Pi Pico 2 W

  • DHT11 or DHT22 Temperature & Humidity Sensor

  • Breadboard & jumper wires

  • USB cable (for programming the Pico)

  • A smartphone with a Bluetooth terminal app (e.g. Serial Bluetooth Terminal for Android)

Software:

  • Thonny IDE (Python environment)

  • MicroPython firmware for Pico

  • Bluetooth library (ubluetooth)

Step 1: Setting Up the Raspberry Pi Pico 2 W

Raspberry Pi Pico 2 W

1. Download & install Thonny IDE on your computer: https://thonny.org

2. Flash MicroPython firmware on Pico 2 W:

  • Connect the Pico while holding the BOOTSEL button.

  • It will appear as a storage device.

  • Download the latest MicroPython UF2 file from: https://micropython.org/download/rp2-pico-w

  • Drag the file into the Pico drive. It will reboot with MicroPython ready.

Step 2: Connect the DHT Sensor to Pico

Wire as follows:

DHT Pin

Connects To

VCC

3.3V (Pico)

GND

GND (Pico)

DATA

GP15

Use jumper wires and a breadboard to make the setup neat.


Step 3: Writing the Code

Here’s a simple Python script to:

  • Read temperature & humidity

  • Send data over Bluetooth

import machine

import time

import dht

import bluetooth

from machine import Pin

from bluetooth import BLE


sensor = dht.DHT22(Pin(15))

ble = bluetooth.BLE()

ble.active(True)


def send_data(data):

    if ble.is_connected():

        ble.gatts_notify(0, 0, data)


def advertise():

    ble.gap_advertise(100, b'\x02\x01\x06\x03\x03\xE0\xFF')


def on_connect(bt):

    print("Bluetooth connected")

    while True:

        sensor.measure()

        temp = sensor.temperature()

        hum = sensor.humidity()

        data = f"Temp: {temp}°C | Hum: {hum}%"

        print(data)

        send_data(data.encode())

        time.sleep(5)


advertise()

ble.irq(handler=lambda e: on_connect(ble))


Note: You may need to adjust for BLE GATT setup based on your device. You can use external libraries for more advanced features like notifications or pairing.


Step 4: Test With a Bluetooth App

  • Download Serial Bluetooth Terminal (Android) or a similar app for iOS.

  • Turn on Bluetooth and scan for your Pico device.

  • Once connected, you’ll start seeing real-time data in the app.

Step 5: Improve the Build (Optional)

Here are some ways to expand your smart sensor:

  • Add an OLED display to show readings on the device itself

  • Power your project using a battery + charging module (like TP4056)

  • Integrate multiple sensors (like motion or light sensors)

  • Send data to cloud via Wi-Fi (using MQTT)

Troubleshooting Tips

Pico not showing up?

Check your USB cable. Some are power-only, not data-capable.

Can’t connect Bluetooth?

Ensure your mobile Bluetooth supports BLE (Bluetooth Low Energy).

Sensor returns 0 values?

Double-check wiring and make sure the sensor has time to stabilize.


Why Bluetooth 5.2?

The Raspberry Pi Pico 2 W comes with Bluetooth 5.2, which offers:

  • Lower power consumption (great for battery-powered devices)

  • Improved data rate and range

  • Compatibility with most new smartphones and IoT devices

Unlike Wi-Fi, Bluetooth is ideal when you need close-range communication without the complexity of internet connectivity.

 

Final Thoughts

Building a smart sensor with Raspberry Pi Pico 2 W and Bluetooth is a rewarding first step into home automation. It's affordable, beginner-friendly, and highly customizable.

This project introduces you to:

  • Using MicroPython for IoT

  • Communicating over Bluetooth 5.2

  • Reading data from sensors in real-time

With just a few components and some code, you’ve created your very own smart home sensor.

Ready To Build More?

You can use the same foundation to create:

  • Smart door/window alerts

  • Motion detectors

  • Air quality monitors

  • Light automation systems

The world of DIY home automation is yours to explore!

Raspberry pi australiaRaspberry pi pico 2 w

Leave a comment

All comments are moderated before being published