Building Snaps
Development of apps to run under Ubuntu Core is different than developing for other operating systems. All required libraries and code must be collected together and compiled into a Snap. If you want to customize the dashboard demo from the previous page by changing it visually, or swapping to another sensor, you have to rebuild and re-install the snap.
This page in the Ubuntu docs is a tutorial covering the entire set up and creating a Snap from scratch. This guide page will cover the necessary set up and how to build the sensor dashboard demo project from the previous page.
The build needs to occur on a device with the same architecture as the target. For example, if you want the app to run under Ubuntu Core x64 on a Raspberry Pi, then you need to build the Snap on an arm64 based device. Advanced users can build inside a virtual machine. This guide documents building using a separate Raspberry Pi that is running the Ubuntu Server OS.
In the Raspberry Pi Imager: Select the appropriate model of your device.
Click on Other general-purpose OS in the main OS menu.
Click on Ubuntu in the next OS menu.
Scroll to the bottom of the list and click on Ubuntu Server 24.04 LTS (64-bit).
Click Next and continue through the rest of the Imager wizard as normal to write the image to the SD card.
When the flashing and verifying is complete click Finish and then unmount or eject the SD card from your computer. Insert it into a Raspberry Pi and boot up.
sudo apt update sudo apt upgrade
sudo snap install snapcraft --classic sudo snap install lxd
Add your user to the lxd group and then reboot the Pi so that the new groups take effect.
sudo usermod -a -G lxd $USER sudo reboot
After the system boots back up use this command to initialize lxd.
sudo lxd init --auto
Click the button above to download the BME280 dashboard snap project code. Unzip it and copy the bme280_dashboard_snap/ folder inside to the build machine.
Snapcraft.yml
All snaps must have a snapcraft.yml file. It defines the requirements and behaviors of the application. This docs page breaks down the structure and typical contents of the file.
Here is the snapcraft.yml file for the BME280 dashboard demo.
# SPDX-FileCopyrightText: 2026 Tim Cocks for Adafruit Industries
# SPDX-License-Identifier: MIT
name: bme280-dashboard
base: core24
version: '0.1'
summary: BME280 environmental sensor dashboard demo for Blinka on Ubuntu Core
description: |
A learning snap that bundles Adafruit Blinka and exposes
the hardware interfaces needed to talk to I2C/GPIO/SPI.
Includes a kiosk-style web dashboard fed by a BME280
temperature/humidity/pressure sensor.
grade: devel
# devmode (not strict): the Pi 5 lgpio backend opens the raw /dev/gpiochip4
# (RP1) char device at "import board", which no snapd interface
# (gpio / gpio-memory-control) grants. devmode lets it through. Pi 3/4 work
# under strict because RPi.GPIO uses /dev/gpiomem via gpio-memory-control.
confinement: devmode
apps:
blinka-test:
command: bin/test-sensor
plugs:
- hardware-observe
- i2c
- spi
- serial-port
- gpio
- gpio-memory-control
sensor-service:
command: bin/sensor-service
daemon: simple
install-mode: enable
restart-condition: always
restart-delay: 5s
plugs:
- hardware-observe
- i2c
- spi
- gpio
- gpio-memory-control
sensor-web:
command: bin/sensor-web
daemon: simple
install-mode: enable
restart-condition: always
restart-delay: 5s
plugs:
- network
- network-bind
parts:
app:
plugin: python
source: .
python-packages:
- adafruit-blinka
- RPi.GPIO # Pi 3/4 (bcm283x/bcm2711) GPIO backend
- lgpio # Pi 5 (bcm2712) GPIO backend - Blinka imports this on the Pi 5
- adafruit-circuitpython-bme280
- flask
- waitress
stage-packages:
- i2c-tools
- libgpiod2
- python3-libgpiod
build-packages:
- libgpiod-dev
override-build: |
craftctl default
install -D -m 0755 test-sensor $CRAFT_PART_INSTALL/bin/test-sensor
The file defines 3 apps:
-
blinka-testa wrapper around the BME280 simpletest script. Useful to confirm that Blinka and the sensor hardware are operational. -
sensor-servicea background service that reads data from the sensor periodically and saves it to a sqlite3 database. This command uses the sensor_kiosk/sensor_service.py script. -
sensor-weba background service that runs a Flask web server that hosts the dashboard. The server code is located in sensor_kiosk/app.py.
The "parts" section defines all of the requirements for the Snap. The sensor demo requires Blinka, its GPIO dependencies, the adafruit_bme280 library, Flask, and waitress.
snapcraft pack
Once the build is complete it will output a message like this.
Packed bme280-dashboard_0.1_arm64.snap
Copy the resulting snap file to the Ubuntu Core device using scp or your preferred file transfer method.
scp -i [keyfile] bme280-dashboard_0.1_arm64.snap [username]@[hostname-or-ip]:/home/[username]/ # example: scp -i ~/.ssh/id_ubuntucore bme280-dashboard_0.1_arm64.snap [email protected]:/home/foamyguy/
From here, everything works the exact same as is documented starting with the Install Snap section on the dashboard demo page.
Page last edited June 08, 2026
Text editor powered by tinymce.