Have a Question?

MicroPython Examples for Digi XBee Part 1: Edge Computing

The new Digi XBee3® line of embedded RF modules feature edge intelligence to help execute business rules and a whole lot more. By running simple Python-based scripts on Digi XBee3, you can save money, extend battery life, improve responsiveness and enhance system reliability.
The best way to understand the power of edge intelligence is hands-on. In this series well take you through some simple examples that you can use directly, then customize and extend to bring the power of programming to everyones favorite line of radio modules.
MicroPython is an open-source programming language based on Python 3, modified to fit on small devices and optimized for microcontrollers. Using MicroPython, an easy-to-learn scripting and programming language, you can rapidly prototype intelligent behaviors at the edges of your network. Cryptic sensor readings can be transformed into useful data, excess transmissions can be intelligently filtered out, and modern sensors and actuators can be employed directly, with complex procedures carried out locally when needed.

Getting Started with Digi XBee MicroPython Programming

XCTU v6.3.8 and later feature a new MicroPython terminal, allowing the user to interact with MicroPython on the Digi XBee3 modules. Through the serial interface in the terminal, users can write, test, load, and run MicroPython code using the familiar REPL interactive prompt.
Its simple to get started. Well begin with the Digi XBee3 Cellular LTE-M Kit. (Other Digi XBee3 Cellular Kits are similar.)
MicroPython Terminal
  1. Assemble the hardware and connect it to the XCTU configuration software. Complete instructions, if needed, can be found in the Getting Started Guide.
  2. Open the XCTU program.
  3. Add a device (help).
  4. The XBee Cellular Modem appears as a box in the Radio Modules information panel. Click this box to select the device and load its current settings.
  5. Set the devices baud rate to 115200 bps for the best experience. In the BD field, select 115200 [7] and click the Write button.
  6. To put the XBee Cellular Modem into MicroPython mode, in the AP field select MicroPython REPL [4] and click the Write button.
  7. Note what COM port(s) the XBee Cellular Modem is using, because you will need this information when you use terminal communication. The Radio Modules information panel lists the COM port in use.
To use the MicroPython Terminal in XCTU:
  1. Click the Tools drop-down menu and select MicroPython Terminal.
  2. Click Open. If you have not already added devices to XCTU:
    1. In the Select the Serial/USB port area, click the COM port that the device uses.
    2. Verify that the baud rate and other settings are correct.
  3. Click OK. (The Open icon changes to Close, indicating that the device is properly connected.)
  4. Press Ctrl+B to get the MicroPython version banner and prompt.

Related white paper: 5 Reasons You Should Consider Embedded Cellular Connectivity.

Hello World Example

Lets upload some simple "Hello World" code to confirm everything is working. Using a text editor, such as Notepad in Windows or TextEdit on MacOS, type in this short script:
contact us to discuss your needs.