Easy MQTT Server Setup

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi you seem to like the home automation project so let's do more of them then qtt protocol is a good solution since it's providing an easy communication between many IOT nodes the central piece is a broker a node connects to the broker and can subscribe to topics the topics are created automatically it can also publish to topics any kind of data the broker distributes the data to any node that has subscribed to that the publishing can be done at 3 quality levels messages are delivered at most once at least once exactly once at rising communication overhead so let's set up such an amputee key broker in our home Network we can use the mosquito MQTT broker on a Linux mini computer mosquito seriously who came up with that name this is really repulsive I hate mosquitoes we can take the raspberry I think it might be even revision one I never did anything with it what else do we need an SD card and a power supply should do we also need a keyboard and mouse and is free to set it up first of all we need to prepare a system image but you can skip this step if you already have one running we can download the system image from here and use a chart to burn it to the SD card the current image with a graphical user interface needs at least an 8 gig SD card h ax is available for different operating systems we can download it here the links can be also found on the project page which is linked in the description there is no need to extract a huge image of the downloading HR supports also zip files I put my SD card in start HR select the downloaded image and confirm the SD card will be completely overwritten so don't use that one with the wedding pictures on it by default a Chauhan's to validate the image it might fail there don't bother I got this every single time for that image it still works fine we can even turn off the validation in the settings writing the image takes a while so grab a cup of coffee and connect the raspberry to your network screen keyboard and mouse put the SD card in your raspberry and connect it to the power via USB or another five volt power supply when it's booted you simply open the terminal and type sudo apt-get update in sudo apt-get install mosquito that's it the brokers up and running it's also automatically started whenever your rasberry is powered up the host address is the IP of the raspberry you can get it if you type ifconfig the pot is 1883 by default and you can access the broker without a username and password like that it works without any problems if you just want to try things for small tests I made two notes that are playing ping pong over mqtt but wait we have to make it a little bit more bulletproof by fixing the IP and adding users and passwords the IP address of the raspberry pi is not really fixed our router assigned that IP to our raspberry not really permanently it probably will get the same address every time but that's not guaranteed the raspberry might also be reached with the host name raspberry pi dot local but a problem here is that not all systems support multicast dns so we might need to fixed IP as fallbacks anyways to let the router give the raspberry the same IP address every single time we have to tie it to the MAC address of the raspberry which is unique to do this we have to login into the router using a browser the default address and login is often shown on the back side of the device if not you might try 198 dot 168 dot zero dot one if this doesn't work you have to search the internet for your specific model locked in we have to find a list with the connected clients there is the raspberry and it's MAC address now we have to find the DHCP settings the DHCP server assigns the IPS there you can either type the MAC address manually and the IP address you like or you might even get a convenient option to select the connected device directly and apply now our Raspberry Pi should get the same IP address every time we can repeat this also for our IOT devices like the ESP modules this way we can label them and access them easily remotely whoo I know this part was really dull hang on we are almost there this is just something we have to do once after that automating our home is a piece of cake now let's add a minimum of security to our MQTT broker with anonymous access anyone in our local network and mess around with our stuff so let's protect the broker by adding a password file like this we open the terminal again change the directory CD / e TC slash mosquito and type sudo mosquito on a scope a swift - C - create password file Looney as the first user adding another user can be done with the option - B we can also type the password directly in the command line like this removing users can be done with the option - D using this command line tool our passwords are stored non readable in the password file to enable the user file we need to change the configuration file of mosquito therefore we need to open it in an editor sudo nano mosquito conf and we add the lines hello underscore anonymous false password underscore file slash EDC slash mosquito slash password file ctrl o and return to store the file ctrl X to exit Donal the simplest way to apply the changes is to reboot from now on any connections will be refused without a valid username and password there are also some features to support secure connections to our broker but that is a topic for another day now that the MQTT broker is up and running we can start creating cool home automation projects i'm also updating my devices like the main switch to Mongoose OS and MQTT the MQTT support is built-in it can't get any simpler than that and it's also really responsive the setup details code parts apps can be found on the project page which is linked in the description coming up next will be how to make a cheap S washing machine smart subscribe to not miss it and also check out my other projects see you soon [Music]
Info
Channel: bitluni
Views: 206,551
Rating: undefined out of 5
Keywords: raspberry pi, mqtt, microcontroller, esp32, esp8266, home automation, switch, remote, IoT, internet of things, easy, tutorial, diy, smart, broker, iot, mosquitto, raspberry, arduino, iot server, home, automation, how to, wifi, technology, server, android mqtt
Id: OOqS8fhd6ck
Channel Id: undefined
Length: 7min 35sec (455 seconds)
Published: Sat Sep 23 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.