Sending messages with Python

So far, we have been publishing MQTT messages to control the vehicle with GUI and command-line tools. Now, we will write code in Python to publish the commands to control each vehicle and check the results of the execution of these commands. Of course, GUI utilities, such as MQTT.fx and the Mosquitto command-line utilities, are extremely useful. However, after we know that things are working as we expect, we can write the necessary code to perform tests in the same programming language we are using to run the code on the IoT board.

Now, we are going to code a Python client that will publish messages to the vehicles/vehiclepi01/commands topic and will subscribe to the vehicles/vehiclepi01/executedcommands topic. ...

Get Hands-On MQTT Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.