Tuesday, June 12, 2018

Cross-compiling QtMqtt module for Raspberry Pi

A previous post of mine described the Qt module for MQTT protocol, and how to compile it for the Android platform. That seems a good fit to develop a client application for a dashboard for instance, where you can subscribe to different topics and monitor the evolution of such items.
Ok you'll say, but what about creating MQTT publishers, i.e. devices that may have sensors and will provide the readings with MQTT messages?

I think that the Qt MQTT module could be of great help for creating an application that can run on a Raspberry Pi board, allowing to publish via MQTT protocol the readings of sensors (i.e. IMU, temperature, pressure, etc.) connected to the device's GPIO.

So let's say you've already cross-compiled Qt for Raspberry Pi following this guide, getting the Qt MQTT module cross-compiled as well will be very easy task. You need to follow step 16, for example building  module MQTT version 5.10, so from folder ~/raspi you run commands:

git clone git://code.qt.io/qt/qtmqtt.git -b 5.10
cd qtmqtt
~/raspi/qt5/bin/qmake -r 

at this point you'll receive this error:
 
Project ERROR: You cannot build examples inside the Qt source tree, except as part of a proper Qt build
 
we'll deal with that later, let's continue making the module first: 
 
make
make install
 
Then we can deploy the new files of the module (headers and shared library) to the device by running this command from folder ~/raspi:

rsync -avz qt5pi pi@raspberrypi.local:/usr/local
Test everything is fine by building and deploying an example, again from folder ~/raspi:
 
cd qtmqtt/examples/mqtt/simpleclient
~/raspi/qt5/bin/qmake
make
scp simplemqttclient pi@raspberrypi.local:/home/pi

 

No comments:

Post a Comment