MQTT#Broker Setup

In this tutorial I will show you how to setup a MQTT Broker in Linux( And I am using Raspberry pi3 this time).

Here is the link to mosquitto.

https://mosquitto.org/download/

Installation

Update your Device.

sudo apt update

Install the mosquitto by using below command:

sudo apt install mosquitto

if this error is shown:

E: ロック /var/lib/dpkg/lockfrontend が取得できませんでした – open (11: リソースが一時的に利用できません)

Please run these commands:

sudo rm /var/lib/apt/lists/lock
sudo rm /var/lib/dpkg/lock
sudo rm /var/lib/dpkg/lockfrontend

Start the Broker by this command;

sudo systemctl start mosquitto

And use this Command to check the Broker status.

sudo systemctl status mosquitto

Test

We can install a mqtt client by this command;

sudo apt-get install mosquitto mosquitto-clients

Open a Terminal, and run this command to subscribe to the Topic class1.

mosquitto_sub -d -t class1

Open another Terminal, and run this command to publish a message with Topic class1.

mosquitto_pub -d -t class1 -m 43.1

You can see 43.1 displayed.

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする