Skip to content

installing 02 mqtt broker

yOyOeK1 edited this page Jan 28, 2022 · 1 revision

Our goal is IoT offline. For that we need a mqtt broker. It's a service collecting, and providing us with a way to communicate with ours things.

I'm assuming that you are having termux on device.

in termux terminal or by loging to in by ssh wee need to enter commands

$ pkg install mosquitto

after installation we need to set up config files by

$ nano $PREFIX/etc/mosquitto/mosquitto.conf

find line listener ~ add new line

listener 10883 0.0.0.0

it will make mosquitto running on all ip addressis at device at port :10883

It will run at your's local small "internet" so I'm also changing

#allow_anonymous true

to

allow_anonymous true

press CTRL-x y and enter to confirm

adding service to termux-services

$ cd $PREFIX/var/service/

$ ls

you will see that mosquitto directory is pressent. but we need to modify run file by writing

$ nano ./mosquitto/run

line with exec need to be

exec mosquitto -c /data/data/com.termux/files/usr/etc/mosquitto/mosquitto.conf 2>&1

save it CTRL-x y enter

it will make mosquitto running with ours config :) now

$ sv up mosquitto

$ sv-enable mosquitto

now restart termux

testing mosquitto broker

by login to termux enter command

$ mosquitto_sub -t '$SYS/#' -p 10883 -V mqttv311 -d

you will get current list of topics on broker. CTRL-c will kill process

NICE !

Clone this wiki locally