Skip to content

uutzinger/SerialUI

Repository files navigation

Graphical User Interface for Serial Communication

Serial Monitor SerialUI provides a graphical interface to send and receive text and data from the serial port or BLE connection (Nordic UART Service).

It includes a serial plotter for displaying numerical data.

It offers features beyond other serial terminals. For example, in addition to features found on Arduino IDE it offers:

  • Serial over BLE
  • Recording of received data
  • Extended charting of the data

Throughput is similar to other serial terminal programs. Data is transmitted using N

This program is written in python using PyQt and Bleak as well as PyQtGraph or fastplotlib .

Under development are binary data transmission and indicating data with display elements other than a chart.

The main program is SerialUI.py. It uses files in the assets, docs and helper folders.

Video

Video using ESP32 with testBLESerial program. Data is transmitted using BLE Serial and maximum transfer test shows > 100 kByte/s. Device is connected to application with both serial USB and serial BLE.

Video

Description

The serial monitor interface

Serial Monitor

The serial charting interface

Serial Plotter

Serial BLE extension

Serial BLE

How to Use This Program

Installation Requirements

One liner Windows: - pip3 install pyqt6 pyqtgraph markdown wmi bleak

One liner Linux: - pip3 install pyqt6 pyqtgraph markdown pyudev bleak

The following python modules are needed:

  • pyqt5 or pyqt6 user interface
  • pyqtgraph plotting
  • fastplotlib for high throughput plotting
  • numpy data gathering and manipulation
  • markdown help file
  • wmi on Windows for USB device notifications
  • pyudev on Linux for USB device notifications
  • bleak for bluetooth communication
  • numba acceleration of numpy code

To install the optional accelerated text parser you need to navigate in your shell to the helper folder and then execute:

  • python3 setup.py build_ext --inplace -v
  • pip install -e . If you are using virtual env for python don't forget to activate it.

If you rebuild, clean the previous build with:

  • python3 setup.py clean --all || true
  • rm -rf build *.egg-info .eggs

This requires a c11 compiler and the python packages pybind11 and setuptools to be available.

A future version will also need:

  • scipy image decompression (FFT)
  • cobs serial data encoding (byte stuffing)
  • tamp for compression (lightweight for microcontrollers)

Enabling / Disabling Features

The programs configuration is stored in config.py (main folder). Here you can enable/disable features such as:

  • USE_FASTPLOTLIB: Plotting with fastplotlib instead of pyqtgraph
  • USE_BLE: enable serial communication over BLE
  • USE_BLUETOOTHCTL: enable pairing and trusting of BLE devices (available on Unix like systems)

Modules

The program is organized into these modules.

Nordic UART Service - BLE

The NUS provides a serial interface similar to regular USB interface for microcontrollers. The implementation on a microcontroller requires more programming effort than a simple Serial.print especially if secure connections and automatic reconnection is considered. BLE connections can be optimized for low power, extended distance or high throughput.

A detailed example is the BLE test program which was used to test SerialUI.

With ESP32-S3 a transfer rate of more than 100kByte/s can be expected when BLE connection is optimized for high throughput.

Data Parsing

The data parser extract values and variable names from lines of text. Besides a python version, there is a C accelerated version available. For supported data formats see: Data Parsing Approach

Indicating Data

Indicating data is not implemented yet: Feature not implemented yet.

fastplotlib

Fastplotlib itself is under development. There is a cusom legend.py in python libraries folder that is needed when you enable fastplotlib in the config file. The file replaces the legends.py of the creators. It needs more work.

During program startup the library and the chart widget are initialized. This requires building the pipeline for the GPU which takes 5-10 seconds. During that time the program might be sluggish.

Arduino Test Programs

In the Arduino_programs folder are example programs that simulate data for serial UART and BLE connection.

Efficiency

A detailed comparison of SerialUI with other serial IO programs was conducted.

The SerialUI is as performant as other good terminal programs. The maximum text transfer of an ESP32-S3 over USB is about 800k bytes/s and 100k bytes/s over BLE. With a Cortex-M7 (Teensy) we reached about 7M bytes/s over USB.

With both fastplotlib and pyqtgraph we can plot two channels with at least 200k samples per second at 10Hz plotting refresh rate. When large display history is needed fastplotlib with a dedicated GPU is better suited as plotting engine.

Packages utilized in this Project

The following libraries are used:

[*] not required but will accelerate the program, [**] needed if BLE is enabled, [***] needed if fastplotlib is enabled [***] future version

Contributors

Urs Utzinger, 2022-2025 (University of Arizona), Cameron K Brooks, 2024 (Western University), ChatGPT (OpenAI)