MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. For example, it has been used in sensors communicating to a broker via satellite link, over occasional dial-up connections with healthcare providers, and in a range of home automation and small device scenarios. It is also ideal for mobile applications because of its small size, low power usage, minimised data packets, and efficient distribution of information to one or many receivers.
MQTT
What do you need?
- Raspberry Pi
- Power supply 5V 2A
- SD Card with Raspbian Strech Lite link
- UTP Cable
- Case for the Raspberry Pi
- PuTTy on a Windows or Linux computer.
Setup Raspbian Stretch Lite
- Installation of the MQTT Broker on Raspberry Pi. http://mqtt.org/
- Make a SSH connection with PuTTy:
Login: 'pi'
Password: 'raspberry' sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mosquitto
sudo apt-get install mosquitto-clients
- Testing the Working of MQTT
- Open two putty programs on windows, you can do this by clicking the putty.exe file and enter the host name and click to open do this twice so that two putty programs access Pi via ssh. Lets say putty1 and putty2 are open and connected to Pi via ssh for our convenient.
- In putty1 window type the command with the topic name
YouTube test
this topic name can be anything, according to the convenience of the user .mosquitto_sub –d –t YouTube test
- In putty2 image 2 window type the following command with the same topic i.e
YouTube test
mosquitto_pub –d –t YouTube test –m “Hello from Yuotube”
- Now come to the window putty1, image 1 here you will be able to see the message
Hello from Yuotube
https://youtu.be/hhcc9Pt03x8