MQTT Network Controller
HTML-код
- Опубликовано: 16 июл 2024
- 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 / 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 Наука
I wish I had found this video a year or two ago. Nice description of the various different pieces of HW, and SW and how they differ. Well done.!!!
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.
Wonderful explanation! I loved the variation of devices used instead of the typical sole device, as well as the "puzzles"! Keep up the great videos!
Thanks again for a very clear and understandable tutorial. With a few tweeks I managed to do the same with esp32.
you put the puzzle pieces together, good job, well done
Forgot how much I love this channel
Wow. This is a very detailed explanation. Thank you.
This video caught my eye --- long time MC programmer here for industrial controls. I wonder if you've considered the implications at putting something like a Beaglebone Black or another board with PRUs in the mix to control extremely time-sensitive devices/triggers? Great stuff, thanks. I like the way you've presented MQTT here.
Firstly, thanks for the video. It is helpful and you obviously put lots of effort into it.
Just wanted to propose a suggestion. At around 29 minutes or so, you talk about using strings instead of integers for command indices for readability reasons. I would suggest having the best of both worlds: keep an enum with a list of names that correspond to integers. This makes your code safer because when you compile you are not allowed to have typos, and it is just as readable because the enum names, rather than the integer value of each enum, are what is in the code.
The only downside is that the same enum must be defined on all platforms involved in the network, but in my opinion it's worth it.
This is amazing! Great work :)
Oh yes, I forgot to say thank you for the great video - I got a lot out of it.
Good job, clear explanations.
Thank you, just what I was looking for!
Great MQTT video, thank you!
Very clean and ubderstable video! Thank you 🙏
This is a very helpful video! Thanks! You def earned a sub!
super video ...really great!! thank you very much!
Every beginner should see this
Awesome, great work!
Hi (عيد مبارك).
Please if you still have the codes, I am kindly asking you to send them to me at the following address (a_zitouni@hotmail.com). unfortunately the provided link does not work.
Regards.
Thanks, your video is very great
thank you for the great video
Great tutorial.
Excellent, Thanks.
Nice Job!!
Great in depth vid covering 3 different "gadgets" ... Which one would you say it's best from a practicability point of view ? I would probably look into installing some magnetic locks on my shed door , or side garden door etc.. to play about with ..
I've got some pi3's laying about which I used for different applications ... Also would like to incorporate all the other "smart" devices I have in Home Assistant which is already running one a Ubuntu Pi ...
also just want to say great stuff you making.
This is amazing
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!
hi, thanks for great tutorial. I have one question, so, your android app interact directly with MQTT server or through a daemon in the same host of MQTT server?
good one. super
I found this video is fruitful and could learn the concept of MQTT and I have a question on deployment - what is the best practices of deploying the bug-fixes, updates of client software onto MQTT client devices?
Great video, I have not got a chance to watch all of it but it`s a really rare video to see. I was wondering if you could attach a VR shield in order to control the separate relays on the different machines by voice. Also a verification message from each machine back to your pc would be awesome to add, could that be done ?
very nice !
it is ''puzzling'' that you've called them actions '''puzzles''. Anyways...keep up the good work. And by the way, great video.
Yes, as a first time viewer I was also puzzled! It sounds like he's calling an Arduino Sketch a Puzzle? ("it's running a puzzle").
I guess I'll need to look back at some older video's, to understand what he's on about with all the Puzzle references. :-)
This was for an escape room. Escape rooms have physical puzzles.
Ah yes, sorry - the majority of my Raspberry Pi/Arduino projects are used for escape room games, so the "program" they run is the controller for a puzzle. I probably say "puzzle" without thinking about it!
thank you namaste
Nice demo! How could a simply IP PTZ camera be added to use the video and control the Pan, Tilt position from the Raspberry PI(3) and opencv? Thanks.
Thanks
If you like the WeMos D1 mini or any esp8266 board for that matter you will LOVE, love, love the esp32! It runs much faster than any Arduino or Raspberry Pi. It has plenty of analog to digital pins as well as a single digital to analog pin. Three processors, security, deep sleep mode (to conserve battery life), Bluetooth, PWM, Mesh and much more. If you get one then you can replace the Raspberry Pi and then turn the Pi into your MQTT Broker (even a Raspberry Pi zero W will work). One final question that I may have missed. Did you send the message (i.e. payload) back to the MQTT Broker, so if it did not receive the message correctly or if it did not see the message at all the Broker could resend the message?
I've literally got some ESP32s on order as we speak! Re: sending a message receipt - you can certainly do that - you might also want to check out "Quality of Service" (QoS) settings in your MQTT client, which control levels of reliability in delivery.
Great video. Do you have a C-version of the RPI code? And maybe also a version operating over wifi (still C).
Thank you for the great video. I have a question. Can i access to RasPi MQTT broke and control it in defferent WiFI??
For example: I'm in my conpany and use my company wifi. can i use MQTT app that U seggest to control my device at home???
Does anyone know?
If he goes to the client.connect() part of the RaspberryPi. Is it the ip adress from the Pi self or is it from his Windows Computer?
Thanks in advance!
Jens
Wow ! Very nice tutorial ! Love it. Keep it up.
If this is connected to a mikrotik mqtt broker, and mikrotik has snmp, can u monitor the data over network routing through public ips, or gsm with ddns or how should this be done in order to connect it and monitor it through a local server dashboard(grafana or something like this ).
Thank u and great work
Hi, I just found out about your channel. Thanks for all the helpful tips I've already gotten from your videos. I am currently working on a project where I want to implement a MQTT-server. However, since MQTT works with a publish-subscribe principle, there is no real check if the message was received by a subscribed client. In escape rooms I believe this is a crucial part, since you want to make sure that a message has been received. How would you account for this?
I guess you need wifi or wired lan connection between the nodes. Maybe using RF is cheaper?
What UI are you using to diagram the three boards? Thanks!
MQTT for IOT looks the same as OPC for Industrial Automation, tag, topic, subscribe. For IOT I use websockets, js, html which do fine.
Hey Alastair.
Firstly thanks loads for this, it took me ages to get the info to work out how to achieve something similar and your solution is far more elegant. Quick question though, if connection to WiFi/mqtt broker fails would the code get stuck waiting to connect or would the puzzles still function but without reporting to the broker? Couldn't quite follow the program flow at that point. Cheers
Kieran Schlechter That's a good question, and because I was trying to keep the code example simple, I probably didn't make it as robust in that respect as I could have.... What behaviour would you like to happen in that scenario? One feature I didn't demonstrate here is a "heartbeat" message regularly published by all clients that are connected. The server subscribes to the topic that those messages are sent to and, if no pulse is detected from a prop for a certain amount of time either because it fails to connect, the connection is lost, or some other malfunction, a warning can be sent to the control room computer (but the prop otherwise continues to function in "offline" mode as usual). Is that the behaviour you'd want?
Alastair, it wasn't a critisism of the code you posted, I just wasn't sure how it would behave if connectivity was lost. In real application of this I think users would want what you describe above. At the very least the prop should function as normal with or without the MQTT functionality. Networks and servers go down from time to time and it shouldn't affect a game in progress if they do.
I was just looking at the connection sections of code, and wondering if it would get stuck in the connection loop until a connection was established, and therefore prevent the prop from functioning.
Hi Playful Technology,
what a great project! It works properly.
I would like to setup a MQTT project with one ESP32 as a subscriber and another ESP32 as publisher. The broker should be a local RasPi standalone as Broker-Server creating its own WLAN without connection to the Internet via Router or Access Point.
Can you give me hints how to do this?
The handling of the ESP32 should be easy. But with the RasPi I have got my problems to combine the installed Mosquitto and the WLAN-Server capabilities.
Do you have this setup described in one of your courses? (Please without NodeRed.)
Thanks!
Oli
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?
byte to string : str(msg.payload) must be changed to msg.payload.decode('utf-8')
ESP32esp 32 will work as a broker?
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.
Can you do this using node red please!
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
Super cool can you make it a kit
How would you do a keypad
For raspberry pie do u have to setup in a raspberry pie in any way ?
Thanks.
Marc.
Maybe it's too late for an answer but yes, you have to install an operating system, setting up users etc... basically you have to do all the stuff you would do on a normal computer. Because that's what it is. A computer.
To do what was done in this video you also have to install a MQTT broker. There's several option for that, but generally speaking, people use Mosquitto.
Can you speak to the robustness of MQTT for IoT used in these manners where cyber security is in question? It seems that if you know the topics to subscribe to, you can create havoc in an MQTT environment, or is that harder than it seems?
i was reading somewhere that the MQTT Borker might be needed anymore, that its build into node red. is that true?
Yes, you can use one of the Node-RED MQTT server nodes, such as that based on Aedes. Mosquitto is normally considered to be a little bit more robust and feature-rich, but it really depends on your use-case.
Is the Ethernet cable both transmitting data and powering the Arduino?
No, not in this case (although you can get "Power over Ethernet" (PoE) which could be used to do so) - the ethernet is data only and I'm powering the Arduino as normal.
Didn't realize you replied. Thanks a lot for the answer. Your videos are fantastic.... Keep it up.
How to write python code in adruino
i have a stupid question: is it possible to multiple arduino devices connected at same time to the MQTT broker?
They will have different IP's and Mac addys, So yes.
What are puzzles?
If you like the wemos you should order a bunch of ESP32's from china, smaller and cheaper and very powerful! (ESP32 is next Gen of ESP8266).
Can you make this mqtt connection with arduino uno board with esp8266 esp01?
Yep. See here: www.patreon.com/posts/how-to-wi-fi-any-21931879
@@PlayfulTechnology Thank you so much
What the F*** is a puzzle?
Something that needs to be solved.