Have you got the next big idea of smart IoT implementation but not clear about how and where to start?
Everything you need to get started with your IoT implementation is here. We have made a recent update on MQTT Broker version 3.3. The new version comes with Mobile app support which makes the MQTT Broker more scalable for any IoT implementation. With the new update any budding developers or early adopters who are intended to take advantage of smart automation can make a successful smart IoT implementation faster & easier. This article provides a detailed view on how to perform an effective IoT implementation with Raspberry pi MQTT Broker.
An Exclusive FREE Raspberry Pi MQTT Broker
Every IoT implementation or application development needs a specific components combined together to achieve your specific target successfully.
In that case, any smart IoT implementation needs 4 basic components
IoT devices (sensors or actuators)
IoT middleware (MQTT Broker)
Automation Platform or HUB (Home Assistant or OpenHAB) If required
Smart Phone APP
And that is why we developed an exclusive MQTT Broker package which acts as a middleware to communicate between your MOTT enabled devices along with the mobile application, home automation platform integration & more…
We want to ensure that this package should be feasible to develop any sort of smart IoT implementations and people could get their things ready in their budget. And we make this MQTT Broker package specifically available in raspbian OS for FREE, as the Raspberry Pi can be an inexpensive and powerful one suits for all your IoT implementations. This could really be an excellent solution/benefit for those who aren’t comfortable with the premium licensing of most commercial solutions / platforms in the market.
Get your IoT devices ready
The selection of your IoT / edge devices or sensors depends on your implementation. To give you an idea, let us consider a smart home implementation. You need a light sensor, temperature sensor, door sensor & more. This varies upon your needs. With our FREE MQTT Broker package you can connect upto 10 MQTT enabled devices or sensors.
Set up the MQTT Broker on Raspberry pi
Start setting up the raspberry pi by using the below steps.
Step 1: Install Raspbian OS in your Raspberry Pi (choose the one which best suits your need)
Step 2: Get the SD Card and the Card Reader
- Get a minimum 8GB class 10 SD card with a card reader. Insert that card into the card reader and plug that to the USB port.
Step 3: Check the Drive in Which the SD Card Is Mounted
- Go to my computer or My PC and find the drive name where the SD card is mounted.
Step 4: Format the SD Card
- Open SD Card Formatter and select the drive you noticed in the previous step.
- Click on format and don’t alter any other options.
- When the formatting is completed, click on OK.
Step 5: Write the OS on the SD Card
- Open win32diskimager.
- Browse the .img file of Raspbian OS that was extracted from the downloaded file.
- Click ‘on open’ and then click ‘on Write’. If any warnings pop up then ignore them by clicking OK. It will only take a few minutes.
Step 6: Eject the SD Card
Now your OS is installed on your Raspberry Pi.
Installing MQTT Broker in the Raspberry Pi
1. Before installing the MQTT broker to our Raspberry Pi, we need to update the operating system.
All we need to do to update the system is to run the following two commands in the terminal
sudo apt update
sudo apt full-upgrade
2. Once the system has finished updating, we can now install the MQTT Broker software.
Download our exclusive Raspberry pi MQTT Broker from the below link and it might get downloaded in a zip format.
Unzip the broker file and then open terminal and run the broker
During the installation process, the package manager will automatically configure the Broker to start on boot.
3. At this point, you will now have the MQTT broker up and running on your device.
You can verify that it is installed and running by using the command below.
sudo systemctl status broker
This command will return the status of the “broker” service.
You should see the text “active (running)” if the service has started up properly.
By default broker will start running at http://localhost:8080 or http://<your IP>:8080. The default credentials to login to the dashboard is
- Username – admin
- Passsword – admin
Now start connecting your IoT devices / sensors from the UI itself.
In order to connect your devices more securely, enable authentication inside broker.conf folder. The default location of conf will be Bevywise/MQTTRoute/conf.
AUTHENTICATION_ENABLED = YES
# YES || NO
Save your changes and rerun the MQTT Broker. Now you will be able to see the security tab on the default dashboard.
The authentication keys present there can be used to connect your IoT devices. You can also generate a new one to connect.
You can view the status of your device once you get your devices connected & data published by it on the dashboard. You can create your own dashboard with pre-built widgets to visualize the data published. To know more on Dashboard usage and other MQTT Broker feature & how to control your connected devices, visit MQTT Broker help.
Integration with Automation Platform
This part is especially for home users who are intended to develop their home automation system. Building your automation system completely from scratch will be a little bit unrealistic for DIY users. That is why there are number of home automation platforms / frameworks available in the market that can get your home automation devices up and running in no time.
The two of the most used open source home automation platforms includes
As I said before, home automation platform can provide everything you need to develop your home automation system. You may ask, what is need of MQTT Broker here??…We have got you covered. Remember that your IoT devices / sensors are MQTT enabled and the initial step to get started with the Home automation platform is to complete MQTT integration with it. Ergo, you need an MQTT Broker for MQTT integration with automation platform.
That being so, Bevywise MQTT Broker supports integration with both Home Assistant & Open HAB.
Once you are ready with the MQTT Broker on Raspberry pi set up, starts integrating with Home Assistant / Open HAB.
Check out the integration steps below.
Home Assistant Integration
The first step is to complete the Home Assistant installation procedure.
You can check the installation steps here
Make sure you download the right package for Raspbian OS.
Once your installation steps are done, you can go ahead with the integration part.
Navigate to the http://homeassistant.local:8123/
Start creating your home assistant account & set up your configurations.
Make sure you enable authentication in broker.conf file. The default location of conf will be Bevywise/MQTTRoute/conf
Now navigate to the Home Assistant UI & click integrations tab.
Click “Add integration” button.
Select MQTT from the list.
You will view the screen asking for the broker details
Enter broker IP or host name as 127.0.0.1
By default port will be set as 1883. In case if TLS is enabled in the broker.conf file, you need to change the port here.
Now enter username and password which is provided in the security tab of MQTTRoute UI.
Once done click submit. If your configurations are set correctly you will receive a success message. You can view the home assistant device connected to the MQTT Broker in Devices tab & list of message published.
For complete details about MQTT Broker integration with Home Assistant refer this blog.