IoT MQTT configuration

Some basic config stuff for the RASPI & MQTT

 

/etc/mosquitto/mosquitto.conf

# Place your local configuration in /etc/mosquitto/conf.d/
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
connection_messages true
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d

/etc/mosquitto/conf.d/dl2sba.conf

password_file /etc/mosquitto/conf.d/pwfile
allow_anonymous false
sys_interval 60

Start/Stop/Status

sudo service mosquitto status

sudo service mosquitto stop

sudo service mosquitto start

Tipps

http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices

 Posting a lifesign to Web-Hub

mosquitto_pub -h 127.0.0.1 -q 1 -u USER -P PASS -t "dl2sba.de/sensorData/40000/1" -m ` cat /proc/uptime | awk -F" " '{ print $1 }'`

 Execute as cronjob every 15min with "crontab -e"

0,15,30,45 * * * * /home/dietmar/bin/postLifesign.sh

Get status of broker

mosquitto_sub -d -h 127.0.0.1 -u user -P password -v -t \$SYS/#