MQTT client

We will create two client applications, one for Raspberry Pi, which will act as the sender (publisher), and one at the server, which will act as the receiver (subscriber). This will help us to implement and better understand the architecture of MQTT. Our implementation will look like the diagram shown in Figure 3.12:

Figure 3.12

Let's write the desktop client application first. We will straight away write the code and not get into the Node.js setup, which we have already done in an earlier part of this chapter:

  1. Create a file with the name desktop_client.js under any folder of your choice; just make sure you have Node.js and its ...

Get Internet of Things with Raspberry Pi 3 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.