FAQ

Is there a way to determine the battery level on MG100 using Canvas?

Yes, battery level can be read on P0.02_AIN0 via the ADC machine class in Python.

https://lairdcp.github.io/canvas_python_docs/machine.html#machine.ADC

 There is also a python sample provided that measures and returns the battery voltage level.

 https://github.com/LairdCP/canvas_python_samples/blob/main/apps/mg100/adc/main.py

How can I determine what Python modules in my devices Canvas Firmware can be imported?

Canvas firmware has enabled a feature of MicroPython that allows you to use the following command to list all available modules (that can be imported with the 'import' statement):

help("modules")

The following is one example of the list of available modules. Note not all products will have the same modules as it is dependent on the device and size of memory.

__main__

canvas

hashlib

os

_onewire

canvas_ble

io

struct

array

collections

machine

sys

binascii

erno

math

time

builtins

gc

micropython

(Plus any modules on the filesystem)

At the time of writing this FAQ the most recent Canvas FW available for a particular module may not yet have support for the help("modules") command.

Is there a way to run scripts with Xbit VS Code Extension without naming them main.py

Yes, python scripts can be run manually by right clicking on <File>.py and select Run Python (no reset).




With this option python scripts can be named differently than main.py during development. This is useful when a developer doesn't want main.py to run automatically after reset.

Is there a script to load multiple python scripts for Canvas Firmware Applications?

Some python scripts written for use with Canvas Firmware require several other python files as dependencies. Rather than load one python script at a time there is a file_uploader.py script developed for just this purpose. Refer to the Canvas_Software_Suite_Tools at the following Ezurio Git repository.

 Canvas_Software_Suite_Tools

Type python file_uploader.py -h. This will provide available command options one of which allows the user to select the REPL port the device is plugged into. A single file can be loaded with this tool or several files contained in a directory can be loaded.

 python file_uploader.py -h

 usage: File Uploader [-h] [-d] -u UPLOAD [-r REPL]

 Tool to upload files onto a MicroPython board.

 options:

  -h, --help            show this help message and exit

  -d, --debug           Enable verbose debug messages

  -u UPLOAD, --upload UPLOAD

                        upload a file or all files in directory

  -r REPL, --repl REPL  The REPL com port to use for file upload

Is there a way to update Canvas FW or load python applications onto my device using Xbit Mobile App?

For any Canvas enabled device both python applications and Canvas firmware updates can be made using the Xbit mobile app. With the device programmed with just the Canvas FW and no applications running (i.e., no main.py or boot.py), the Canvas FW runs a built-in script to just advertise as a generic "Canvas Device".

Xbit mobile app provides the Canvas Hub applet that will allow you to select the advertising Canvas enabled device, connect to it and complete both firmware updates and python application updates.

Lyra 24 allows application updates via BLE transfers but does not allow FW updates.

The NX040 supports two UART Ports. Which UART is needed to communicate with the Python REPL?

UART1 is used by the Python REPL and is set via Canvas FW running on the module.

I'm having trouble transferring scripts to my Canvas enabled device, what should I do?

To reliably transfer files, your python app cannot be in a loop or printing any messages. Follow the steps provided below to ensure reliable file transfers.

  1. Open the UART and issue Ctrl+C.
  2. You should now have a REPL prompt.
  3. Open the UART with Xbit VS Code.
  4. Rename main.py to something else and reboot.
  5. Now you can transfer files.
  6. Important Note: To have a reliable file transfer experience, reduce the print messages in your python app, the file transfer is over this UART so cross talk must be eliminated.

How can I make calls to the OS using Micro-Python enabled Canvas firmware?

The commands detailed in the document linked below can be executed in the REPL to make calls to the Zephyr OS:

https://docs.micropython.org/en/latest/library/os.html

Not all commands are implemented, particularly in older firmware versions of Canvas.  The best way to know if a command is available is by executing it.