Raspberry Pi – nodered/mosquitto
Table of Contents
Intro
Instructions
Install Mosquitto
// good to know
hostname -I // GET Raspi IP
// install mosquitto broker
sudo apt update // update system
sudo apt install -y mosquitto mosquitto-clients // install mosquitto broker
sudo systemctl enable mosquitto.service // autostart on boot
mosquitto -v // check mosquitto version
Create Auth
// set up a user
sudo mosquitto_passwd -c /etc/mosquitto/credentials myuser // create a user
sudo nano /etc/mosquitto/mosquitto.conf // setup for using a user in settings
allow_anonymous false
password_file /etc/mosquitto/credential
// if you want to add websocket support for mqtt then add this too
listener 1883
listener 9001
protocol websockets
// if you want us ssl or more info check out http://www.steves-internet-guide.com/mqtt-websockets/
sudo service mosquitto restart // restart mosquitto service
# MySettings
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
allow_anonymous false
password_file /etc/mosquitto/credentials
listener 1883
listener 9001
protocol websockets
Install NodeRed
// install node.js
curl -sSL https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt install -y nodejs
//check version
node --version
npm --version
//install node-red
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
sudo systemctl enable nodered.service // add servic to autostart on boot