Skip to content

Instantly share code, notes, and snippets.

@leighghunt
Last active October 6, 2023 04:51
Show Gist options
  • Save leighghunt/dacfe5320ef06f9fcb24588603bc9397 to your computer and use it in GitHub Desktop.
Save leighghunt/dacfe5320ef06f9fcb24588603bc9397 to your computer and use it in GitHub Desktop.
Energy Management Dashboard installation
version: '2.1'
services:
dashboard:
container_name: dashboard
image: leighghunt/energy-monitoring-dashboard:pi-zero-node-11-5-gauges
restart: unless-stopped
ports:
- 80:80
volumes:
- /home/pi/logFiles:/data/logFiles
devices:
- /dev/ttyS0:/dev/ttyAMA0
- /dev/mem:/dev/mem
environment:
- NODE_ENV=production
version: '2.1'
services:
dashboard:
container_name: dashboard
image: leighghunt/energy-monitoring-dashboard:pi-zero-node-11-5-gauges
restart: unless-stopped
ports:
- 80:80
volumes:
- /home/pi/logFiles:/data/logFiles
devices:
- /dev/ttyAMA0:/dev/ttyAMA0
- /dev/mem:/dev/mem
environment:
- NODE_ENV=production
version: '2.1'
services:
dashboard:
container_name: dashboard
image: leighghunt/energy-monitoring-dashboard:pi-zero-node-11-motor-rpm
build:
context: .
restart: unless-stopped
ports:
- 80:80
volumes:
- /home/pi/logFiles:/data/logFiles
devices:
- /dev/ttyAMA0:/dev/ttyAMA0
- /dev/mem:/dev/mem
environment:
- NODE_ENV=production
version: '2.1'
services:
dashboard:
container_name: dashboard
image: leighghunt/energy-monitoring-dashboard:pi-zero-node-11
restart: unless-stopped
ports:
- 80:80
volumes:
- /home/pi/logFiles:/data/logFiles
devices:
- /dev/ttyAMA0:/dev/ttyAMA0
- /dev/mem:/dev/mem
environment:
- NODE_ENV=production

How to get running on a Raspberry Pi Zero W

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=NZ

network={
        ssid="SSID1"
        psk="Password 1"
}
network={
        ssid="SSID2"
        psk="Password 2"
}
  • Create empty ssh file on SD card. On Mac, you can use touch to do this.
touch /Volumes/boot/ssh
  • Pop SD card into Raspberry Pi
  • Power up pi.
  • To find IP address of pi:
15:57 $ arp -a | grep b8:27
? (10.1.10.49) at b8:27:eb:f6:c2:ef on en0 ifscope [ethernet]
  • For a pi Zero W 2, use the following:
➜  ~ arp -a | grep e4:5f
? (10.1.10.28) at e4:5f:1:5a:6e:b3 on en0 ifscope [ethernet]
➜  ~ 

e4:5f

  • Login to pi - pi, raspberry, accepting fingerprint warning if neccessary.
16:00 $ arp -a | grep b8:27
? (10.1.10.49) at b8:27:eb:f6:c2:ef on en0 ifscope [ethernet]
? (10.1.10.74) at b8:27:eb:4c:b:3a on en0 ifscope [ethernet]
✔ ~/dev/astara/EnergyMonitoringDashboard [master|✚ 2]
16:01 $ ssh pi@10.1.10.74
The authenticity of host '10.1.10.74 (10.1.10.74)' can't be established.
ECDSA key fingerprint is SHA256:qmO5vdnwHH/Mw6MaB8LxwdOoLSVNFqAoOxs5umJCukA.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.1.10.74' (ECDSA) to the list of known hosts.
pi@10.1.10.74's password:
Linux raspberrypi 4.14.79+ #1159 Sun Nov 4 17:28:08 GMT 2018 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $
  • Download the following two scripts and run them
curl -L "https://gist.github.com/leighghunt/dacfe5320ef06f9fcb24588603bc9397/raw/install-step-1.sh" -o install-step-1.sh
chmod +x install-step-1.sh
curl -L "https://gist.github.com/leighghunt/dacfe5320ef06f9fcb24588603bc9397/raw/install-step-2.sh" -o install-step-2.sh
chmod +x install-step-2.sh
  • Download the docker-compose file. N.B. download the correct version depending on whether you're running 5 gauges version.
  • Normal version:
curl -L "https://gist.github.com/leighghunt/dacfe5320ef06f9fcb24588603bc9397/raw/docker-compose.yml" -o docker-compose.yml
  • 5 Gauges version:
curl -L "https://gist.github.com/leighghunt/dacfe5320ef06f9fcb24588603bc9397/raw/docker-compose-5-gauges.yml" -o docker-compose.yml
  • Run install-step-1.sh
./install-step-1.sh
  • Reboot pi
sudo shutdown -r now
  • Log in to pi again and run install-step-2.sh, and provide the username energymonitoringdashboard and password when prompted.
./install-step-2.sh
pi@raspberrypi:~$ ./install-step-2.sh 
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: energymonitoringdashboard
Password: 
WARNING! Your password will be stored unencrypted in /home/pi/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

#!/bin/bash
# Install byobu
sudo apt-get update
sudo apt-get install byobu -y
sudo apt-get install python python-pip libffi-dev libssl-dev -y
sudo pip install docker-compose
# Set timezone
echo -e "TZ='Pacific/Auckland'; export TZ\n_byobu_sourced=1 . /usr/bin/byobu-launch 2>/dev/null || true" >.profile
# Enable serial comms
sudo raspi-config nonint do_i2c 0
sudo raspi-config nonint do_spi 0
sudo raspi-config nonint do_serial 1
# Disable bluetooth (as per https://github.com/node-serialport/node-serialport/issues/1583#issuecomment-399946145)
echo -e "dtoverlay=pi3-disable-bt\nenable_uart=1" | sudo tee --append /boot/config.txt
# Pin docker version
echo -e "Package: docker-ce\nPin: version 18.06.*\nPin-Priority: 1000" | sudo tee /etc/apt/preferences
# Download docker
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
sudo usermod -aG docker pi
# Docker compose
#sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
#sudo chmod +x /usr/local/bin/docker-compose
echo ""
echo "******************"
echo "Now reboot your pi"
echo "******************"
#!/bin/bash
# Docker login
docker login
# Start container
docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment