For our project, we will build a JavaScript client and connect it to an MQTT Broker. We will both Publish and Subscribe to a topic named test. We will then write a small simple program on Raspberry Pi to publish to the topic named test. What this code will demonstrate is how easy it is to send and receive messages using MQTT.
Take a look at the following diagram to see what we will accomplish with this project:
The first step is to set up an MQTT Broker. We may do this by installing one locally using the Mosquitto platform (www.mosquitto.org). What we will do instead is set up a cloud-based MQTT Broker using the website www.cloudmqtt.com.
To set up an account:
- In your browser, navigate to www.cloudmqtt.com.
- Click on
Log in
at the top-right corner. - In the
Create an account
box, type in your email address:
- You will be sent an email to that email address asking you for confirmation. You can complete the confirmation process...