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
  • НаукаНаука

Комментарии • 93

  • @bgable7707
    @bgable7707 4 года назад +1

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

  • @robertgilbert6963
    @robertgilbert6963 3 года назад +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.

  • @deaneatsgreens
    @deaneatsgreens 4 года назад

    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!

  • @DigiRabit
    @DigiRabit 5 лет назад

    Thanks again for a very clear and understandable tutorial. With a few tweeks I managed to do the same with esp32.

  • @alarmitCreator
    @alarmitCreator 4 года назад

    you put the puzzle pieces together, good job, well done

  • @manyshadesofbrown
    @manyshadesofbrown 3 года назад

    Forgot how much I love this channel

  • @harrywhite7287
    @harrywhite7287 4 года назад

    Wow. This is a very detailed explanation. Thank you.

  • @davidhargrove5181
    @davidhargrove5181 6 лет назад +4

    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.

  • @hesperaux
    @hesperaux 6 лет назад +1

    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.

  • @NoviceRobot
    @NoviceRobot 6 лет назад

    This is amazing! Great work :)

  • @quantumsensing9032
    @quantumsensing9032 6 лет назад +1

    Oh yes, I forgot to say thank you for the great video - I got a lot out of it.

  • @kees-ft1yb
    @kees-ft1yb 4 года назад +1

    Good job, clear explanations.

  • @JavoCover
    @JavoCover 3 года назад

    Thank you, just what I was looking for!

  • @georgeboydratcliff1036
    @georgeboydratcliff1036 2 года назад

    Great MQTT video, thank you!

  • @PeterMisovicProfile
    @PeterMisovicProfile 3 года назад

    Very clean and ubderstable video! Thank you 🙏

  • @Geeksmithing
    @Geeksmithing 3 года назад

    This is a very helpful video! Thanks! You def earned a sub!

  • @winfridfluggen5047
    @winfridfluggen5047 6 лет назад

    super video ...really great!! thank you very much!

  • @medilies
    @medilies 4 года назад

    Every beginner should see this

  • @mohamedfaroukel-alem7253
    @mohamedfaroukel-alem7253 6 лет назад

    Awesome, great work!

    • @zitouniabdelkader8868
      @zitouniabdelkader8868 3 года назад

      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.

  • @XuanKyAutomation
    @XuanKyAutomation 4 года назад

    Thanks, your video is very great

  • @franciscosolis5027
    @franciscosolis5027 3 года назад

    thank you for the great video

  • @1977Arcademan
    @1977Arcademan 2 года назад

    Great tutorial.

  • @harrywhite7287
    @harrywhite7287 3 года назад

    Excellent, Thanks.

  • @KaiBuskirk
    @KaiBuskirk 4 года назад

    Nice Job!!

  • @TheRealAnthony_real
    @TheRealAnthony_real 5 лет назад

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

  • @Lennings82
    @Lennings82 8 месяцев назад

    also just want to say great stuff you making.

  • @hamhish4222
    @hamhish4222 3 года назад

    This is amazing

  • @davecobb5649
    @davecobb5649 3 года назад +1

    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!

  • @JanieLe2109
    @JanieLe2109 6 лет назад

    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?

  • @PremkumarD
    @PremkumarD 3 года назад

    good one. super

  • @SenthilKumar-vu7mf
    @SenthilKumar-vu7mf 4 года назад

    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?

  • @djnec4
    @djnec4 5 лет назад +1

    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 ?

  • @iamcalledusman
    @iamcalledusman 2 года назад

    very nice !

  • @ovi_4
    @ovi_4 6 лет назад +3

    it is ''puzzling'' that you've called them actions '''puzzles''. Anyways...keep up the good work. And by the way, great video.

    • @gregclare
      @gregclare 6 лет назад +2

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

    • @blackphidora
      @blackphidora 6 лет назад +2

      This was for an escape room. Escape rooms have physical puzzles.

    • @PlayfulTechnology
      @PlayfulTechnology  5 лет назад +1

      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!

  • @Skookumshroom
    @Skookumshroom 4 года назад

    thank you namaste

  • @qzorn4440
    @qzorn4440 5 лет назад

    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.

  • @dannymagat
    @dannymagat 4 года назад

    Thanks

  • @vonries
    @vonries 6 лет назад +3

    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?

    • @PlayfulTechnology
      @PlayfulTechnology  6 лет назад +2

      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.

  • @hammershigh
    @hammershigh 4 года назад

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

  • @SonNguyen-ux8zl
    @SonNguyen-ux8zl 4 года назад

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

  • @XilumX1
    @XilumX1 5 лет назад +1

    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

  • @cgeorgevitch67
    @cgeorgevitch67 Год назад

    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

  • @dionzand
    @dionzand 9 месяцев назад

    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?

  • @PabloPazosGutierrez
    @PabloPazosGutierrez 3 года назад

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

  • @17573240
    @17573240 3 года назад

    What UI are you using to diagram the three boards? Thanks!

  • @dasdunetechnologies1695
    @dasdunetechnologies1695 4 года назад

    MQTT for IOT looks the same as OPC for Industrial Automation, tag, topic, subscribe. For IOT I use websockets, js, html which do fine.

  • @munk3ystump
    @munk3ystump 6 лет назад

    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

    • @PlayfulTechnology
      @PlayfulTechnology  6 лет назад

      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?

    • @munk3ystump
      @munk3ystump 6 лет назад

      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.

  • @os-channel
    @os-channel 10 месяцев назад

    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

  • @awaisahmed302
    @awaisahmed302 3 года назад

    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?

  • @JeanDAVID
    @JeanDAVID 3 года назад

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

  • @madhusudhang8254
    @madhusudhang8254 5 лет назад

    ESP32esp 32 will work as a broker?

  • @usamakhan-yi9fb
    @usamakhan-yi9fb 3 года назад

    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.

  • @PepeSi7via
    @PepeSi7via Год назад

    Can you do this using node red please!

  • @starlingwatch3921
    @starlingwatch3921 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

  • @KaiBuskirk
    @KaiBuskirk 3 года назад

    Super cool can you make it a kit

  • @tyson_gaming1013
    @tyson_gaming1013 2 года назад

    How would you do a keypad

  • @MPElectronique
    @MPElectronique 5 лет назад

    For raspberry pie do u have to setup in a raspberry pie in any way ?
    Thanks.
    Marc.

    • @jean-naymar602
      @jean-naymar602 5 лет назад

      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.

  • @quantumsensing9032
    @quantumsensing9032 6 лет назад

    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?

  • @Lennings82
    @Lennings82 8 месяцев назад

    i was reading somewhere that the MQTT Borker might be needed anymore, that its build into node red. is that true?

    • @PlayfulTechnology
      @PlayfulTechnology  7 месяцев назад

      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.

  • @K10Eddy
    @K10Eddy 6 лет назад

    Is the Ethernet cable both transmitting data and powering the Arduino?

    • @PlayfulTechnology
      @PlayfulTechnology  6 лет назад

      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.

    • @K10Eddy
      @K10Eddy 5 лет назад

      Didn't realize you replied. Thanks a lot for the answer. Your videos are fantastic.... Keep it up.

  • @PremkumarD
    @PremkumarD 3 года назад

    How to write python code in adruino

  • @lassegamingdk
    @lassegamingdk 5 лет назад

    i have a stupid question: is it possible to multiple arduino devices connected at same time to the MQTT broker?

    • @DrexProjects
      @DrexProjects 5 лет назад

      They will have different IP's and Mac addys, So yes.

  • @wangouthangout
    @wangouthangout 4 года назад

    What are puzzles?

  • @stewartrv
    @stewartrv 6 лет назад

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

  • @afifahmahin8137
    @afifahmahin8137 3 года назад

    Can you make this mqtt connection with arduino uno board with esp8266 esp01?

    • @PlayfulTechnology
      @PlayfulTechnology  3 года назад +1

      Yep. See here: www.patreon.com/posts/how-to-wi-fi-any-21931879

    • @afifahmahin8137
      @afifahmahin8137 3 года назад

      @@PlayfulTechnology Thank you so much

  • @KarlMiller
    @KarlMiller 4 года назад

    What the F*** is a puzzle?