Insta MCUKit Library 1000x650

23 - 11 - 2023 - Expert blogs

Boosting Qt for MCU development with Insta’s MCUKit library

Qt for MCU is a graphics framework tailored for creating user experiences on resource constrained MCU devices. In this blog post, our Senior Software Developer Markus Mertama shares his experiences working with Qt for MCU and illustrates how he implemented a library containing an essential set of connectivity features and UI components to speed up application development of any MCU project using Qt for MCU. 

Software development
Insta MCUKit Library 1000x650

Background

We have been working on an air quality monitoring system project that uses sensors and displays on a Raspberry Pi, connects to services over MQTT, and our cloud backend over OPC UA. As impressive and easy to use as the Raspberry Pi is - it primarily excels in prototyping. Leveraging it for mass industrial production is not feasible.

We decided to move from a Raspberry PI to a microcontroller (MCU) based approach. When considering factors such as cost, availability, and sourcing, an MCU solution stands out as a superior option. I selected the STM32F769I-DISCO as my development platform. The platform has a touch screen HMI and I have extensive experience with Qt, so Qt for MCU was a natural selection for my graphics framework.

Building up the MCUKit Library

Qt for MCU is a separate product in the Qt ecosystem. Whereas the ‘normal’ Qt is a multiplatform C++ framework for embedded, desktop and mobile, Qt for MCU aims for multiplatform across a wide range of MCU hardware. Qt for MCU provides a QML (aka QtQuick) development experience for selected MCU platforms. It does not contain the same Qt C++ API libraries that Qt developers have been utilizing for decades. Rather, the C++ API is limited to low level hardware abstractions. QML support is limited to basic drawing, and only a few widgets are supported out of the box. Qt for MCU offers draw primitives, basic widgets, events, system service abstractions and a C++ / QML communication API.

I needed MQTT for the project and quickly noticed that foundational networking APIs and user input widgets need to be built up from scratch. Therefore, to really make the air quality monitoring system production grade, I set off to implement a good set of essential widgets, networking APIs, as well as utilities, and packaged them up in what I named ´the MCUKit library´ that benefits any MCU project using Qt for MCU.

MCUKit contains interfaces to speed up software development; you can e.g. implement an MQTT application with just a few lines of QML. To minimize system requirements (and HW costs) and maximize performance I decided to work on ‘baremetal’ i.e. with no operating system underneath. The MCUKit can also be used with FreeRTOS for projects that benefit from operating system services.

MCUKit Library

MCUKit networking is based on the LWIP stack, which is a minimal implementation of TCP/IP suitable for MCU devices. MCUKit wraps up STMicroelectronics’s reference adaptation for STM32F769I-DISCO networking and offers a C++/QML API for networking essentials like setup, TCP/IP, UDP and MQTT. All these essentials have QML interfaces for setup as well as sending and receiving data (in MQTT case this is called publish and subscribe).

The full MQTT application is only a few lines of QML:

import QtQuickimport QtMCU

Rectangle {MQTTTopic {topic: "/test/QtMCU/mumbling-news"connection: mosquittoonSubscription: {var msg = readString();log.appendLine("msg);}onIsConnectedChanged: {if(isConnected) {subscribe();}}}

MQTTConnection {id: mosquittobroker: "test.mosquitto.org"}

For a minimum MQTT application there are very few other things to do when leveraging MCUKit. A baremetal runtime is a single process, single threaded environment with nothing else running except the application itself. Network.poll () gives execution time for the networking and thus the application has full control over system resources.

Timer {interval: 100repeat: trueonTriggered: Network.poll();

}

MCUKit provides a convenient ConsoleView component to write output in a terminal style:

ConsoleView {

id: log

anchors.fill: parent

rows: 15

topDown: false

cutAt: 65

}

}

MCUKit is not only about networking. In addition, there are some very essential components like:

ConsoleView to show a streaming output like a log.

  • Multiline text view

  • Grows up (terminal style) or down (list style)

ITUTKeys for a text in put on a small screen.

  • When there is no room for qwerty the ITU-T offers input in 12 keys

  • Mobile phone style input has low and upper letters, numbers and a wide set on symbols

TextInputField

  • User friendly input field associated with ITUTKeys.

Qt for MCU is a cool graphics framework

Qt for MCU is a cool graphics framework and toolkit to create and deliver user experiences on resource constrained MCU devices. As a constrained environment it is understandable that all the API’s and widgets from the ‘normal’ Qt are not available, hence many essential components for production grade products need to be built up from scratch.

We are happy to chip into this effort by creating MCUKit to speed up connected Qt for MCU application development and help our customers. We are keen on extending support for other platforms and adding functionality to the needs that our customers will have.

Ohjelmistokonsultointi

Markus Mertama
writer

Markus Mertama

Senior Software Developer, Insta Advance

Share article

Stay on top of the industry trends and subscribe to our newsletter

The most important news, inspiring articles, and up-to-date insights from our experts across various industries and information about our upcoming events.

Accept the terms and conditions. We handle your information responsibly.
Please review our privacy policy.