Using Bluetooth on the Raspberry Pico

Cartoon computer and Raspberry Pi Pico shout echo into a glowing cave with bold title Using Bluetooth On The Raspberry Pico.

Bluetooth on the Raspberry Pi Pico W opens the door to simple, wireless communication between your microcontroller and a PC, phone, or robot controller. It lets you transmit data without cables and is perfect for small robots, sensors and remote-control projects.

It’s important to know that Bluetooth actually comes in two flavours: classic Bluetooth and Bluetooth Low Energy (BLE). Classic Bluetooth is used for things like headphones and older serial modules, while BLE is designed for low-power, short bursts of data.

The Pico W supports BLE only, making it ideal for efficient, lightweight communication without draining your battery. In this tutorial, we’ll focus entirely on BLE and show you how to send and receive messages using the Pico’s built-in wireless capabilities.

In this tutorial we will allow you to enter in some text, which then gets sent to the Pico via Bluetooth and then echoed back via the command prompt.

Set up your PC

In order to get started you will need to follow this tutorial then configure python to install Bleak.

Bleak is a lightweight, cross-platform Python library that makes it easy to communicate with Bluetooth Low Energy (BLE) devices from your computer. It handles scanning, connecting, sending data and receiving notifications, all with simple, asynchronous Python code.

To install Bleak on your system, just open a terminal or command prompt and run pip install bleak, or py -m pip install bleak – depending upon your set-up, and you’ll have everything you need to start building BLE applications in Python.

Use Thonny to create the following code and save it to your PC in a file called pc_echo.py.

This is program will connect to the Raspberry Pico and allow transmission of a message to it.

Bluetooth Channels

In BLE communication, UUIDs act like unique identifiers that define the services and characteristics a device offers. They tell the connected device exactly where to send data and which characteristic to listen to for incoming messages. In this tutorial, these UUIDs are used to create a simple UART-style channel so the Pico and PC can reliably exchange text data.

The UUIDs in the example come from the Nordic UART Service (NUS). This is not part of the official Bluetooth SIG standard, but it has become a very common choice because it’s simple and widely supported. Libraries like MicroPython’s BLE examples and the Python Bleak library are already built to work with it. Developers can also define their own UUIDs if needed, but using the NUS set makes development much easier.

Here’s a quick reference for the UUIDs used:

UUIDPurpose
6E400001-B5A3-F393-E0A9-E50E24DCCA9EThe main UART service that links the TX and RX characteristics.
6E400003-B5A3-F393-E0A9-E50E24DCCA9ETX characteristic (Pico → PC). The PC subscribes to this for notifications.
6E400002-B5A3-F393-E0A9-E50E24DCCA9ERX characteristic (PC → Pico). The PC writes outgoing data here.

If you want to explore more services, characteristics and vendor-defined UUIDs, Nordic provides an excellent reference list here:
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/protocols/bt/services.html

You can read more about how Bluetooth operates in energy saving environments in the How does BLE Bluetooth work? article.

Setting Up The Pico

Create the following file and save it to the Raspberry Pic as main.py.

Then create the following file and save it to the Raspberry Pico as ble_uart.py.

The ble_uart.py file acts as a small helper library that hides all the low-level details of Bluetooth Low Energy communication on the Pico W. BLE is quite complex under the hood which involves services, characteristics, handles, advertising packets, connection events and more. Instead of making you deal with all of that, ble_uart.py wraps it into a simple, easy-to-use class called BLEUART.

This class sets up a UART-style BLE service, handles advertising, manages connections, and triggers a callback whenever data arrives from the PC. It also provides a .send() function so you can transmit data back. In short, ble_uart.py gives your Pico a clean, serial-like Bluetooth interface, letting you focus on sending and receiving messages without worrying about the BLE protocol details.

The main.py listens for anything the PC sends, prints it to the console, and then sends a reply straight back. It also prints status messages so you can see when the Pico is advertising or when a device connects. Put simply, main.py is the brain of your program that runs your logic and uses the Bluetooth helper to communicate with the outside world.

Testing

Once the files have been created and uploaded the code can be tested.

The Pico code can be started by clicking the green run button at the top of the editor (don’t forget to check the Pico is connected). In the console at the bottom of the screen the following text should be visible.

A heartbeat should be shown with a connected state of false. This shows that the Pico code is running, but hasn’t connected to the client yet.

Next, on the client run start running the client code by running the following:

The program should then run and look for the Pico. You should see the following:

The Thonny console should then show loop heartbeat, connected = True, demonstrating that the client has connected.

Going back to the console and typing "picos love bananas" into the prompt gives the following message.

In the console on Thonny you should see the following:

Main Topic

The Raspberry Pi Pico

Raspberry Pi Pico on a breadboard with sensors and jumper wires arranged neatly on a desk, ready for an electronics project.

Raspberry Pi Pico is an affordable, efficient microcontroller offering flexible GPIO, strong performance, and versatile hardware features for beginner electronics projects.

Other Tutorials in this Topic

Cartoon Raspberry Pi Pico on a breadboard with glowing LED and wires beside a computer screen showing the Thonny picozero plugin installation.

Getting Started With The Raspberry Pico

Getting started guide showing how to set up a Raspberry Pi Pico on a breadboard and install…

A cheerful orange octopus adjusts wires on a breadboard with a Raspberry Pi Pico, potentiometer, and glowing LED beneath the text Basic Input / Output On the Pico.

Basic Input and Output With The Raspberry Pi…

The article explains how a Raspberry Pi Pico uses a potentiometer to control LED brightness, demonstrating basic…

A cheerful cartoon duck turns a control dial beside a spinning motor while an oscilloscope displays a squarewave showing PWM motor control.

Pico Motor Control Using the L9110 Control Board

A tutorial showing how to control a motor using PWM modulation to varying the speed of a…

Small educational robot uses ultrasonic sensor to navigate obstacles like cones and boxes while moving through a bright indoor course

Getting Started with an Ultrasonic Sensor Module on…

Beginner guide explaining how an ultrasonic sensor module works with Raspberry Pi Pico to measure distance using…

Cartoon robot spins happily while IMU detects z-axis rotation with arrows screens and motion lines in colorful laboratory scene background

Using the MPU6050 Gyro With Raspberry Pi Pico

The article explains how the MPU6050 IMU measures motion and rotation and communicates with microcontrollers using the…

Cartoon LCD on breadboard shows Hello from Tinkimo heart while silly banana sparks and googly eyed hammer watch Pico project

Using an LCD with the Pico

Beginner friendly guide explains using an LCD with the Raspberry Pi Pico for wiring, control signals, and…

Raspberry Pi Pico on breadboard drives LCD showing Hello message surrounded by colourful wires LEDs creating playful beginner electronics scene

Controlling an ST7789 Display With a Raspberry Pi…

Beginner guide explains using an ST7789 LCD with a Raspberry Pi Pico to create simple colourful display…