Home Creators Posts Import Register Favorites Logout

Content

As the topic that received the most votes in my recent survey, this video describes how to setup a network in which various puzzle controllers - Arduinos, Raspberry Pis, ESP8266s, and more - can communicate with each other by publishing and subscribing to messages on an MQTT broker. This allows you to monitor the status of puzzles from a central server, or to remotely reset or force-solve them, for example.

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

It's quite a long video, and depending on what hardware you're using not all of it might be relevant to you, so here's a guide to jump to the relevant bits!

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

As ever, please ask any questions or comments below!

Files

MQTT Network Controller

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. 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

Comments

David J Sebek

Just checked out the first 15 minutes, awesome! Thank you so much for publishing this "TOPIC"

David J Sebek

Also, what did you use as your server? Is your connection between your server and your computer wifi? I can't wait to get started on this project.

Sean McQuarrie

Hi Alastair, great job as always. I do have a question regarding the RFID with the D1, I tested the "cover up" sketch with D1 modifying the code where appropriate and got that working correctly. However when trying the RFID puzzle I am getting an error on load ""MFRC522 Software Version: 0x0 (unknown) WARNING: Communication failure, is the MFRC522 properly connected? Scan PICC to see UID, type, and data blocks..." I have tried using a different D1 board, different wires and 3 RFID sensors all with the same issue, I even tested the same sensor, wires with the UNO from your original RFID puzzle and it works fine. Do you know where I might be going wrong? Any help would be highly appreciated.

Sean McQuarrie

Thanks mate, It's a D1 R1. I kept fiddling around and it's working fine when its a single RFID card, I am having an issue with more than 1 (I've tested multiple pins and readers), please let me know if you can test more than 1 sometime. Its not throwing an error, I'm guessing it may be a power issue. Any info whenever you have some time would help, thanks :)

Matt

Hi Alistair - very elegant solution, I have put together the LDR version but using a Nano and of course a different shield/library (Ethernet not wifi). I got it working like yours (eventually) but as I will be building a few of these I would like to make a latching version. Ideally where it can be solved and even if the light source reverts it is still solved until it is reset by a MQTT message. Could you give me a steer on how this might be achieved or has anyone else done it. Thanks

ryan derhammer

Hey Alastair, I'm trying to use the MQTT code to publish to several different topics and not having any luck. For example, I have four buttons and would like the broker to know when each button is pushed and give a value for each button individually. button1, 0 or 1, button2, 0 or 1, etc. and not having any luck figuring out how to have a different topic of each button. Currently, I can send a value for each button state however, it all shows under one topic.