Now that your Wi-SUN network is operational and all devices can communicate, it’s time to give your edge nodes some intelligence. This is known as edge intelligence—the ability for devices to process and respond to data locally, without relying on a centralized system.
In this step, you will configure your Wi-SUN Development Kit devices to demonstrate a simple message exchange using MicroPython and Python, respectively:
-
Send a message from the XBee Hive Wi-SUN to a XBee Wi-SUN node.
-
Process and display the message on the XBee Wi-SUN module, converting it to uppercase before sending it back.
-
Confirm reception of the echoed message on the XBee Hive Wi-SUN, completing a round-trip interaction.
To complete this example:
1. Run the MicroPython echo app on the XBee Wi-SUN modules
After completing the setup in Step 5 - Configure the Wi-SUN devices, your XBee Wi-SUN modules are preloaded with a MicroPython script that:
-
Listens for incoming IPv6 messages on port
0x2616(9750). -
Converts the payload to uppercase.
-
Sends the modified message back to the sender’s address.
This application is not started automatically. To run it manually:
-
Open the MicroPython Terminal in XBee Studio for each device you want to activate.
-
Click Open connection with the device in the terminal’s top toolbar.
-
If prompted to enable MicroPython REPL mode, click Yes.
-
-
When the prompt (
>>>) appears, press Enter. -
Press Ctrl + R to run the script. You should see the following output:
>>> Parsing /flash/main.py... Compiling /flash/main.py... Running bytecode... Waiting for the module to be connected to the network... Waiting for incoming data...This indicates the echo application is running and ready to receive data.
To make the application run automatically at boot, set the ATPS parameter to Enabled [1].
|
2. Run the client Python app on the XBee Hive Wi-SUN
As with the XBee, after completing Step 5 - Configure the Wi-SUN devices, your XBee Hive Wi-SUN device includes a ready-to-run Python script located at /etc/config/scripts/get-started.
This script allows you to send messages to an XBee Wi-SUN node and receive its response.
To run the script:
-
Open the Terminal for the XBee Hive Wi-SUN in XBee Studio.
-
Click Open connection with the device in the toolbar.
A selection menu is displayed:
Access selection menu: a: Admin CLI s: Shell q: Quit Select access or quit [admin] : -
Type S to access the XBee Hive Wi-SUN shell.
-
Navigate to the script folder:
# cd /etc/config/scripts/get-started -
Obtain the IPv6 address of the target XBee Wi-SUN:
-
In XBee Studio, right-click on the XBee Wi-SUN module tab.
-
Select Copy > Mesh IPv6 from the context menu.
-
-
Run the Python script by passing the target IPv6 address:
# python main.py -a <node_ipv6>Where
<node_ipv6>is the copied XBee Wi-SUN module IPv6 address.For example, for a XBee Wi-SUN module IPv6 address
fd12::4fb9:# python main.py -a fd12::4fb9 Type a message and hit Enter to send it to [fd12::4fb9]:9750. >
3. Confirm the message exchange
To validate the communication between your devices:
-
Detach the tab of the target XBee Wi-SUN device to make both terminals visible.
-
In the XBee Studio main window, ensure the XBee Hive Wi-SUN Terminal is in focus.
-
Arrange the windows so you can monitor both devices side-by-side.
-
In the XBee Hive Wi-SUN Terminal, enter:
Hello from BR’s Python app! -
Press Enter.
-
On the XBee Wi-SUN MicroPython Terminal, you should see output like:
Received from [<br_ipv6>]:<port> >> Hello from BR's Python app! Echoed to [<br_ipv6>]:9750 >> HELLO FROM BR'S PYTHON APP!Where
<br_ipv6>is the IPv6 address of your XBee Hive Wi-SUN. -
The XBee Hive Wi-SUN Terminal should display:
# python main.py -a <node_ipv6> Type a message and hit Enter to send it to [<node_ipv6>]:9750. > Hello from BR's Python app! > Received from [<node_ipv6>]:9750 >> HELLO FROM BR'S PYTHON APP! >Where
<node_ipv6>is the XBee Wi-SUN module IPv6 address. -
Close the device’s terminals:
-
In the XBee Wi-SUN MicroPython Terminal, click Close the connection with the device in the toolbar.
-
In the XBee Hive Wi-SUN Terminal, click Close the connection with the device in the toolbar.
-
4. Summary and next steps
In this example, you:
-
Started a MicroPython application on the XBee Wi-SUN modules to receive, process, and echo messages over IPv6.
-
Launched a Python application on the XBee Hive Wi-SUN to send and receive test messages.
-
Verified successful bidirectional communication within your Wi-SUN network.
This is your first step toward building distributed logic across your network using Python and MicroPython. You can now extend this setup to create intelligent applications for sensing, actuation, and autonomous coordination.
4.1. Tools and libraries to build Python applications
Digi offers a complete suite of tools to help you create, debug, and deploy Python-based applications on your devices:
| Tool / Library | Description |
|---|---|
Official PyCharm plugin that enables Python development on edge devices (like XBee Gateways and Border Routers) and MicroPython development on XBee modules. It lets you write, deploy, and execute scripts directly from the IDE—no additional setup required. |
|
A robust library for Python applications running on host platforms. It abstracts XBee communication protocols and simplifies message exchange. |
|
A graphical interface for configuring, managing, and interacting with XBee devices. Includes integrated terminal support for both Python and MicroPython development. |
These tools are actively maintained by Digi and designed to streamline your development workflow across embedded and edge applications.