Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Interfacing XBee Module with Raspberry Pi Pico & MicroPython
Raspberry Pi Raspberry Pi Pico Projects

Interfacing XBee Module with Raspberry Pi Pico & MicroPython

Mamtaz AlamBy Mamtaz AlamUpdated:February 2, 20259 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Interfacing XBee Module with Raspberry Pi Pico & MicroPython
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this guide, we will interface the XBee Module with a Raspberry Pi Pico and set up ZigBee communication using MicroPython Code to use it as a transmitter and receiver. Earlier we learned about Arduino ZigBee Communication.

ZigBee is a wireless communication protocol designed primarily for IoT (Internet of Things) applications, enabling smart devices to connect and communicate seamlessly in a mesh network. This mesh structure allows ZigBee devices to relay data through one another, extending the network’s range and improving reliability.

In this tutorial, we will:

  1. Introduce the XBee Module: Learn about the XBee module’s features, applications, and communication range.
  2. Set Up XCTU Software: Use XCTU to configure the XBee module as a transmitter or receiver.
  3. Connect XBee Modules to the Raspberry Pi Pico: Set up one Raspberry Pi Pico with an XBee module as a transmitter and another as a receiver.
  4. Write Sample MicroPython Code: Create code in MicroPython to send data wirelessly between the two Raspberry Pi Pico boards.
  5. Test the Wireless Communication: Verify successful data transmission between the transmitter and receiver over a certain distance.

By the end, you’ll have a fully functional setup for wireless ZigBee communication using the XBee Module and Raspberry Pi Pico.


Components Required

For interfacing the XBee Module with Raspberry Pi Pico, we need the following components.

S.N.Components NameQuantityPurchase Link
1Raspberry Pi Pico2Amazon | AliExpress
2XBee Module2Amazon | AliExpress
3Xbee Adapter2Amazon | AliExpress
4DHT11 Sensor1Amazon | AliExpress
5Connecting Wires10Amazon | AliExpress
6Breadboard2Amazon | AliExpress




XBee Module

XBee modules are popular wireless communication modules developed by Digi International, designed to make wireless networking easy for IoT and embedded applications.

This is Zigbee XBee Module S2C 802.15.4 2mW with Wire Antenna XB24CZ7WIT-004. The XBee 2mW Wire Antenna S2C, the latest in Series 2, offers easy point-to-multipoint device connectivity, providing cost-effective wireless solutions for electronic devices. They are interoperable with other ZigBee feature set devices, including devices from different vendors.

Key Features of XBee Modules

  1. Integrated, Wire Antenna
  2. Interoperable with other ZigBee-compliant devices
  3. Programmable versions with onboard microprocessors enable custom ZigBee application development
  4. Supports binding and multicasting for easy integration into a home automation platform
  5. Through-hole form factor enables flexible design
  6. 15 general-purpose I/O lines
  7. Industry-leading sleep current of sub 1 µA
  8. Firmware upgrades via UART, SPI, or over-the-air

XBee Module Pinout

The XBee module has 20 pins, each serving specific functions that support various I/O, communication, and control features.

Pin No. Name Direction Description
1 VCC – Power Supply
2 DOUT Output UART Data Out
3 DIN/CONFIG Input UART Data In
4 DO8 Output Digital Output 8
5 RESET Input Module Reset (reset pulse >= 200 ns)
6 PWM0/RSSI Output PWM Output 0 / Received Signal Strength Indicator
7 PWM1 Output PWM Output 1
8 Reserved – Do not connect
9 DTR/SLEEP_RQ/DI8 Input Sleep Control or Digital Input 8
10 GND – Ground
11 AD4/DIO4 Input / Output Analog Input 4 / Digital I/O 4
12 CTS/DIO7 Input / Output Clear-To-Send Flow Control or Digital I/O 7
13 ON/SLEEP Output Module Status Indicator, High = ON, Low = SLEEP
14 VREF Input Reference Voltage for ADC
15 ASSOCIATE/AD5/DIO5 Input / Output Association Indicator, Analog Input 5 or Digital I/O 5
16 RTS/AD6/DIO6 Input / Output Request-To-Send Flow Control, Analog Input 6 or Digital I/O 6
17 AD3/DIO3 Input / Output Analog Input 3 or Digital I/O 3
18 AD2/DIO2 Input / Output Analog Input 2 or Digital I/O 2
19 AD1/DIO1 Input / Output Analog Input 1 or Digital I/O 1
20 AD0/DIO0 Input / Output Analog Input 0 or Digital I/O 0




XBee USB Adapter Board

One disadvantage of the Zigbee module is its lack of breadboard compatibility; its pin mapping doesn’t align with typical breadboards. Additionally, most Zigbee modules operate within a voltage range of 2.0V to 3.6V, with 3.3V as the standard. This makes them incompatible with 5V microcontrollers or any microcontrollers with higher voltage digital pins.

XBee Adapter Board

To overcome this, a Zigbee Adapter is needed. A popular choice is the XBee USB Adapter, a UART communication board designed specifically for XBee connectivity. It provides a UART interface, USB interface, and includes onboard buttons and LEDs, making it a user-friendly option for both development and debugging.

Key Features of the XBee USB Adapter

  1. Compatibility with Microcontrollers: The adapter operates with 3.3V logic, making it compatible with 3.3V microcontrollers.
  2. USB Interface: Equipped with a USB port, the adapter enables direct communication with a computer, allowing configuration and testing using AT Commands.
  3. Testing and Debugging: The adapter includes buttons and LEDs that facilitate easy testing of XBee modules.

Using XBee Module with XBee Adapter Board

To use the Zigbee module, start by carefully inserting it into the adapter board, ensuring the correct alignment and orientation.

XBee Adapter Usage

The module should fit securely on top of the adapter, so double-check that the pins are properly aligned to avoid any connection issues.


Setting Up XBee Module using the X-CTU Software

Digi International provides a software tool known as X-CTU for configuring XBee in either operating mode or device function type. Using this tool, we can configure the device, test its performance, and upgrade its firmware.

Here we need first to download X-CTU software and go through a short overview of the X-CTU User Guide.

Follow these steps to configure two Zigbee modules—one as the coordinator and the other as the end device—using the X-CTU software.

Configure the Coordinator

  1. Connect the ZigBee Module: Plug the ZigBee module into your computer using a USB cable and note the COM port assigned to it.
  2. Open X-CTU Software: Launch the X-CTU software, then click on the Add Device option.
  3. Select COM Port: Choose the appropriate COM port for your connected ZigBee module and click Next. No additional settings need to be changed here, so click Finish to begin searching for the module.
  4. Add the Detected Device: When X-CTU detects your module, select it and click Add Selected Device. This will open the module’s configuration page.
  5. Update Firmware (if prompted): If X-CTU suggests a firmware update, proceed with the upgrade to ensure your module is using the latest version.
  6. Set Device as Coordinator:
    • Under Radio Settings, change the PAN ID to a unique identifier, like 10001. This ID must match on all devices in the network.
    • Scroll down and set the Device Role to Coordinator.
  7. Write Settings: Click on Write to save these changes to the module. Your coordinator is now configured.



Configure the End Device

  1. Connect the Second ZigBee Module: Insert the second ZigBee module into your computer, following the same process as above.
  2. Select COM Port: Once connected, choose the appropriate COM port in X-CTU, click Next, and then Finish to start device detection.
  3. Add the Detected Device: Once the device is found, select it and add it to the software. If a firmware update is prompted, proceed to update.
  4. Set Device as End Device:
    • In Radio Settings, set the PAN ID to match the one set on the coordinator (e.g., 10001).
    • Scroll down and set the Device Role to End Device instead of Coordinator.
  5. Write Settings: Click Write to save these settings to the module. Your end device is now configured.

Once these steps are completed, your ZigBee modules are set up, with one as a coordinator and the other as an end device, and are ready for communication.


Interfacing XBee Module with Raspberry Pi Pico

Lets setup the hardware by interfacing XBee Module with Raspberry Pi Pico. First we will establish the hardware connection between Raspberry Pi Pico & XBee module so that we can establish ZigBee Communication.

We need to setup the two pieces of hardware here. One for the transmitter (end device) and the other one for the receiver (coordinator).

Transmitter Circuit (End Device)

On the transmitter circuit, connect the XBee Module & DHT11 Humidity Temperature Sensor to the Raspberry Pi Pico Board as shown in the image below.

XBee Module Raspberry Pi Pico Transmitter Circuit
Fig: Transmitter Circuit (End Device)

Connect the XBee Module Adapter VCC & GND Pin to 5V & GND Pin of the Pico. For the TX & Rx part of XBee Module Adapter, we will use the UART0 Pin of the Pico. For the DHT Sensor, connect its digital pin to GP15 of Raspberry Pi Pico.

XBee Pico Transmitter Circuit
Fig: Breadboard Assembly of the Transmitter Circuit

You may use the breadboard and jumper wire to assemble and connect the hardware as per the circuit diagram.



Receiver Circuit (Coordinator)

On the receiver circuit, connect only the XBee Module to the Raspberry Pi Pico Board as shown in the image below.

XBee Module Raspberry Pi Pico Receiver Circuit
Fig: Receiver Circuit (Coordinator)

Connect the XBee Module Adapter’s VCC and GND pins to the 5V and GND pins on the Raspberry Pi Pico. For data communication, connect the XBee Module Adapter’s TX and RX pins to the Raspberry Pi Pico’s UART0 pins (TX to RX and RX to TX).

XBee Pico Receiver Circuit
Fig: Breadboard Assembly of the Receiver Circuit

That’s all from the hardware connection part. Now lets move to the coding part.


MicroPython Code for Raspberry Pi Pico ZigBee Communication

To establish the ZigBee Communication between Raspberry Pi Pico & XBee module, we need to write MicroPython Code for both transmitter & receiver.

Transmitter Code (End Device)

The sender code initializes a DHT11 sensor to measure temperature and humidity, formats the readings into a structured message (e.g., <T:29,H:71>), and sends this data over UART to an XBee module for wireless transmission. It also prints the sent values to the console for debugging purposes and repeats the process every 2 seconds.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import machine
import utime
import dht
from machine import UART
 
# Initialize the DHT11 sensor
sensor = dht.DHT11(machine.Pin(15))
 
# Initialize UART for XBee communication
uart = UART(0, baudrate=9600)
 
def read_and_send():
    try:
        sensor.measure()
        temp = sensor.temperature()
        hum = sensor.humidity()
        
        # Prepare the message string
        message = "<T:{},H:{}>".format(temp, hum)
        
        # Send the message over UART
        uart.write(message)
        
        # Debugging output to console
        print("Sent Temp: {} C, Hum: {} %".format(temp, hum))
    except OSError as e:
        print("Failed to read from DHT sensor")
 
    utime.sleep(2)
 
while True:
    read_and_send()


Receiver Code (Coordinator)

The receiver code listens for incoming UART data from an XBee module, checks if the received message is correctly formatted (e.g., <T:29,H:71>), and extracts the temperature and humidity values. It then prints the raw message as well as the parsed temperature and humidity values to the console for verification. If the message format is incorrect or parsing fails, it prints an error message. The process repeats every second to avoid flooding the output.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from machine import UART
import utime
 
# Initialize UART for XBee communication
uart = UART(0, baudrate=9600)
 
def receive_and_display():
    if uart.any():
        message = uart.readline().decode()
        if message.startswith('<') and message.endswith('>'):
            print("Raw Msg: ", message.strip())
            
            # Extract temperature and humidity
            try:
                temp_start = message.find('T:') + 2
                temp_end = message.find(',', temp_start)
                temp = float(message[temp_start:temp_end])
                
                hum_start = message.find('H:') + 2
                hum_end = message.find('>', hum_start)
                hum = float(message[hum_start:hum_end])
                
                # Debugging output to console
                print("Received Temp: {} C, Hum: {} %".format(temp, hum))
            except ValueError:
                print("Failed to parse temp and humidity.")
 
while True:
    receive_and_display()
    utime.sleep(1)  # Small delay to prevent flooding the output


Testing Raspberry Pi Pico ZigBee Communication

Connect both Raspberry Pi Pico boards (one for the transmitter and one for the receiver) to your computer via USB.

ZigBee Communication MicroPython

Run each script separately on the respective Pico board by clicking the Run button in Thonny.

  • Sender Output: On the first Pico (transmitter), you’ll see the output in Thonny’s Shell window, where it displays the formatted message with temperature and humidity values being sent (e.g., "Sent Temp: 29 C, Hum: 71 %").
  • Receiver Output: On the second Pico (receiver), the Shell window will show the received message, including both the raw format (e.g., "Raw Msg: <T:29,H:71>") and the extracted temperature and humidity values (e.g., "Received Temp: 29.0 C, Hum: 71.0 %").

Video Tutorial & Guide

XBee Tutorial | How to use XBee with Arduino for ZigBee Communication | XCTU Software Setup
Watch this video on YouTube.

This is how we can interface XBee Module with Raspberry Pi Pico using MicroPython Code and establish ZigBee communication between end device and coordinator.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleHow to set up & interface XBee Module with Arduino (Tx & Rx)
Next Article Interfacing MiCS-5524 CO, Alcohol, VOC Gas Sensor with Arduino

Related Posts

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

ADXL375 Accelerometer with Raspberry Pi Pico & MicroPython

Updated:July 24, 2025
Interface BMI160 with Raspberry Pi Pico & MicroPython

Interface BMI160 with Raspberry Pi Pico & MicroPython

Updated:February 2, 20253K
Shift Register 74HC595 with Raspberry Pi Pico & MicroPython

Shift Register 74HC595 with Raspberry Pi Pico & MicroPython

Updated:February 2, 202513K
Modbus RTU with Raspberry Pi Pico & Micropython

Modbus RTU with Raspberry Pi Pico & MicroPython

Updated:February 2, 20258K
Fever Detector with MLX90640 & OpenCV Raspberry Pi

Thermal Fever Detector with MLX90640 & OpenCV Raspberry Pi

Updated:February 2, 20256K
Thermal Imaging Camera with MLX90640 & Raspberry Pi

DIY Thermal Imaging Camera with MLX90640 & Raspberry Pi

Updated:May 2, 2026618K
Add A Comment

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 21, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • MAX30102 & Arduino: Heart Rate + Blood Oxygen Monitoring
    MAX30102 & Arduino: Heart Rate + Blood Oxygen Monitoring
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.