Book Image

Python Programming for Arduino

Book Image

Python Programming for Arduino

Overview of this book

Table of Contents (18 chapters)
Python Programming for Arduino
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Getting started with MQTT on Arduino and Python


Now that you have the Mosquitto broker installed on your computer, it means that you have a working broker that implements the MQTT protocol. Our next goal is to develop the MQTT clients in Arduino and also in Python so that they will work as publishers and subscribers. After implementing the MQTT clients, we will have a fully-functional MQTT system, where these clients communicate through the Mosquitto broker. Let's begin with deploying MQTT on the Arduino platform.

MQTT on Arduino using the PubSubClient library

As MQTT is a network-based messaging protocol, you will always need an Ethernet Shield to communicate with your network. For the following exercise, we will continue using the same hardware that we have been using throughout this chapter.

Installing the PubSubClient library

To use Arduino for pub/sub and enable simple MQTT messaging, you need the Arduino client library for MQTT, also known as the PubSubClient library. The PubSubClient...