MQTT Communication With the Nano 33 IoT & WeMos D1 Boards

Published by frenoy on

This post will tell you everything you need to know about MQTT communication which will enable you to use it communicate between devices. We add an LED to the Arduino Nano 33 IoT board and this LED is controlled remotely from a switch that is connected to a WeMos D1 mini board. All communication occurs through the MQTT broker which also communicates with Home Assistant.

Step 1: Watch the Video

A lot of effort has been put into making the video above as we felt that a video is the best way to understand a topic like this. Please take a moment to watch the video to get a better understanding of MQTT and how we will set up the broker, use it and so on.

Step 2: Install & Configure the MQTT Broker

As this involves several steps, it is advisable to watch the video to view how to set this up correctly.

Step 3: Download & Update the Sketches

As mentioned in the video, you can use the sketches linked below to test out your setup. The file below contains two sketches – one for the Arduino Nano 33 IoT board and the other for the WeMos D1 mini board.

https://github.com/bnbe-club/mqtt-communication-diy-34

You will need to add your WiFi network name, and password, along with the MQTT broker details. Please watch the video for more information.

Step 4: Wire the Boards, Upload & Test

Nano 33 IoT Wiring

First, connect an LED to the Arduino Nano 33 IoT board using the reference wiring shown in the image. Once done, you would need to do the following:

  • Install the board support package by using the board manager. Search for “Nano 33 IoT”
  • Install the WiFiNiNa library by using the library manager so that we can use the WiFi module. Search for “WiFiNiNa”
  • Install the PubSubClient library by using the library manager as this is needed for MQTT communication. Search for “PubSubClient”

Then, select the correct board, COM port and upload the sketch. You can open the serial monitor with the baud rate of 115200 to view the board status.

WeMos D1 Mini Wiring

Then, select the correct board along with the board settings as listed in the sketch. Upload the sketch and then open up the serial monitor with a baud of 115200 to view the board status.

The boards should connect to the MQTT broker and pressing the switch should allow you to control the LED remotely. The video shows you how you can test the setup.

Please do consider subscribing to our YouTube channel as it helps us create projects like these.

Thank you for reading!