You can develop MicroPython applications with any text editor or Python IDE and deploy them manually to the XBee for Wi-SUN device.
But for a more streamlined workflow, Digi provides the Digi XBee PyCharm IDE plugin. This plugin integrates seamlessly with XBee for Wi-SUN devices, allowing you to create new MicroPython projects or import existing examples. And, once your application is ready, it lets you build and deploy it to the target device with a single click. It also offers code completion and direct access to XBee-specific MicroPython libraries.
This section explains how to create a new project, import an existing sample and launch any application on the XBee for Wi-SUN using the Digi XBee PyCharm IDE plugin.
| For more information about the Digi XBee PyCharm IDE plugin, refer to the Digi XBee PyCharm IDE Plugin User Guide. |
1. Launch the Digi XBee PyCharm IDE plugin
The first step in developing an application is to open the IDE with all the tools needed to streamline and simplify both development and deployment.
If you don’t have PyCharm or the Digi XBee PyCharm IDE plugin installed, follow the steps below.
Follow these steps to install PyCharm and the Digi XBee PyCharm IDE plugin:
-
Download and install the latest version of PyCharm Community Edition from the PyCharm download page.
-
Execute PyCharm.
-
Go to the Plugins window by doing one of the following:
-
On the Welcome screen select Plugins.
-
Or, from the main menu, select File > Settings, and then click Plugins.
-
-
In the Marketplace search box, type Digi XBee. The Digi XBee plugin should appear and selected by default.
-
Click Install.
-
When finished, click Restart IDE to complete the plugin installation.
After completing the installation, keep PyCharm open. You’ll use it throughout the rest of this process.
2. Create your project
Once PyCharm and the plugin are ready, you can start working on a new project. You can either:
Both options are supported directly within PyCharm using the Digi XBee plugin.
Import a Digi sample
Digi offers a wide variety of working examples that cover many common use cases to work with your XBee for Wi-SUN devices. The Digi XBee PyCharm IDE plugin allows you to clone any of these examples from GitHub. These examples are pre-configured to run on XBee for Wi-SUN and are a great starting point for testing or extending existing functionality.
To import a sample:
-
Open the Import Digi Sample wizard dialog. You have 2 ways to do it:
-
On the Welcome screen, click New Digi Project and select Import Digi Sample on the modal dialog that appears.
-
Or, from the main menu, choose File > Import Digi Sample Project.
-
-
In the wizard dialog, select the XBee module category and click Next. The platform list appears.
-
Select the Digi XBee for Wi-SUN platform and click Next. The samples list is displayed.
-
Select the desired sample project. When you click on a sample, the right-side pane displays a description for such sample. Use this as a helper to select the right sample for you.
-
Once the sample is selected, click Next. The project configuration view appears.
-
Specify the project location and Python interpreter, then click Create. PyCharm imports the sample and opens its
main.pyandREADME.mdfiles.
Create an empty project
You can also start a project from scratch using Digi’s PyCharm plugin to simplify the setup.
To create a new project:
-
Open the New Digi Project wizard dialog. You have 2 ways to do it:
-
On the Welcome screen, click New Digi Project and select Create Digi Project on the modal dialog that appears.
-
Or, from the main menu, choose File > New Digi Project.
-
-
In the wizard dialog, select the XBee module category and click Next. The platform list appears.
-
Select the Digi XBee for Wi-SUN platform and click Next. The available libraries list is displayed.
-
If your project requires libraries, select them to be imported and click Next. The project configuration view appears.
-
Specify the project location and Python interpreter, then click Create. PyCharm creates a new project and opens main.py, ready for you to start coding.
3. Build and launch your application
After you finish coding your application, you can build and launch it on your XBee for Wi-SUN device directly from PyCharm.
As PyCharm first connects to the device where the application has to be deployed, you need to ensure that the device is discoverable. Once done, you do not have to repeat this process again:
-
An XBee for Wi-SUN device only requires to be connected to the PC. If you don’t know how to do it, refer to Step 3 - Set up the hardware.
To build and run:
-
In the PyCharm top toolbar, click the Run button (green triangle). A dialog appears prompting you to select the target device.
-
Click OK. The XBee Device Selector dialog opens.
-
Choose Local PC to discover the XBee for Wi-SUN device connected to your computer and click Next.
-
Select your XBee for Wi-SUN and click OK.
| If your device is not in MicroPython REPL mode, you will be prompted to configure it. Click Yes to set it automatically. |
-
Wait for the MicroPython application to be automatically transferred and executed on your XBee for Wi-SUN device.
-
The application is transferred and executed on the XBee for Wi-SUN device. The MicroPython REPL console view displays the output of the application.
4. Next steps
To continue building your knowledge and applications using MicroPython with XBee for Wi-SUN, explore the ready-to-use examples available through the Digi XBee PyCharm IDE Plugin. These examples are directly importable and demonstrate, among other things, how to:
-
Perform regular device configuration tasks or manage runtime behavior.
-
Configure and monitor GPIO, I2C, and ADC to interact with external hardware.
-
Use power management features to reduce energy consumption in battery-powered deployments.
-
Build richer device applications by extending the examples with custom logic.
To get started, see Digi XBee Pycharm IDE plugin.
Develop a MicroPython application with other tools
If you prefer not to use the Digi XBee PyCharm IDE plugin, you can still manually develop and deploy MicroPython applications following the steps below:
-
Write your MicroPython application using your preferred Python IDE or text editor.
Refer to the Digi MicroPython Programming Guide for information about the APIs supported by the XBee devices. -
Rename the application to
main.py. -
Transfer the application and required libraries to the root of the XBee for Wi-SUN device’s file system using XBee Studio.
-
Configure the
PSAT command with1(enabled) using XBee Studio so that the MicroPython application starts automatically when the device boots. -
Open the MicroPython Terminal view of your XBee device in XBee Studio and connect it.
-
Reset your XBee module. The MicroPython application starts automatically and the MicroPython Terminal within XBee Studio displays the output of the application.
| For more information about how to manage the file system of your XBee device, configure it, and access the MicroPython Terminal, refer to the Manage the XBee device chapter. |