• MQTT, or Message Queue Telemetry Transport, is a lightweight publish/subscribe messaging protocol frequently used in IoT applications.
  • The protocol runs over TCP/IP and is designed to be platform-agnostic
  • It is a machine-to-machine communication protocol that uses message multiplexing to transmit data over long distances.
  • The publish/subscribe model is used to implement the MQTT messaging protocol, which is lightweight and dynamic in IoT.
    • In the publish and subscribe principle, a topic is required to publish somewhere else so that subscribers see it, and this is why the publish and subscribe principle is used.
    • A broker connects subscribers and publishers in an effort to facilitate communication between them
    • The publisher can publish its message on a topic and the subscriber can listen to it.
    • The broker is only required to use the same network if the topics are distributed throughout the network.
  • It can provide real-time and dependable messaging services for Internet of Things (IoT) devices in a fraction of the time and bandwidth required by traditional messaging services.
  • MQTT is a protocol that is widely used in the Internet of Things, mobile internet, and in other fields such as electricity.

Messages can be sent and received by any device using MQTT, and we can communicate with other devices in the network the broker receives all messages from publishers (who publish on this server) and sends specific messages to subscribers (devices that view the sensor data published by the publisher)

Node Red MQTT Broker

A MQTT Broker that Is Implemented In Node.js The use of the MQTT open messaging protocol makes it simple for network clients with limited bandwidth to distribute telemetry data.

You can use MQTT-in and MQTT-out nodes without using the Mosquitto environment It is used as a MQTT broker in Node.js. Node is responsible for implementing this MQTT broker. There are no requirements for a Mosquitto-like environment to use because you can use MQTT-in and MQTT-out nodes.

Mosquitto MQTT Broker and Client

The recommended method is to use the Mosquitto package from the official repositories. Install MQTT broker and MQTT client. There are many different clients available, but we recommend using MQTT.fx MQTT.fx installed, open it and click on the “Connect” button. In the “Host” field, enter the IP address of your Raspberry Pi. The default port is 1883, so you can leave that field blank.

Exercises

  • Use the Raspberry Pi as a communication device to send a message from one device to another
  • Create a Raspberry Pi MQTT Broker for your Raspberry Pi
  • Use the pubsub library and ESP8266 to send data from our Raspberry Pi MCU to our MQTT server

References