Learn how to publish and subscribe to messages sent via an MQTT message broker to be able to remotely control or monitor the status of devices, including Arduino, Raspberry Pi, Android, PC, and Wemos D1.

In this video I’ll demonstrate how to install and setup the Mosquitto MQTT server, available at www.mosquitto.org, on a Windows PC. I’ll then create clients that subscribe to topics on that MQTT broker running on an Arduino UNO (via an Ethernet shield), a WeMos D1 (connected via built-in Wi-Fi), and a Raspberry Pi (connected via built-in ethernet), and control those devices by publishing messages using a command-line PC application and an Android app.

You can access the wiring diagram, additional documentation, and code downloads used in this video at https://www.patreon.com/posts/17921563

00:00 – 05:55 Introduction and Demonstration
05:56 – 07:34 Android client demonstration
07:35 – 13:03 Arduino, Wemos, and Raspberry Pi Wiring
13:04 – 20:01 Installing and testing the Mosquitto MQTT server
20:02 – 37:24 Code for Arduino Ethernet and MQTT client
37:25 – 43:05 Code for Wemos WiFi and MQTT client
43:06 – 48:33 Code for Raspberry Pi MQTT client
48:34 – 50:10 Android client (MQTT Dash)
50:11 – 51:12 Wrapup

, https://i.ytimg.com/vi/VSwu-ZYiTxg/hqdefault.jpg

source

29 Comments

  1. Well done! Clear and concise tuition. I’m moving away from Blynk into MQTT and this was probably the best 'first step’ that I’ve come across. That 'front end' that you spoke of at the end of your talk, I hope that it’s still a likely project. I eagerly await your updates.

  2. Hi Alastair, thanks for taking the time to explain mqtt in detail. I feel you've done a great job explaining it. In your code you reference a pulseCount var, but it's not used elsewhere. Can you explain how you would go about monitoring the heartbeat? I get the frequent publishing of the count and subscribing to it, just unclear as to how you would action an mqtt or WiFi failure. Also, have you had chance to play with micropython on the esp32 and mqtt? Cheers!

  3. I am working on a wrist watch project and need a way to move 1 to 40 Mbyte data files from an Android and iOS mobile device to the watch over Bluetooth Classic. ESP32 drives the watch. Have you seen a solution? -Frank

  4. I have problem with latency @ Arduino Mega + Eth. Shield and @ Wemos D1. If I subscribe for 1 topic, no problem, but 2 – 3 and more topics, and latency grows from miliseconds to minutes and I do not know, where is o problem. 3 x broker @ RPI PI 3+ / 4 + clients @ Uubuntu & Raspbian 32/ 64 – noproblem, problem is only @ Mega and Wemos.

  5. hi,can you explain to me a little bit about MQTT as I'm stuck? I want to send a message from my laptop to node MCU or esp8266. I have an MQTT broker installed on my laptop, so I will use that broker or my self-made server/broker.

  6. kaptan amerika olacakken son anda webtekno recep baltaş olmuş amk

  7. Thank you for this amazing video, Please Could you give me your contact, I have some questions

  8. byte to string : str(msg.payload) must be changed to msg.payload.decode('utf-8')

  9. I guess you need wifi or wired lan connection between the nodes. Maybe using RF is cheaper?

  10. Hiya, Just wanted to know if there is tutorial on how to implement MQTT on Arduino uno with seeedstudio V2.0 wifi shield? Can anyone please help me in this regard?

  11. Great video! Went to Patreon.com and supported you so I could download the software. The globals in CoverUp are too large for the Arduino Uno so I loaded it onto a Arduino Mega. It does not work properly – reconnects every few seconds. Can you help me with this?

  12. Great video. Do you have a C-version of the RPI code? And maybe also a version operating over wifi (still C).

  13. Hi mate!I am working on a project and have customer for the tool to measure radiation from 3-4 detectors that measure radiation and waiting for give it out through rs 485. We connected all this to Raspberry Pi. All is working fine on hardware level. The problem started when our customer requested web based interface to make settings of the monitor. They also requested 10" displaying of radiation levels with 3 thresholds.
    If you could help me to complete this we are ready to pay for this work. For details you can contact me @ yatsiv@specinteh.com.ua
    I am from Ukraine Kyiv.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.