Rabu, 12 Januari 2022

Tutorial Install MQQT Broker on OpenWrt 19.07.5

Detail play Vdeo and activated feature CC/Subtitle to see detail intruction



 

Step by Step intruction :

Login router with PuTTy

root@OpenWrt:~# opkg update

root@OpenWrt:~# opkg install mosquitto-ssl

root@OpenWrt:~# opkg install mosquitto-client-ssl libmosquitto-ssl

Open WinSCP 
Find and edit the mosquitto.conf file in /etc/mosquitto/mosquitto.conf

Edit the mosquitto.conf file to be like this
# ===========================
# General configuration
# ===========================
# Port to use for the default listener.
port 1883
# anonymous
allow_anonymous false
# persistence
persistence true
# name of the file for persistence
persistence_file mosquitto.db
# location of the file for persistence
persistence_location /mnt/sda2/mosquitto/
#how often to save to the persistence file
autosave_interval 1800
log_timestamp true
log_dest file /mnt/sda2/mosquitto/mosquitto.log
log_dest stdout
password_file /mnt/sda2/mosquitto/passwords.txt
===============================
SAVE dan Close
root@OpenWrt:~# /etc/init.d/mosquitto enable
root@OpenWrt:~# /etc/init.d/mosquitto restart

Create MQTT User1 
root@OpenWrt:~# mosquitto_passwd -c /mnt/sda2/mosquitto/passwords.txt keishax1 <<<< Edit you user 
Password :              <<<< type the password 
Reenter Password :      <<<< type the password again

If it happens like that, because the passwords.txt file in /mnt/sda2/mosquitto/passwords.txt doesn't exist yet

Open WinScp 
Find Folder /mnt/sda2
Make file :
passwords.txt
mosquitto.log
Make Folder : mosquitto <<< set permision 0777

Move the passwords.txt and mosquitto.log files to the 
/mnt/sda2/mosquitto/ folder

Repeat for MQTT user and password 
Create MQTT User1

root@OpenWrt:~# mosquitto_passwd -c /mnt/sda2/mosquitto/passwords.txt keishax1 <<<<<< Edit you user
Password :              <<<< type the password
Reenter Password :      <<<< type the password again

root@OpenWrt:~# /etc/init.d/mosquitto stop

root@OpenWrt:~# mosquitto -c /etc/mosquitto/mosquitto.conf

If error unable Open

Open WinScp
Find file mosquitto.log in folder /mnt/sda2/mosquitto/mosquitto.log set permision to 0755
mosquitto.log set permision to 0777

root@OpenWrt:~# mosquitto -c /etc/mosquitto/mosquitto.conf

If there is no error, it looks like this

1604592752: mosquitto version 1.6.12 starting
1604592752: Config loaded from /etc/mosquitto/mosquitto.conf.
1604592752: Opening ipv4 listen socket on port 1883.

MQTT Broker is already running 
Can check in the mosquitto.log file and saving memory is stored in mosquitto.db

If you want to set MQTT via Luci Web Install MQTT Luci

root@OpenWrt:~# opkg install luci-app-mosquitto

Refresh Luci web and check in the Services menu mosquitto
Service Mosquitto already installed

If MQTT Broker is already set via WinScp, you don't need to set MQTT via Luci service mosquitto

Test with a laptop using MQTT Explorer to access the web temperature chart MQTT ESP8266
Testing MQTT ESP8266 temperature

Tidak ada komentar:

Posting Komentar

Jika ada pertanyaan silahkan tulis di kolom komentar.dengan bahasa yang sopan,No Sara,No Rasis & No Pornografi

Featured Post

Extroot and install luci in firmware OpenWrt Compilation