Understanding the requirements to control a vehicle with MQTT

In the previous three chapters, we learned how MQTT works in detail. We understood how to establish a connection between an MQTT client and an MQTT server. We learned what happened when we subscribed to topic filters and when a publisher sent messages to specific topics. We installed a Mosquitto server and then we secured it.

Now, we will use Python as our main programming language to generate MQTT clients that will act as publishers and subscribers. We will connect a Python MQTT client to the MQTT server and we will process commands to control a small vehicle with MQTT messages. The small vehicle replicates many capabilities found in real-life road vehicles.

We will use TLS encryption and TLS authentication because we don't want any MQTT client to be able to send commands to our vehicle. We want our Python 3.x code to run on many platforms because we will use the same code base to control vehicles that use the following IoT boards:

  • Raspberry Pi 3 Model B+
  • Qualcomm DragonBoard 410c
  • BeagleBone Black
  • MinnowBoard Turbot Quad-Core
  • LattePanda 2G
  • UP Core 4GB
  • UP Squared

Depending on the platform, each vehicle is going to provide additional features because some boards are more powerful compared to other boards. However, we will focus on the basic features to keep our example simple and stay concentrated on MQTT. Then, we will be able to use this project as a baseline for other solutions that require us to run code on an IoT board that runs Python 3.x code, has to connect to an MQTT server, and processes commands.

The code that runs on the boards that power the vehicles must be able to process commands received in messages on a specific topic. We will use JSON strings in the payloads.

A client application also written in Python must be able to control one or more vehicles. We will also write the client application in Python and it will publish MQTT messages with JSON strings to the topic for each vehicle. The client application must display the results of executing each command. Each vehicle must publish a message to a specific topic whenever a command is successfully executed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.41.187