Nowadays electronic devices have infiltrated the majority of industries and serve numerous functions—from automotive to consumer electronics, medical devices, and smart technologies. The one common factor among all devices is the need for software—fast in development, cost-effective in design, cross-platform, and delivery of a seamless user experience across all devices. Qt framework fits all these criteria.
Qt is a cross-platform C++ development framework for mobile, desktop, and embedded applications. It supports various platforms like Linux, OS X, Windows, Android, iOS, BlackBerry, Sailfish OS, and others. Eight of the top ten Fortune 500 companies use Qt for its own devices.
CoE Solutions team decided to gather real experience with Qt framework and have started a proof of concept (PoC). The following goals are expected to be achieved at the end of the PoC:
- Gain hands-on experience with Qt from design to implementation
- Validate assumptions and ideas about Qt
- Have a ready and presentable product for our clients
Start with simple
Based on framework description we made the following assumptions to be validated:
- Qt Markup Language (QML) offers tools for faster development and modern UX/UI design compared to Qt GUI + Qt Widgets.
- Qt should be lightweight enough to run an application on a platform with limited resources like embedded devices.
- Qt is a cross-platform framework offering cross-platform and cross-compiling support. Developed application and designed user interface once could be easily deployed across several mobile and desktop operation systems like Linux amd64, Linux armv7, Windows, or Android etc.
- To conserve a device’s resources, try using Qt without display manager and window system.
We started the investigation with a small and simple prototype in order to gain prompt, initial experience.
The following components were chosen for the first prototype:
Raspberry Pi 3 Model B+ – 1.4GHz 64-bit quad-core processor, 1GB RAM, dual-band wireless LAN, Bluetooth 4.2/BLE, faster Ethernet, and Power-over-Ethernet support (with separate PoE HAT)
Analog Ambient Light Sensor v2.1 – This sensor detects the light density and reflects the analog voltage signal back to controller. Illumination range from 1 Lux to 6000 Lux.
ADC MCP3008 – 8-channel 10-bit analog to digital converter. This is a good option for reading simple analog signals from a light or temperature sensor.
CircularGauge QML Type is used to show measured values from light sensor. It is similar to traditional mechanical gauges that use a needle to display a value from some minimum to maximum defined value.
The device was acceptable and initial experience was gained. Qt is available under following licensing options: commercial licenses and GNU Lesser General Public License (LGPL) version 3. LGPL license is good enough to use it for R&D (Research & Development) and prototyping for different devices and platforms, including embedded devices as well.
The next step was to extend the current solution and increase functionality for the average user.
Make it useful
The second step of the PoC was to develop a more useful device for the end user, while simultaneously increasing options for user interface variations. The most logical way for evaluating the first prototype is extending it to a Working Environment Monitor (WEM). For the purpose of the PoC, the device was named "Sense1". The new device would monitor base parameters inside a users’ room and provide information about working environmental conditions.
Six base parameters were chosen for measuring environmental conditions: temperature, humidity, barometric pressure, noise level, illuminance, and air condition. Volatile organic compounds (VOC) are measured as air condition parameter.
Next, the following sensors were added to capture and measure environmental parameters:
BME280 – temperature, humidity and pressure sensor. This sensor can measure temperature from -40°C to 85°C with ±1.0°C accuracy, relative humidity from 0 to 100% with ±3% accuracy and barometric pressure from 300Pa to 1100 hPa with ±1 hPa absolute accuracy.
Waveshare Sound Sensor – has microphone with sensitivity 52 dB and frequency range 50Hz ~ 20KHz.
Air quality sensor – SparkFun CC811 is a digital gas sensor that senses a wide range of VOC, including equivalent carbon dioxide and metal oxide.
The four sensors were connected to Raspberry PI to measure six base parameters for environmental conditions. To display parameter values and provide a user the ability to interact with the device, a 5-inch LCD resistive display was connected.
The display also allowed the user the ability to rearrange the order of the icons, choosing preferable order for displaying values. To get more information about specific parameter, like current light, humidity, or pressure, the user could tap on the icon and open the indicator’s card.
For increased understanding and view, the following photos give a high-level representation and view of how the device looks when ready, prior to development and debug stage.
Preliminary prices for hardware device components are listed below.
|Raspberry Pi 3 Model B+||$35.00|
|Analog to Digital Converter||$2.30|
|Temperature, humidity and pressure sensor||$6.60|
|Air quality sensor||$20.95|
|LCD resistive display||$35.00|
Make it pretty
For everyday use Sense1 requires a compact, ergonomic, and functional case. Several technical tasks should be solved to cover these requirements. First, the wrong placing of sensors may affect device functionality. The air quality sensor should be placed in separate section, because oil on device, flux for soldering, and other organic chemistry from device can influence air quality measurements. Temperature and pressure sensors also require separate sections, as additional heat from device causes inaccuracies in measurements. The light sensor detector should be placed on the outside of the case. A hole should be present in the case for a sound sensor microphone.
Secondly, the device should be compact. This work is still in progress with two possible options. The first option is to have the screen overlapping Raspberry; The second option is to create a more compact version with Raspberry’s USB ports next to the screen.
Special connectors have been ordered to make Sense1 more compact.
Validation of Assumptions
At the end of investigation all assumptions were validated.
The device is very efficient in the scope of the hardware resource consumption. Software and hardware can work with satisfactory performance and render smooth UI even with Raspberry Pi Zero that has a one core 1 GHz processor and 512 RAM—which is less powerful compared with first option Raspberry Pi 3 1.4GHz quad-core processor and 1GB RAM.
Qt gives a possibility to use EGLFS plugin for rendering. EGLFS is a platform plugin on top of an interface between OpenGL and the native windowing system—without an actual windowing system like X11 or Wayland—and supports software-rendered windows, like QWidget, too. Widgets' contents are rendered using the CPU into images—uploaded into textures and composited by the plugin. Elimination of display manger and windows system allows at least 100 Mb of RAM to be saved. This RAM conservation is significant in the case of devices with 256 RAM usage limits.
The final application consumes about 40 Mb of RAM and has a binary size of about 1.2 Mb.
QML is easy in usage and fast in development. It provides a satisfactory performance, running natively and supporting cross-platform development. Moreover, Qt Quick provides a rich set of controls out of the box and gives additional improvement for development velocity.
As a result, the Sense1 device based on Raspberry Pi is ready and gathering information about environmental conditions from connected sensors. Qt application is written and running on embedded device.
Next steps—make it production ready. First, the device requires a case, likely to be printed on a 3D printer. Next, the cross-platform development of desktop application for Windows, Linux, MacOS, and mobile application for IOS and Android. The applications will be able to gather information from several WEMs and provide the data to the user for monitoring and analysis. The user will be able to configure Sense1 devices, setting up acceptable ranges for environmental conditions, building diagrams, aggregating data for analysis, as well as create support tickets from applications as necessary for improvement.
Finally, the monitoring and detecting environmental conditions issues are adequate. However, integration with heating and air condition system, humidifier, and light system will help to further fix and adjust the desired measurable values.
The first and hardest initial steps have been completed. The team gained expertise and experience, which will assist in further development of this direction in the future.