MQTT with a Raspberry Pi and an Arduino

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 มิ.ย. 2024
  • MQTT allows data to be sent from IoT devices to smartphones or up to the cloud. DEAL $19 - Linux Power User Bundle deal: andauth.co/LinuxPowerUserBund...
    MQTT (MQ Telemetry Transport) can be used on microcontrollers like the Arduino or on boards like the Raspberry Pi. Here is a full overview and DEMO using Android, Mosquitto on Raspberry Pi, and an Arduino.
    Arduino code: github.com/garyexplains/examp...
    Introduction to Android app development: www.dgitacademy.com
    Let Me Explain T-shirt: teespring.com/gary-explains-l...
    Twitter: / garyexplains
    Instagram: / garyexplains
    #garyexplains

ความคิดเห็น • 98

  • @jasonpluis3493
    @jasonpluis3493 4 ปีที่แล้ว +10

    OMG. Best explanation of mqtt I have seen.

  • @JoseFernandez-yz1sf
    @JoseFernandez-yz1sf 4 ปีที่แล้ว +3

    Very good explanation on MQTT. I will try to set something here at home. Many thanks Gary

  • @fa77y
    @fa77y 3 ปีที่แล้ว

    That was great! Thanks for making this video. I can't wait to start using this in my projects!

  • @skd5432
    @skd5432 2 ปีที่แล้ว +1

    The best and wonderful MQTT related overview.....

  • @ruizheshang4808
    @ruizheshang4808 3 ปีที่แล้ว

    Insanely cool and helpful video, thanks Grey! 👍👍

  • @minibigs5259
    @minibigs5259 4 ปีที่แล้ว +7

    Yeeees. More please..... (Node red, Grafana)
    Docker explained by you would be awesome too.

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว +2

      Did you see this video of mine about Docker? th-cam.com/video/nBwJm0onzeo/w-d-xo.html

    • @minibigs5259
      @minibigs5259 4 ปีที่แล้ว

      @@GaryExplains Missed that Gary. Cheers :-)

  • @johnxisde
    @johnxisde 3 ปีที่แล้ว +1

    Amazing gary! thanks for that

  • @levon9
    @levon9 4 ปีที่แล้ว

    Very nicely done - thank you!

  • @callmereno
    @callmereno ปีที่แล้ว

    Soo well explained! Thank u!

  • @highend5358
    @highend5358 3 ปีที่แล้ว

    Amazing!! Such a nice tutorial!

  • @Rocksetta
    @Rocksetta 3 ปีที่แล้ว

    @Gary any idea if Mosquitto can be compiled to run on any of the new Arduino's?

  • @moeyali123
    @moeyali123 29 วันที่ผ่านมา

    Thanks mate, I will setup MQTT

  • @subhankarmahapatra5492
    @subhankarmahapatra5492 4 ปีที่แล้ว

    Inspiringly explained 👏

  • @julienbietlot3401
    @julienbietlot3401 4 ปีที่แล้ว +2

    Hello Gary, great content. I believe it is 2 roles not modes... (pub/sub). Also topics should be represented the other way around: bulbstatus/on not on/bulbstatus or should be in fact topic=bulbstatus payload=on in the form topic:payload.For mosquitto_sub the -v add the topic name back uppon change. Thumb up !!

  • @saynlee
    @saynlee 3 ปีที่แล้ว

    From this video, I became known mqtt broker, Thank you Gray Explains

  • @Virtualangello
    @Virtualangello 3 ปีที่แล้ว +3

    Best tutorial ever!

  • @TheUncle79
    @TheUncle79 4 ปีที่แล้ว +1

    hi,
    I'm trying to configure arduino to be able to use the mqtt protocol to communicate on a web platform. Do you have any idea?

  • @thaernejem7317
    @thaernejem7317 4 ปีที่แล้ว

    great one, totally like it

  • @1MarkKeller
    @1MarkKeller 4 ปีที่แล้ว

    *GARY!!!*
    *Good Afternoon Professor!*
    *Good Afternoon Fellow Classmates!*

  • @uvatham
    @uvatham 4 ปีที่แล้ว

    Please make a video on "ROS".

  • @sammckenzie2331
    @sammckenzie2331 4 ปีที่แล้ว

    Gary, why do most light bulbs and many other IoT devices use Zigbee or Z-Wave instead of mqtt?

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว

      MQTT is a protocol that runs over TCP/IP, meaning over Wi-Fi for wireless setups. Zigbee isn't a replacement for MQTT pe se, but rather a replacement for the Wi-Fi bit, but once you replace the lower layers then the upper layers have to change as well, so MQTT (in its native form) won't run over Zigbee.

  • @RegisMichelLeclerc
    @RegisMichelLeclerc ปีที่แล้ว

    Interesting, but that's just the easy part. The objection about DHCP doesn't really stand because you will need to make a difference between the living room bulb and the one in the toilet!
    Thus, it might have been interesting to detail further the kind of code you put on the Arduino to control many devices of different kinds (such as heating, fan, bulbs, mains sockets, etc.) and show how to differenciate each device at the device level. At the computer level (here Raspberry Pi, but can be anything, really), it's always simple, at the sensor level... not so.

  • @dineshbobburu4743
    @dineshbobburu4743 3 ปีที่แล้ว

    Great Explanation!! If we consider real time scenario and if we are making a product then how are we gonna connect esp32's acting as a subscriber to the Raspberry PI acting as MQTT broker, as the esp32 code can't be updated again and again when IP address of broker change, can you please clarify this doubt and mobile app will be interacting with the MQTT broker as publisher to MQTT broker, Thanks in advance...

  • @os-channel
    @os-channel 9 หลายเดือนก่อน

    Great clip!
    One question: Is the RasPi directly connected to the Arduino via WiFi or is the a Router between?
    Regards
    Oli

    • @GaryExplains
      @GaryExplains  9 หลายเดือนก่อน +1

      Via a router.

  • @edhalferty
    @edhalferty 4 ปีที่แล้ว

    Greets from California!

  • @ganeshshetepatil9829
    @ganeshshetepatil9829 3 ปีที่แล้ว

    Very nice explanation. Thanks.
    Can you please tell how data is getting transferred from Arduino to Android or Rasberry pie. I mean the physical communication media over which these topics are transferred.

    • @rahulj2167
      @rahulj2167 2 ปีที่แล้ว +1

      I think there is a connection settings where you can specify device connections. Strange that part was omitted.

    • @wayland7150
      @wayland7150 ปีที่แล้ว +1

      It's just TCP/IP.

  • @warrenscorner
    @warrenscorner ปีที่แล้ว

    Great tutorial Gary! I was able to setup my Raspberry Pi as my MQTT broker. I have one Arduino 33 iot with a door switch and another Arduino Uno WiFi with a sim7000 hat. When my door switch is open the sim sends me an sms. Awesome!
    Is there an app I can install on my iPhone that I can send info back to the broker?

  • @thorsten9211
    @thorsten9211 4 ปีที่แล้ว

    woud love to see a small tutorial in python or c++ :)

  • @JoelJosephReji
    @JoelJosephReji 4 ปีที่แล้ว +1

    hey why was it that the first hello message did not have any quotes wrapped around but the following messages had quotes around them

  • @nevineasfour4963
    @nevineasfour4963 ปีที่แล้ว

    please I face a problem I don't know what is the black screen you use I tried to use visual studio but it doesn't work

  • @AndersJackson
    @AndersJackson 4 ปีที่แล้ว

    Actually, MQTT server doesn't need to have a fixed address. You can use mDNS to find the MQTT server.
    For real use, you should also do encryption and use passwords.

    • @ovalwingnut
      @ovalwingnut 2 ปีที่แล้ว +1

      Unless you are stealing your neighbors WiFi and you don't want nDNS giving away the scam. The devil is in the details. Cheers AJ

    • @AndersJackson
      @AndersJackson 2 ปีที่แล้ว

      @@ovalwingnut well, I don't steal neighbors WiFI, so that is not a problem for me. :-)

  • @FlyRenegade_
    @FlyRenegade_ 4 ปีที่แล้ว

    Does the arduino have an ip address?
    Is the arduino able to communicate over http?

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว

      Yes and yes. Have you seen this video of mine on that very subject? th-cam.com/video/lRV-TaHSWUk/w-d-xo.html

  • @DAVIDGREGORYKERR
    @DAVIDGREGORYKERR 3 ปีที่แล้ว

    should the command to run mosquitto be ./mosquitto unless it is a python script.

  • @unclerojelio6320
    @unclerojelio6320 2 ปีที่แล้ว

    Which arduino model is that?

  • @maro1977pl
    @maro1977pl 2 ปีที่แล้ว

    Whether arduino can work in case of loss of connection with the MQTT broker?

    • @wayland7150
      @wayland7150 ปีที่แล้ว

      If the Arduino button is used to turn on the LED then you could simply do that in Arduino code in the button press code. You'd still publish the LIT status but you'd not know if it was received.

  • @ovalwingnut
    @ovalwingnut 2 ปีที่แล้ว

    Don't hope... I DID! Enjoy it that is. Thanks so much (and where are you that it's snowing. No disrespect to the England, but snow, seriously).

  • @gidimiz
    @gidimiz 4 ปีที่แล้ว

    Great video, thanks.
    How can you connect to the MQTT outside home?
    I can use DuckDNS to reach my raspberry, but how can I make it secure connection without using VPN every time?
    Is there another free MQTT server that's relay messages?
    Any other options?

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว +2

      Mosquitto supports user/password authentication and TLS.

    • @gidimiz
      @gidimiz 4 ปีที่แล้ว

      @@GaryExplains I would love to see a video on how to do this so I can control and also get notification (pop up ) on the Android phone. Thanks.

  • @sohampatel7636
    @sohampatel7636 4 ปีที่แล้ว +1

    I cannot sign up for your newsletter from website. Please help. By the way great content sir. Appreciate it

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว +1

      Glad you like the content. Sorry to hear you are having trouble signing-up for the newsletter. What is the exact problem? Is there an error?

    • @sohampatel7636
      @sohampatel7636 4 ปีที่แล้ว

      @@GaryExplains It first takes a while to load and then says" Site can't be reached" after i enter my email and press sign-up button on website.

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว +1

      @@sohampatel7636 I just tried it and it worked perfectly. Sounds like you have a local Internet problem.

  • @112BALAGE112
    @112BALAGE112 4 ปีที่แล้ว

    You mentioned the use of an alarm system. Is it a good idea to run an alarm system on MQTT? Is it fast/secure/reliable enough? Can the MQTT server be configured to persistently and accurately keep logs of important alarm events? Is it possible to use MQTT in authenticated mode, as to protect against message spoofing?

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว +1

      I guess I was thinking more about asking an alarm system about it current status or status of the various sensors. For actual alarm triggers (window opened) or alarm actions (like starting a siren etc) then I don't think MQTT would be the best solution.

    • @kamran_aghlami
      @kamran_aghlami 4 ปีที่แล้ว

      There is username and password authentication and you can use SSL encryption (TLS v1.2) on top of that. And some mqtt servers (emqx) allow you to have permission based subscribing and publishing as well, I don't know about the industry standards but I think these features make mqtt very secure.

    • @kamran_aghlami
      @kamran_aghlami 4 ปีที่แล้ว

      And there are other topics like persistence and quality of service to make things reliable, and if you are not planning to stream video mqtt is pretty fast. You can send pictures and even files in general, you would have to handle the encode/decode to base64 and back though

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว +1

      @@kamran_aghlami The real issue isn't authentication / security, but guaranteed delivery, something you don't get with MQTT as there are no queues.

    • @kamran_aghlami
      @kamran_aghlami 4 ปีที่แล้ว

      @@GaryExplains Doesn't quality of service (QOS2) address that?

  • @samkaxe2488
    @samkaxe2488 ปีที่แล้ว

    any idea how to send data from pi to arduino :D

  • @bhushann2356
    @bhushann2356 4 ปีที่แล้ว

    IBM's MQ comes from Message Queue

  • @rohanjoshi8420
    @rohanjoshi8420 4 ปีที่แล้ว

    Sir can you make more video of implementation of MQTT and creating webapp or android app from scratch to control rasberry pi or Arduino based IoT device and I am also want to how to connect it Google home and add my IoT device in Google home app. I am trying to find it but I am not get much resources on it can please make videos or share some resources it will help me a lot and once again Thank you sir.

  • @Flankymanga
    @Flankymanga 4 ปีที่แล้ว

    @Garry: Out of curiosity where did you film the first couple of seconds? Which country were you in? Was that some Slavic country (a question out of curiosity)?

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว

      Didn't you hear that curiosity killed the cat!

    • @Flankymanga
      @Flankymanga 4 ปีที่แล้ว

      @@GaryExplains Not me:) Im still alive and well :) Anyway thanks for the video!

  • @ttssoon1975
    @ttssoon1975 3 ปีที่แล้ว +1

    "MQ " stand for message query.

  •  4 ปีที่แล้ว +4

    Neither snow nor rain nor heat nor gloom of night stays these couriers from the swift completion of their appointed rounds.

  • @jzilla1234
    @jzilla1234 4 ปีที่แล้ว

    Where is it snowing?

  • @meltonenterprises6761
    @meltonenterprises6761 3 ปีที่แล้ว

    A+

  • @dmbrv
    @dmbrv 4 ปีที่แล้ว

    great video :)

  • @power-max
    @power-max 4 ปีที่แล้ว

    Is there a limit to the payload size? Can I send entire JUMBO ethernet frames or JSON or messagepack packets through it?

    • @GaryExplains
      @GaryExplains  4 ปีที่แล้ว

      The max message size is 256MB.

    • @power-max
      @power-max 4 ปีที่แล้ว

      @@GaryExplains Wow I could probably stuff my thesis down that! (at least in plaintext 😅)

  • @samot56498
    @samot56498 3 ปีที่แล้ว

    Is possible in this project use ESP8266, instead of MKR1000? Maybe is somebody make this?

    • @GaryExplains
      @GaryExplains  3 ปีที่แล้ว +1

      Should work without any problems.

    • @samot56498
      @samot56498 3 ปีที่แล้ว

      @@GaryExplains Ok I will try. Thank you very much for fast answer. :)

  • @lezbriddon
    @lezbriddon 3 ปีที่แล้ว

    ok so ''great cooking inc'' has a magazine called "good food" it Publishes, and this months is "good food" "great burger recipe's"
    Now joe blogs subscribes to this 'magazine' "good food" and so very soon he is going to get "good burger recipes" (payload?) - but the question is this, how does he receive it, does the postman bring it ring the doorbell and hand it over or does he have to walk to the magazine store periodically and see if its in stock yet? IE does the broker push messages, or is it polled for them?

    • @wayland7150
      @wayland7150 ปีที่แล้ว

      The point about subscribing is that you get the message automatically, you don't have to keep checking. By subscribing with the Broker they know to notify you when that publication comes in to them.

    • @lezbriddon
      @lezbriddon ปีที่แล้ว

      @@wayland7150 but what's the procedure of that, some handshake must go on ?

    • @wayland7150
      @wayland7150 ปีที่แล้ว

      @@lezbriddon It's a while since I used MQTT so I don't know if you get an error if the Broker is disconnected. I expect you do. However it's not really a handshake type of protocol. You'd not toggle something on and off, you'd send an ON signal if you wanted it on and an OFF signal if you wanted it off. Expect not to get a 'message received and understood'. If it's status then the sensor would simply send the signal every few minutes and send the signal on change of state to say what state it's actually in.

  • @stechnicalexpert7983
    @stechnicalexpert7983 4 ปีที่แล้ว

    Raspberry networking expert need please help

  •  4 ปีที่แล้ว

    So mqtt is like reddit :-), you select a topic, subscribe to it, and send/receive messages on that topic on a server.

  • @eamonhannon1103
    @eamonhannon1103 2 หลายเดือนก่อน

    Confusing Demo ! Need to explain the setup and try not to to be running Publisher and Subscriber on the same device .No explanation of how the Ardiuno is connected with the Raspberry PI . Confusing !

    • @GaryExplains
      @GaryExplains  2 หลายเดือนก่อน

      Sorry to hear that. I thought the video contained all the pertinent information. The devices are connected via WiFi. If you have specific questions I am happy to try and help. Maybe rewatch the video note the timecode where you have questions and let me know.