The MicroPython Read-Eval-Print Loop (REPL) is an interactive command-line interface that allows you to write, test, and debug MicroPython code directly on the XBee 3 BLU module.
This feature is essential for rapid development and troubleshooting, offering a live environment where you can execute commands and see immediate results. It enables real-time interaction with the device’s hardware, files, and network settings without the need to compile or deploy code repeatedly.
Use cases of this feature include:
-
Rapid prototyping and development: The REPL is crucial in the early development stages for testing code snippets, adjusting parameters, and exploring XBee’s API. It lets you experiment in real-time, making it perfect for prototyping and validating concepts before integrating them into larger projects.
-
Debugging and troubleshooting: When problems occur in your application, the REPL allows you to inspect the device’s current state and run diagnostic commands. You can also test code snippets or perform hardware diagnostics without altering the main script.
Currently, the only way to interact with the REPL is:
Using XBee Studio
XBee Studio includes an embedded tool called MicroPython Terminal to interact with the MicroPython REPL of an XBee device. This tool includes helper features and is able to interpret escape sequences and control codes correctly, making it ideal to streamline REPL interactions.
Follow these steps to access the MicroPython Terminal view of your XBee 3 BLU device:
-
Connect your device to a PC where XBee Studio is installed.
This section assumes that you know how to connect the XBee 3 BLU device to a PC. For more information on how to connect an XBee device to a PC, see the Step 2 - Set up the hardware page from the getting started section. -
Open XBee Studio.
-
Wait for your device to be discovered.
A module that’s never been configured should be discovered automatically, but if you have problems discovering your local device, see the Device discovery tools section of XBee Studio User Guide to learn how to do it manually. -
Click on the device. The Dashboard page appears. It contains the device information, connection interface and a list of quick actions.
-
Click the MicroPython Terminal item in the sidebar of the tab, located within the Development section. MicroPython Terminal view is displayed.
-
Open the connection by clicking on the plug adapter button on the top toolbar.
To use the REPL, your module must be set to MicroPython REPL operating mode. If it isn’t, the tool will prompt you with a confirmation pop-up to automatically switch the mode. -
Press Ctrl+B to get the MicroPython version banner and prompt.
MicroPython v1.20.0-1829-gcf5c2e9fb on 2023-07-20; XBee BLE with EFR32MG Type "help()" for more information. >>>
-
You can type any MicroPython instruction, like
print("hello")
or3+2
and then press Enter to execute it.
See the Micropython Terminal section of the XBee Studio User Guide for more information. |
Using a serial console application
You can use any terminal/console application (such as Tera Term or Picocom) to interact with the REPL while the XBee device is connected serially to your PC or microcontroller.
To interact with your XBee 3 BLU’s REPL serially using any serial console application, refer to the Other terminal applications topic.