Stretch from scratch

My current home automation server is running Node-Red and a Mosquitto MQTT broker on a Raspberry Pi 2. The uptime is over 2 years.
(moved the location of the Pi, otherwise it was close to 3 years)


I was still running Wheezy and in desperate need of an update. Instead of going trough the painful process of trying to update without breaking something I decided to start from scratch on a shiny new Raspberry Pi 3B+.

First download the latest Raspbian. Use Raspbian Stetch Lite as we will be running the Pi headless. Burn the image to an SD card. (Apple-Pi-Baker on MacOS)

Enable SSH (on root of SSD)

touch SSH

Insert the SD in the Pi and login using SSH from terminal.

ssh pi@raspberrypi

Setup wifi / timezone / camera

sudo raspi-config
sudo apt-get update
sudo apt-get upgrade

Install Node-Red

bash <(curl -sL

Install GIT

sudo apt-get install git

setup Node-Red projects

cd ~/.node-red/
nano settings.js
projects = true

autostart Node-RED at every boot

sudo systemctl enable nodered.service

Node-RED Authentication with GitHub
New OAuth App
npm install node-red/node-red-auth-github
cd ~/.node-red
nano settings.js


adminAuth: require('node-red-auth-github')({
baseURL: "http://localhost:/admin“,
users: [
{ username: “mdellen”,permissions: ["*"]}
httpAdminRoot: '/admin',

Redirect website

cd ~/.node-red
mkdir web
cd web
nano index.html

Add: pi_RED___etc_mosquitto_—_ssh_pi_red_local_—_238×70

nano settings.js
httpStatic: '/home/pi/.node-red/web',

Install MQTT broker

sudo apt-get install libwebsockets-dev
sudo apt-get install mosquitto
cd /etc/mosquitto
sudo mosquitto_passwd -c /etc/mosquitto/passwd [USERNAME]
sudo nano mosquitto.conf
allow_anonymous = false
password_file /etc/mosquitto/passwd
sudo service mosquitto restart
sudo mosquitto_passwd /etc/mosquitto/passwd [USER2]
sudo mosquitto_passwd /etc/mosquitto/passwd [USER3]
sudo service mosquitto restart
tail -f /var/log/mosquitto/mosquitto.log

Now you have setup a virgin Raspberry with Node-Red and a MQTT broker.
MacOS users can also setup file sharing for easy acces and editing of file on the Pi.

Next thing is to add SSL to Node-Red for much needed security when you expose your project to the internet.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: