Balena Sense Without the Cloud

Notes on setting up a Balena Sense air quality monitoring whateverydo, without using Balena Cloud

There may be a better / easier way of settting this up, but…

  • Make it work 👈 … right now we’re here
  • Make it right
  • Make it fast

Assumptions:

  • Raspberry Pi 3 (you’ll have to fork and fiddle with the GitHub for any other Pis)
  • You have a Wi-Fi Pi
  • You have a BME680 sensor already wired up to the Pi

Create boot disk

Choose your Raspbian

At time of writing, Raspbian Buster is relatively fresh, and it takes a little fiddling to get everything set up right. If you want to avoid that fiddling, it may be worth downloading the latest Stretch release

🔥 Burn baby burn 🔥

Install balenaEtcher, if you don’t already have it

brew cask install balenaetcher

And then run it

And choose the Raspbian image, the MicroSD card, and let the sparks fly

balenaEtcher will unmount the card once it’s written the image. To continue with Wi-Fi or SSH set up, you’ll need to remount it

Wi-Fi

⚠️ Assuming your MicroSD card is mounted at /Volumes/boot. If this is not the case, update the path in the references below

cat > /Volumes/boot/wpa_supplicant.conf << EOF
network={
    ssid="SSID"
    psk="PASSWORD"
}
EOF

SSH

SSH is disabled by default on Raspbian. If you don’t fancy digging out a keyboard and monitor, we can enable SSH on first boot with an empty file named ssh in the boot disk

touch /Volumes/boot/ssh

Switch it on

Switch on the Pi and connect via your preferred means:

  • Keyboard and monitor 👴
  • Find the IP and SSH

Pi setup

sudo raspi-config
Section Setting Value
Change User Password ⚠️ Change this to something secure
Network Options Hostname air-(area), or whatever you prefer
Interfacing Options SSH Yes
Interfacing Options I2C Yes

Portainer

Install Docker

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

Buster-specific fixes

⚠️ If you see any of the following errors, you’re running Buster and you need to do some fiddling

  • E: Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'testing' to 'stable'
  • E: The repository 'https://download.docker.com/linux/raspbian 10 Release' does not have a Release file.

To fix:

sudo apt update --allow-releaseinfo-change
sudo sed -i '/apt_repo=/a apt_repo="deb [arch=armhf] https://download.docker.com/linux/raspbian stretch nightly"' get-docker.sh
sh get-docker.sh

Sort out permissions & kick off a reboot

sudo usermod -aG docker pi
sudo reboot

Run Portainer

docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --restart always --name portainer portainer/portainer -H unix:///var/run/docker.sock

Balena Sense

Find out your Pi’s internal IP

ifconfig wlan0 | grep 'inet '

Example IP: 192.168.0.2. Swap this out with your own IP in the references below

Login to Portainer

Set up the Balena Sense Stack

Note: This GitHub repository will only work for Raspberry Pi 3. For any other versions, you’ll have to clone down the repository and change the FROM lines in the Dockerfiles within

Setting Value
Name balenasense
Repository URL https://github.com/rjacksonm1/balena-sense
  • “Deploy the stack”
  • This will take a bit of time. It’s building Docker images

Check out the stats in Grafana