MQTT is the standardized network protocol which sends the data from the devices of IoTs and which supported by most of the microcontrollers and systems.
In this tutorial we will install a MQTT broker in Odinub where we can receive and send the data. For this we can either choose several Odinub boards or just a single Odinub board and a device with MQTT app.
- Publisher: Sends the message
- Subscriber: Receives meassage to the broker
- Broker: Forward messages to registered devices
Fire this below command in your odinub's terminal
cd ..
This is how you can go back to root directory.
sudo nano /etc/network/interfaces
Now you will get below text in your nano editor.
Auto wlan0
Iface wlan0 inet dhcp
Wpa-ssid Odinub(your wifi name)
Wpa-psk 1234(your password)
Change your SSID and Password. Once you have updated your wifi id password you can just fire below commands to start wifi.
Step 1: Install and test mosquittoThere are several application that can be run on the Odinub for the sending and receive the data through the MQTT broker but Mosquitto is one of the simplest broker.
Install this on Odinub:ifup wlan0sudo apt-get install –y mosquitto sudo apt-get install –y mosquitto-clients
Step 2: Get the Odinub’s IP address :ifconfig wlan0
After installing mqtt mosquitto broker and client we need to test.
Now download the My MQTT app from google playstore.
Step 4: Connect Odinub with MyMQTT app.Go to the settings and write the Odinub IP address in Broker and save the settings.
Now write this command in window which will subscribe the topic.
mosquitto_sub –h 192.168.1.4 –t odinub
Now, we have to publish a topic with any message by the MQTT app.
Now if we want to subscribe the topic from MQTT app than add the subscriber topic in MQTT app.
Now for publish a message from odinub than type this command on window.
mosquitto_pub –h 192.168.1.4 –t mqtt_test –m “Hello”
We can use this protocol for many more application like transfering data of any sensor, live communication with any device, etc. I hope that this article helps you in your project building.
Comments
Please log in or sign up to comment.