From Digi: Employing Wireless Edge Intelligence with Digi XBee MicroPython

Jun 8, 2019
 

At Digi, we have been enhancing the MicroPython capabilities in our XBee® line for many months, and have rolled out a range of new features. But we will continually add enhancements to support edge intelligence in IoT applications. “We’ve only just begun!”

With the latest release of the Digi XBee3 MicroPython firmware, the feature set now enables customers to build real business logic on the XBee itself over the lifecycle of the end product.

Here’s a quick review of some of the new features:

  • We’ve expanded the MicroPython capabilities across the product line.
  • We added MicroPython custom module support to our short range products.
  • Additionally, we added the ability to update the MicroPython application remotely over the air.

 

Expanded MicroPython Capabilities

The new MicroPython capabilities mean that you can expect the I/O interfaces to look the same across the XBee3 product line. Whether you want to use PWM to drive a motor, interface to an I2C thermostat or sensor, or just turn a light on and off, you will be able to use your Digi XBee3 device to add intelligence and interact directly with the real world. As we’ll see, potential real world use cases include everything from home automation to industrial IoT applications.

Custom MicroPython Support

On Digi XBee3 short range products, customers can now add their own custom MicroPython modules. A Python environment without modules is severely limiting. Modules are fundamental to Python programming and software engineering best practices. They make it straightforward to share common code between different XBee3 modules and even different customer end products.

MicroPython Over-the-air Updates

Over-the-air updates (OTA) mean if you find a bug in your code or you want to enhance the capabilities of your devices in the field you can push out new code to your XBees without having to roll a truck to each one.

In many applications such as street lighting, having to physically access the devices to fix a bug or add some new features is simply not practical. This feature lets you update your devices without having to physically disassemble them, which saving time and labor.

Over-the-air Updates for Short Range and Cellular

Digi XBee and XBee3 customers are already familiar with our ability to upgrade your XBee firmware over-the-air. Our development team set out to ensure that customers can also remotely update MicroPython applications on Digi XBee3 devices. For devices that use IP, we integrate Digi Remote Manager® (DRM), Digi’s cloud service for remote device monitoring and configuration management. For short-range RF products that are not on an IP network like Zigbee, we use the OTA feature.

Digi XBee3 short range products that include 802.15.4, DigiMesh and Zigbee cannot connect directly to DRM and also have an over the air MicroPython update feature. Since they have more limited space than XBee3 Cellular, we utilize the firmware update features that were already present in the product to upload a simple filesystem image that contains the Python application and its supporting modules.

For Digi XBee3 Cellular products, you can use DRM to directly interact with the filesystem on your XBee. Not only can you upload your Python code, but you can set it so updates only occur when sleeping devices wake, for optimal battery usage. This capability uses a feature unique to Digi devices connected to DRM called Short Message (SM) Query. It allows you to minimize data usage and even to connect on demand via SMS or at the next check-in interval via UDP.


Benefits of Using MicroPython

MicroPython enables customers to add intelligence to end products without the added time, cost, and complexity of designing in a host microcontroller. Of course, this is not a one-size-fits-all model; the choice of using MicroPython or host processor depends on the complexity and requirements of the application.

A host microcontroller may be appropriate, and the two are not mutually exclusive. MicroPython can serve to add functionality to the communications module that might not be there otherwise (e.g. MQTT), and thereby save the time required to implement it on the host MCU. That saidmany applications do not require a host processor and simply require their business logic to perform some sequence of the following actions:

  • Read an input (I2C, GPIO)
  • Track an interval
  • Send some data
  • Perform a simple calculation
  • Check for a condition to change
  • Turn a device on or off
  • Sleep
  • Wake up

The actions above combine in straightforward ways to solve problems, and any of these actions can be performed using MicroPython. A typical XBee3 running MicroPython might sleep for five minutes, wake up to check whether the status of a GPIO has changed from low to high, then go back to sleep. If the value changes it could send a text message to issue an alarm that something is has gone wrong.

Sample Use Cases for Digi XBee3 MicroPython

There are many practical everyday uses for this functionality, as well as field applications for industrial IoT. The various types of use cases may require the functionality of the XBee3 Cellular line (CAT1, LTE-M, NB-IoT, 3G), or XBee3 short range products (Zigbee, DigiMesh, 802.15.4), depending on the required topology and distribution of devices and the frequency and amount of data to be sent.

Let’s explore examples that show the range of possibilities.

Water Level Sensor

In certain climates, homes can experience sump pump failure due to excessive snow melt and run-off, or rainstorms that produce a high volume of rain. A simple high-water-level sensor can alert the homeowner to the issue before it results in basement flooding.

Daily Data Reading Application

In another example of a typical Digi XBee3 MicroPython application, the module sleeps for a day, wakes up, reads an I2C sensor, transforms the data with a simple calculation, formats the result, and then transmits the data point upstream to the desired IoT cloud or to a local gateway for aggregation, depending on whether the XBee3 is cellular or short range, respectively.

Industrial and Agricultural Applications

Using MicroPython on Digi XBee3 is gaining traction with our customers to solve real world problems.

Digi XBee MicroPython

For example, one customer used MicroPython on XBee3 Cellular LTE-M to build the logic into battery powered soil sensors to monitor the temperature and humidity of fields of mulch piles. This application utilized several MicroPython libraries including MQTT to publish the data to the AWS (Amazon Web Services) IoT cloud.

Another customer used an FTP client library to log data to the filesystem and then transmit it to their own application server.

In another use case, a customer used MicroPython on XBee3 Zigbee to read the current temperature and send it to a remote node in a steam metering application.


MicroPython Code Simplicity

The great thing about these solutions is they involve incredibly simple MicroPython code. A skilled developer can create a useful application in 100 lines of code or less.

MicroPython solutions are limited only by the imagination. For example, you can use MicroPython with Digi XBee3 devices to do any of the following and more:

  • Drive a simple display
  • Interface with BLE
  • Add a simple network protocol
  • Enhance API mode with the User Data Relay Frame
  • Handle requests from the cloud

We’ve only just begun to deliver edge intelligence solutions on Digi XBee3. Digi is actively working to expand our MicroPython development tools, libraries, example programs, and applications that we host on our github repository. These developer resources provide building blocks that you can use to solve real problems by adding intelligence to IoT your products and applications.

 

Source: https://www.digi.com/blog/employing-wireless-edge-intelligence-with-digi-xbee-micropython/ 

 

Looking to integrate Digi products with your design? Our Applications Engineers offer free design and technical help for your latest designs. Contact us today!

 


 

Symmetry Electronics Logo

 

Why partner with Symmetry Electronics? Symmetry's technical staff is specially trained by our suppliers to provide a comprehensive level of technical support. Our in-house Applications Engineers provide free design services to help customers early in the design cycle, providing solutions to save them time, money and frustration. Contact Symmetry for more information.



Subscribe

Sign up to get tech news, product updates and store promos from Symmetry Electronics.

Subscribe

Choose Topic

Blog Archive

  2019
  2018
  2017
  2016
  2015
  2014
  2013
  2012
  2011
  2010
  2009

Previously Viewed Products