# Use Blinka in Ubuntu Core on Raspberry Pi

## Overview

![Raspberry Pi 4 connected to an HDMI display and a BME280 sensor via I2C. The display shows the Ubuntu Core logo during first bootup and installation.](https://cdn-learn.adafruit.com/assets/assets/000/144/484/medium800/temperature___humidity_hero_photo.png?1780591691 )

## What Is It?

[Ubuntu Core](https://ubuntu.com/core) is an OS intended for use on devices embedded within commercial products or industrial equipment. It's very locked down by default. It runs on lots of different hardware. This guide focuses on Raspberry Pi 3, 4, and 5 devices.

It is a very different kind of OS than the traditional Raspberry Pi OS, which is aimed at students, hobbyists, and tinkerers. The locked down nature can make the development iteration cycle slower and more tedious than traditional Pi OS.

Ubuntu Core's strengths really shine most after you've already got a project functioning how you want under a more traditional OS like Pi OS or Ubuntu Server/Desktop and you are ready to deploy somewhere remote.&nbsp;

The&nbsp;[Ubuntu Core documentation](https://documentation.ubuntu.com/core/) describes the OS like this:

> **Ubuntu Core** is an immutable and transaction-based version of Ubuntu that’s engineered for cloud, embedded, and IoT systems.
> 
> It provides an image-based deployment infrastructure with automatic updates for sandboxed applications, enabling the creation of production-ready systems with minimal attack surface and automatic rollback capabilities.
> 
> Ubuntu Core reduces the time to production by eliminating manual provisioning, ensuring systems remain secure throughout their lifecycle, and enabling rapid updates across fleets of devices at scale.
> 
> It is designed for embedded Linux developers, IoT device manufacturers, cloud-based applications, and organizations deploying embedded systems in robotics, automotive, signage, industrial automation, and IoT applications - from single devices to thousands in the field.

## Blinka Inside Ubuntu Core

The process to get [Adafruit\_Blinka](https://github.com/adafruit/Adafruit_Blinka), and a Python script that uses it, running inside of Ubuntu Core is quite different from what you might be familiar with. All libraries and code must be packaged inside of a [Snap](https://en.wikipedia.org/wiki/Snap_(software)#Snapcraft) to be installed and run. It's not possible to use package manager tools like `apt` and `pip` directly. Requirements need to be declared and embedded during the Snap compilation, or "packing" step.

This guide will walk through the process of getting the Ubuntu Core loaded onto a Pi, show a demo of a basic sensor based project, and cover the steps required to build snaps and customized Ubuntu Core images.

## Parts
Building Snaps and Ubuntu Core images needs to be done on another machine that is running Ubuntu. One option is a second Raspberry Pi flashed with Ubuntu Server or Desktop.

Featured
### Raspberry Pi 5 - 4 GB RAM

[Raspberry Pi 5 - 4 GB RAM](https://www.adafruit.com/product/5812)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_ processor, USB 3.0 ports, and an updated Gigabit Ethernet chip with PoE...

In Stock
[Buy Now](https://www.adafruit.com/product/5812)
[Related Guides to the Product](https://learn.adafruit.com/products/5812/guides)
![Angled shot of green Raspberry Pi 5 microcontroller.](https://cdn-shop.adafruit.com/640x480/5812-01.jpg)

Featured
### Raspberry Pi 4 Model B - 4 GB RAM

[Raspberry Pi 4 Model B - 4 GB RAM](https://www.adafruit.com/product/4296)
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 4 better than the 3? How about a&nbsp;_faster_ processor, USB 3.0 ports, and updated Gigabit Ethernet chip with...

In Stock
[Buy Now](https://www.adafruit.com/product/4296)
[Related Guides to the Product](https://learn.adafruit.com/products/4296/guides)
![Angled shot of Raspberry Pi 4](https://cdn-shop.adafruit.com/640x480/4296-11.jpg)

Featured
### Raspberry Pi 3 - Model B - ARMv8 with 1G RAM

[Raspberry Pi 3 - Model B - ARMv8 with 1G RAM](https://www.adafruit.com/product/3055)
Did you really think the Raspberry Pi would stop getting better? At this point, we sound like a broken record, extolling on the new Pi’s myriad improvements like we’re surprised that the folks at the Raspberry Pi Foundation are continuously making their flagship board better.&nbsp;...

In Stock
[Buy Now](https://www.adafruit.com/product/3055)
[Related Guides to the Product](https://learn.adafruit.com/products/3055/guides)
![Angled shot of Raspberry Pi 3 - Model B.](https://cdn-shop.adafruit.com/640x480/3055-04.jpg)

Featured
### Adafruit Pi Stemma QT Breakout for Raspberry Pi and Compatibles

[Adafruit Pi Stemma QT Breakout for Raspberry Pi and Compatibles](https://www.adafruit.com/product/6365)
The **Adafruit Pi Stemma** is a small, easily removable breakout that easily adds a 4-pin JST SH pin (Stemma QT or [Qwiic](https://www.adafruit.com/?q=qwiic)) connector to your Raspberry Pi. The 2x3 socket design allows you to plug securely into the Pi's I2C bus...

In Stock
[Buy Now](https://www.adafruit.com/product/6365)
[Related Guides to the Product](https://learn.adafruit.com/products/6365/guides)
![Demo Shot of the Adafruit Pi Stemma QT Breakout connected to the Raspberry Pi and then connected to the BMP280 Pressure Sensor via a Stemma Cable.](https://cdn-shop.adafruit.com/640x480/6365-04.jpg)

Featured
### Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor

[Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor](https://www.adafruit.com/product/2652)
Bosch has stepped up their game with their new BME280 sensor, an environmental sensor with temperature, barometric pressure&nbsp;and&nbsp;humidity! This sensor is great for all sorts of indoor environmental sensing and can even be used in both I2C and SPI!

This precision sensor from...

In Stock
[Buy Now](https://www.adafruit.com/product/2652)
[Related Guides to the Product](https://learn.adafruit.com/products/2652/guides)
![small, rectangle-shaped, BME280 temperature humidity pressure sensor breakout board.](https://cdn-shop.adafruit.com/640x480/2652-04.jpg)

### For Pi 4 & 5:
Featured
### Official Raspberry Pi 45W USB-C Power Supply

[Official Raspberry Pi 45W USB-C Power Supply](https://www.adafruit.com/product/6320)
If you want a general-purpose USB Power Delivery supply, the official Raspberry Pi 45W USB-C power supply makes for a good quality PD supply that provides high current at a large option of voltages, including 12V which is not always supported, and 5A and 5V which also is a bit rare but makes...

In Stock
[Buy Now](https://www.adafruit.com/product/6320)
[Related Guides to the Product](https://learn.adafruit.com/products/6320/guides)
![Angled Shot of the Official Raspberry Pi 45W USB-C Power Supply.](https://cdn-shop.adafruit.com/640x480/6320-03.jpg)

Featured
### Micro HDMI to HDMI Cable - 2 meter

[Micro HDMI to HDMI Cable - 2 meter](https://www.adafruit.com/product/1322)
Connect an HDMI device with a micro HDMI port to one with a regular size HDMI port together with this basic HDMI cable. It has nice molded grips for easy installation, and is 2 meter long (about 6 feet). This is a HDMI 1.3 cable. Works great with a BeagleBone or Raspberry Pi 4  
  
<img...></img...>

In Stock
[Buy Now](https://www.adafruit.com/product/1322)
[Related Guides to the Product](https://learn.adafruit.com/products/1322/guides)
![Coiled, 2 meter long, black, micro HDMI to HDMI cable.](https://cdn-shop.adafruit.com/640x480/1322-05.jpg)

### For Pi 3:
Featured
### 5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable

[5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable](https://www.adafruit.com/product/1995)
Our all-in-one 5V 2.5 Amp + MicroUSB cable power adapter is the perfect choice for powering single-board computers like Raspberry Pi, BeagleBone, or anything else that's power-hungry!

This adapter was specifically designed to provide 5.25V, not 5V, but we still call it a 5V USB...

In Stock
[Buy Now](https://www.adafruit.com/product/1995)
[Related Guides to the Product](https://learn.adafruit.com/products/1995/guides)
![MicroUSB power supply with bundled cable and U.S. plugs.](https://cdn-shop.adafruit.com/640x480/1995-02.jpg)

Featured
### HDMI Cable - 1 meter

[HDMI Cable - 1 meter](https://www.adafruit.com/product/608)
Connect two HDMI devices together with this basic HDMI cable. It has nice molded grips for easy installation, and is 1 meter long (about 3 feet). This is a HDMI 1.3 cable.

We're now stocking a very fancy Official Raspberry Pi cable with overmolding and a Pi logo. Please note...

In Stock
[Buy Now](https://www.adafruit.com/product/608)
[Related Guides to the Product](https://learn.adafruit.com/products/608/guides)
![Official Raspberry Pi HDMI Cable - 1 meter](https://cdn-shop.adafruit.com/640x480/608-03.jpg)

# Use Blinka in Ubuntu Core on Raspberry Pi

## Ubuntu One Account & SSH Key

## Ubuntu One Account

The standard way to manage and control Ubuntu Core devices is via SSH using public/private keys to authenticate. The user account on the device and the public SSH key are set up on first boot using an Ubuntu One account. You have to create an account and upload a public key using a browser on a different computer (not the Pi running Ubuntu Core). [This documentation page](https://documentation.ubuntu.com/core/how-to-guides/manage-ubuntu-core/use-ubuntu-one-ssh/#how-to-guides-manage-ubuntu-core-use-ubuntu-one-ssh) contains detailed information about the account and SSH setup.

Start by going to [login.ubuntu.com](https://login.ubuntu.com/) and selecting "I don’t have an Ubuntu One account" then fill in email, name, username, and password to create an account.

## Create SSH Key

Creating an SSH key pair can be done easily on Linux or Mac. It's possible on Windows, but trickier. You can use another Raspberry Pi running Pi OS or Ubuntu Server OS to generate the SSH keys.

First create a directory to store keys in and restrict its permissions to be accessible only to the user that owns it with these commands.

```terminal
mkdir -p ~/.ssh
chmod 700 ~/.ssh
```

Use the following commands to change directories and start the key generation wizard.

```terminal
cd ~/.ssh/
ssh-keygen -t rsa
```

Respond to the following prompts in the keygen wizard

- File to save the key in. Enter " **id\_ubuntucore**" or whatever name you want to give your keypair
- **Passphrase** is an extra password that must be entered in order to use the key. It can be left blank, but it's best to enter a passphrase and keep it secret. It acts as a second factor of authentication beyond just having the key file.
- **Confirm Passphrase** by entering the exact same value again.

The output of the wizard will look something like this once complete:

```terminal
Generating public/private rsa key pair.
Enter file in which to save the key (/home/myuser/.ssh/id_rsa): id_ubuntucore
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_ubuntucore
Your public key has been saved in id_ubuntucore.pub
The key fingerprint is:
SHA256:NdKl6pErAxt4fVDNsptgbYwN5B66ZncxWeRk6Zs0Xro user@hostname
The key's randomart image is:
+---[RSA 3072]----+
|     .. .o+..    |
|     ....*+o     |
|      +*.+B      |
|   . ++o*B+..    |
|  . =.ooS= *     |
|   . = oo==      |
|    = + +  .     |
|   o . +  E      |
|                 |
+----[SHA256]-----+
```

That will create two files, **id\_ubuntucore** and **id\_ubuntucore.pub** if you used the name quoted above.

As the file extension suggests&nbsp; **id\_ubuntucore.pub** is the public key of this key pair. It needs to be copied onto the device you want to access with SSH. For Ubuntu Core, the copying happens by uploading the public key to your Ubuntu One account and entering your email in the first boot config.

The file with no extension, **id\_ubuntucore** , is the private key file. Keep that file secure. Anyone who has that file and its passphrase can log in to control any computers configured with the public key.

## Upload Public SSH Key to Ubuntu One

Go to:&nbsp;[https://login.ubuntu.com/ssh-keys](https://login.ubuntu.com/ssh-keys) and use the import key section.

Open the **id\_ubuntucore.pub** file in your text editor of choice or use `cat` in the terminal to print it. Copy the entire contents of the public key file and paste them into the import box on the ssh-keys page then click the **Import SSH Key** button.

![Ubuntu SSH keys page showing a public key pasted into the import form box.](https://cdn-learn.adafruit.com/assets/assets/000/144/445/medium800/temperature___humidity_upload_ssh_key.png?1780079380 )

# Use Blinka in Ubuntu Core on Raspberry Pi

## Install

The steps to install the pre-built images for Raspberry Pi are [documented here in the Ubuntu Core docs](https://documentation.ubuntu.com/core/tutorials/try-pre-built-images/use-raspberry-pi-imager/).

## Prepare SD Card

Flashing an SD card with an Ubuntu Core image is largely the same process as flashing Pi OS or any other image. Use the [Raspberry Pi Imager](https://www.raspberrypi.com/software/) application.

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 Core24**.

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.

![Raspberry Pi Imager application with 'Other General OS' highlighted on the OS selection screen.](https://cdn-learn.adafruit.com/assets/assets/000/144/446/medium640/temperature___humidity_pi_imager_other_os.png?1780080725)

![Raspberry Pi Imager application with Ubuntu highlighted in the OS sub menu](https://cdn-learn.adafruit.com/assets/assets/000/144/447/medium640/temperature___humidity_pi_imager_ubuntu.png?1780080887)

![Raspberry Pi Imager application with Ubuntu Core24 selected in the OS sub menu](https://cdn-learn.adafruit.com/assets/assets/000/144/449/medium640/temperature___humidity_ubuntu_core24.png?1780080958)

## First Boot

After flashing the SD card, insert it into the Pi and then connect the Pi's power adapter. The first boot up will take several minutes and will reboot automatically during the process. When it's complete, it will prompt with **Press enter to configure**.

This initial part of the configuration needs to be done with a keyboard and HDMI display connected to the Raspberry Pi.

### Network

Press the&nbsp; **enter** key a few times to get past the initial prompts and get into the network configuration.

On the network config screen use **arrow up/down** to move the selector around and highlight either **wlan0** or **eth0** based on how you want to connect your network. Press **enter** on the desired network interface.

To set up a WIFI network, select **Edit Wifi** in the **wlan0 sub menu**.

Then use **arrow up/down** to navigate around the WiFi dialog box. Either enter your SSID and password directly, or select&nbsp; **Choose a visible network** , find your network in the list and enter the password.

Highlight **Save** and press **enter** when complete.

It will take a few seconds for the network connection to activate, a rotating slash character indicates progress while it's working.

Once the connection is made successfully, the first item in the menu at the bottom of the screen will change to **Done**. Highlight it and press **enter** to move to the next step.

![First boot config prompt](https://cdn-learn.adafruit.com/assets/assets/000/144/450/medium640/temperature___humidity_firstboot_prompt.png?1780082657)

![First boot network config screen with wlan0 highlighted](https://cdn-learn.adafruit.com/assets/assets/000/144/451/medium640/temperature___humidity_firstboot_wlan.png?1780082689)

![First boot network config with Edit wifi highlighted in the wlan0 submenu](https://cdn-learn.adafruit.com/assets/assets/000/144/452/medium640/temperature___humidity_firstboot_editwifi.png?1780082714)

![First boot wifi config screen with choose a visible network highlighted](https://cdn-learn.adafruit.com/assets/assets/000/144/453/medium640/temperature___humidity_firstboot_visiblenetworks.png?1780082752)

![First boot network screen with Done menu item at the bottom](https://cdn-learn.adafruit.com/assets/assets/000/144/454/medium640/temperature___humidity_firstboot_wifi_done.png?1780083250)

### Profile

The last step of the first boot process is entering the email address associated with your Ubuntu One account. This should be the same email account that was set up on the prior page and has your public SSH key uploaded to it.

When you enter your email address on this page, it is going to try to download the public SSH key(s) from your account. _ **You have to have the keys uploaded prior to this step during the first boot** _, so if you haven't uploaded them, go do it now on a different computer before entering your email here.

After entering your email address, use the arrow keys to highlight the **Done** item in the menu at the bottom of the screen and press **enter**

![First boot profile setup screen prompting for the email associated with the users Ubuntu One account](https://cdn-learn.adafruit.com/assets/assets/000/144/455/medium640/temperature___humidity_firstboot_email.png?1780083450)

Once complete, it will show a message like this on the screen.

```terminal
This device is registered to [ubuntu-sso-email-address]

Remote access was authenticated with SSO user [username].
Public SSH keys were added to the device for remote access.

[ubuntu-sso-email-address] can connect remotely to this device via SSH:

ssh [username]@[ip-address]
```

The default screen shown, when the device boots up from here on after, will look similar and will show the IP address with SSH command to connect to the device.

Verify that the SSH connection works, with these commands, on another computer on the same network as the Pi. Fill in your own username and IP address to the relevant spots. Enter the same passphrase used when creating the key.

```terminal
# Activate the key in your terminal session
ssh-add ~/.ssh/id_ubuntucore
ssh [username]@[ip-address]

# OR specify the keyfile with argument
ssh -i ~/.ssh/id_ubuntucore [username]@[ip-address]
```

If SSH connects successfully, then the installation is done and you're ready to move on to the Blinka demo. If it doesn't, then pause here and troubleshoot it. Look at the display to identify any errors. If it does not show a valid network connection, use a keyboard to troubleshoot/configure the network.

# Use Blinka in Ubuntu Core on Raspberry Pi

## Sensor Dashboard Demo

![Raspberry Pi next to an HDMI display. The Pi is running an environmental sensor dashboard in a full screen kiosk mode](https://cdn-learn.adafruit.com/assets/assets/000/144/459/medium800/temperature___humidity_dashboard.png?1780335834 )

This page demonstrates an environmental sensor dashboard. The demo uses [ubuntu-frame](https://ubuntu.com/frame) and [wpe-webkit-mir-kiosk](https://snapcraft.io/wpe-webkit-mir-kiosk) to automatically launch a full-screen headless browser window to display the dashboard. [Adafruit Blinka](https://github.com/adafruit/Adafruit_Blinka) allows the app to read environmental data from the BME280 sensor over I2C.

Featured
### Adafruit Pi Stemma QT Breakout for Raspberry Pi and Compatibles

[Adafruit Pi Stemma QT Breakout for Raspberry Pi and Compatibles](https://www.adafruit.com/product/6365)
The **Adafruit Pi Stemma** is a small, easily removable breakout that easily adds a 4-pin JST SH pin (Stemma QT or [Qwiic](https://www.adafruit.com/?q=qwiic)) connector to your Raspberry Pi. The 2x3 socket design allows you to plug securely into the Pi's I2C bus...

In Stock
[Buy Now](https://www.adafruit.com/product/6365)
[Related Guides to the Product](https://learn.adafruit.com/products/6365/guides)
![Demo Shot of the Adafruit Pi Stemma QT Breakout connected to the Raspberry Pi and then connected to the BMP280 Pressure Sensor via a Stemma Cable.](https://cdn-shop.adafruit.com/640x480/6365-04.jpg)

Featured
### Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor

[Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor](https://www.adafruit.com/product/2652)
Bosch has stepped up their game with their new BME280 sensor, an environmental sensor with temperature, barometric pressure&nbsp;and&nbsp;humidity! This sensor is great for all sorts of indoor environmental sensing and can even be used in both I2C and SPI!

This precision sensor from...

In Stock
[Buy Now](https://www.adafruit.com/product/2652)
[Related Guides to the Product](https://learn.adafruit.com/products/2652/guides)
![small, rectangle-shaped, BME280 temperature humidity pressure sensor breakout board.](https://cdn-shop.adafruit.com/640x480/2652-04.jpg)

## Kiosk Launcher

Install the `ubuntu-frame` and the `kiosk web page launcher` with this command.

```terminal
snap install ubuntu-frame wpe-webkit-mir-kiosk
```

The HDMI display will start showing a default web page when the kiosk app install completes.

## BME280 Dashboard

The BME280 dashboard app is a locally built snap file. It is not distributed through the snap store like ubuntu-frame and wpe-webkit-mir-kiosk. The code for this snap can be found on the&nbsp;[Building Snaps page of this guide](https://learn.adafruit.com/use-blinka-with-ubuntu-core-on-raspberry-pi/building-snaps).

### Download & Copy Snap

Use the button below to download a copy of the file&nbsp; **bme280-dashboard\_0.1\_arm64.snap**.

Copy the file to the Ubuntu Core device. One easy way to copy it is [scp](https://man7.org/linux/man-pages/man1/scp.1.html).

[bme280-dashboard_0.1_arm64.snap](https://github.com/adafruit/Ubuntu_Core_Blinka_Sensor_Snap/raw/refs/heads/main/bme280-dashboard_0.1_arm64.snap)
```terminal
# Run on your main computer to copy the snap file to the Ubuntu Core device
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 foamyguy@192.168.1.121:/home/foamyguy/
```

### Install Snap

Install the snap file with the following command. The `--dangerous` flag is required to install snap files that are not distributed through the snap store. The `--devmode` flag loosens some of the restrictions within the OS for development. It allows the Pi 5's GPIO access to work without further customization of the system image. It's required on Pi 3 and 4 as well because they all use the same Snap for this demo. It would be possible to modify and rebuild the snap to target only Pi 3 or 4 to avoid needing the `--devmode` flag.

```terminal
sudo snap install ./bme280-dashboard_0.1_arm64.snap --dangerous --devmode
```

### Connect Plugs to Slots

Ubuntu Core apps are sandboxed and locked down by default, with minimal access to the hardware on the device. The permission model is based on **plugs** and **slots**. If an application wants to use a particular piece of hardware on the device, the app declares a plug for the hardware. The OS provides slots that the plugs need to be connected to in order to actually be granted access to the hardware.

For testing a custom built snap, the only way to connect the plug to the slot is with a command. For building a custom image and deploying, it is possible to use a customized [gadget snap](https://documentation.ubuntu.com/core/how-to-guides/image-creation/build-a-gadget-snap/) to make these connections automatically upon first boot up. A custom gadget snap is also what would be required to target the Pi 5 with this snap and remove the need for the `--devmode` installation flag.

Run these commands to allow permission for the `i2c` bus and `hardware-observe` plugs, both are required by the Blinka demo.

```terminal
sudo snap connect bme280-dashboard:i2c pi:i2c-1
sudo snap connect bme280-dashboard:hardware-observe
```

### Test Script

To confirm everything is working, use the `sudo bme280-dashboard.blinka-test` command. You should see output similar to this.

![Terminal screenshot showing output of the bme280-dashboard.blinka-test command with temperature, humidity, pressure, and altitude](https://cdn-learn.adafruit.com/assets/assets/000/144/461/medium800/temperature___humidity_blinka_test_output.png?1780419089 )

Press **ctrl-c** &nbsp;to stop the program.

### Set Dashboard URL

Finally, configure the kiosk URL to point to the dashboard, which is being hosted by a small webserver inside the snap on `localhost` port 8080.

```terminal
snap set wpe-webkit-mir-kiosk url=http://localhost:8080/
```

The display will change from the default Ubuntu Core web page to the sensor dashboard demo.

![Environmental sensor dashboard showing current and graphed historical data for temperature, humidity, and pressure.](https://cdn-learn.adafruit.com/assets/assets/000/144/463/medium800/temperature___humidity_sensor_dashboard_screenshot.png?1780419641 )

# Use Blinka in Ubuntu Core on Raspberry Pi

## 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](https://documentation.ubuntu.com/core/explanation/core-elements/snaps-in-ubuntu-core/). 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](https://documentation.ubuntu.com/snapcraft/stable/tutorials/craft-a-snap/) 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.

## Set Up Build Pi
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.

![Raspberry Pi imager app screenshot showing the Ubuntu Server 24.04 LTS OS highlighted](https://cdn-learn.adafruit.com/assets/assets/000/144/464/medium640/temperature___humidity_ubuntu_server_24.png?1780420747)

## Build Environment

Update the software on the build Pi using&nbsp;`apt` with these commands.

```terminal
sudo apt update
sudo apt upgrade
```

Install [snapcraft](https://github.com/canonical/snapcraft) and [lxd](https://documentation.ubuntu.com/lxd/latest/) with these commands.

```terminal
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.

```terminal
sudo usermod -a -G lxd $USER
sudo reboot
```

After the system boots back up use this command to initialize lxd.

```terminal
sudo lxd init --auto
```

## Sensor Demo Code
[bme280_snap_code.zip](https://cdn-learn.adafruit.com/assets/assets/000/144/498/original/bme280_snap_code.zip?1780670534)
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](https://documentation.ubuntu.com/snapcraft/stable/explanation/snapcraft-yaml/) breaks down the structure and typical contents of the file.

Here is the **snapcraft.yml** file for the BME280 dashboard demo.

https://github.com/adafruit/Ubuntu_Core_Blinka_Sensor_Snap/blob/main/snap/snapcraft.yaml

The file defines 3 apps:&nbsp;

- `blinka-test` a wrapper around the [BME280 simpletest](https://github.com/adafruit/Adafruit_CircuitPython_BME280/blob/main/examples/bme280_simpletest.py) script. Useful to confirm that Blinka and the sensor hardware are operational.
- `sensor-service` a background service that reads data from the sensor periodically and saves it to a [sqlite3](https://sqlite.org/index.html) database. This command uses the **sensor\_kiosk/sensor\_service.py** script.
- `sensor-web` a background service that runs a [Flask](https://flask.palletsprojects.com/en/stable/) 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.

## Build Snap

Use the snapcraft CLI inside of the **bme280\_dashboard\_snap/** folder to build the snap.

```terminal
snapcraft pack
```

Yellow: The first build of a snap takes several minutes (8-10 min on Pi 5). Subsequent builds can run a little faster due to some parts of the container being cached.

Once the build is complete it will output a message like this.

```terminal
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.

```terminal
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 foamyguy@192.168.1.121:/home/foamyguy/
```

From here, everything works the exact same as is documented starting with the [Install Snap section on the dashboard demo page](https://learn.adafruit.com/use-blinka-with-ubuntu-core-on-raspberry-pi/sensor-dashboard-demo#install-snap-3220653).

# Use Blinka in Ubuntu Core on Raspberry Pi

## Custom Images

[This page from the Ubuntu Core docs](https://documentation.ubuntu.com/core/tutorials/build-your-first-image/) walks through all of the steps necessary to build an image. This guide page will cover the process of creating an image that has the BME280 dashboard preloaded into it.

Images can be created using Ubuntu Server or Desktop 22.04+ OS. The Raspberry Pi that was set up with [Ubuntu Server on the Building Snaps page](https://learn.adafruit.com/use-blinka-with-ubuntu-core-on-raspberry-pi/building-snaps#set-up-build-pi-3220676) is suitable if it has a large enough SD card. The docs list 10gb requirement for the build machine. The output image file alone is about 3.8gb.

Images are built from **models**. A model is a JSON file that acts as a recipe for an image. It defines the Snaps built-in to the image, and metadata including a developer ID from a [Ubuntu One](https://learn.adafruit.com/use-blinka-with-ubuntu-core-on-raspberry-pi/ubuntu-one-account-and-ssh-key) account.

## Retrieve Developer ID

You can find your developer ID using the snapcraft CLI. It's the same CLI used to build Snaps, so if you followed along with that page, you should have it already. If you don't then install it with this command.

```terminal
sudo snap install snapcraft --classic
```

Next, use these commands to login and export your credentials to an environment variable that the snapcraft CLI will use.

```terminal
snapcraft export-login credentials.txt
export SNAPCRAFT_STORE_CREDENTIALS=$(cat credentials.txt)
```

You should see output like this.

![Terminal screenshot showing the export-login command output and environment variable export command.](https://cdn-learn.adafruit.com/assets/assets/000/144/479/medium800/temperature___humidity_export_login.png?1780515343 )

Now use `snapcraft whoami` to find your developer ID.

```terminal
snapcraft whoami
```

Look for the row that starts with `id:`, the value to the right is your developer ID. Copy it and save it somewhere to reference later. The model JSON file will need to have your ID put into it.

![Terminal screenshot showing output of the snapcraft whoami command including ubuntu developer ID.](https://cdn-learn.adafruit.com/assets/assets/000/144/480/medium800/temperature___humidity_snapcraft_whoami.png?1780516053 )

## Model JSON

This is the model JSON file for an image with `ubuntu-frame` and `wpe-webkit-mir-kiosk` built in. To build an image from the model, fill in your developer ID for the `authority-id` and `brand-id` values.

https://github.com/adafruit/Ubuntu_Core_Blinka_Sensor_Snap/blob/main/image/bme280_dashboard_core24_model.json

## Create & Register Key

Before the image can be made, the model must be signed to turn it into a **model assertion**. To sign the model, you need to create and register a key in the Ubuntu snapcraft system. [This page documents](https://documentation.ubuntu.com/core/tutorials/build-your-first-image/sign-the-model/) the key set up and signing process.

Info: This model signing key is different from the SSH key created and uploaded on the Ubuntu One Account & SSH Key page.

If you've done any Ubuntu or Snap development before, you can check whether you have a key already with this command.

```terminal
snapcraft list-keys
```

If you see "No keys have been registered..." then use the following commands to create and register a key. You can use any name that you like for the key.

```terminal
# command
snapcraft create-key [key-name]


# example
snapcraft create-key bme280-dashboard-key
```

You will be prompted for a passphrase to use on the key. This is an extra password that will be required in order to use the key. It can be left blank, but it's best to use a secure passphrase and keep it secret. It serves as a second factor in addition to possession of the key file. Enter the desired passphrase and repeat it again for the confirmation prompt.

```terminal
# command
snapcraft register-key [key-name]


# example
snapcraft register-key bme280-dashboard-key
```

You will be prompted for the passphrase in order to register the key, and again when you use it to sign a model.

## Update Model Timestamp

Inside of the model JSON, the `timestamp` field needs to contain a timestamp that is newer than the signing key. So if you just created and registered a key using the steps above, then you must set the timestamp to a more recent value after the key was registered.

You can get a timestamp with suitable syntax using this command.

```terminal
date -Iseconds --utc
```

Then update the value in the model JSON file with it.

```auto
"timestamp": "[timestamp_here]",


# example
"timestamp": "2026-06-03T20:27:10+00:00",
```

## Sign Model

Finally, it's time to sign the model using the registered key.

```terminal
# command
snap sign -k [key-name] [model-file.json] > [output_model-file.model]


# example
snap sign -k bme280-dashboard-key bme280_dashboard_core24_model.json > bme280_dashboard_core24_model.model
```

You will be prompted for the passphrase when you use a key to sign a model.

It will create a new file for the model assertion with the specified output name, **bme280\_dashboard\_core24\_model.model** in the example above.

## Build Image

Building the image is done with the [ubuntu-image](https://github.com/canonical/ubuntu-image) utility. Install it with this command.

```terminal
sudo snap install ubuntu-image --classic --edge
```

Build the image from a model assertion with the following command. The `--snap` argument is optional. It allows you to specify a custom Snap file, such as one built on the previous page, to be included in the image. For final deployment, snaps would be distributed via the Snap Store instead.

```terminal
# command
ubuntu-image snap --allow-snapd-kernel-mismatch [model-assertion-file.model] --snap [custom.snap]

#example
ubuntu-image snap --allow-snapd-kernel-mismatch bme280_dashboard_core24_model.model --snap bme280-dashboard_0.1_arm64.snap
```

If successful, the output will look like this. It will also create a **pi.img** file as shown by the `ls` command after the output in the screenshot below.

![Terminal output from the ubuntu-image command to build the system image. Output from ls command showing the created pi.img file.](https://cdn-learn.adafruit.com/assets/assets/000/144/485/medium800/temperature___humidity_build_image_output.png?1780592577 )

## Flash Image
Copy the resulting **pi.img** file to a computer with Raspberry Pi imager on it.

Flash this img file to an sdcard with Pi imager app.

Click&nbsp; **Use custom** on the OS menu and then select the **pi.img** file.

![Raspberry Pi imager app OS selection screen with 'Use Custom' highlighted](https://cdn-learn.adafruit.com/assets/assets/000/144/483/medium640/temperature___humidity_pi_imager_custom_img.png?1780582616)

After flashing the image, follow the same steps from the [First Boot Up section on the Install guide page](https://learn.adafruit.com/use-blinka-with-ubuntu-core-on-raspberry-pi/install-2#first-boot-3220574). Once the first boot configuration is complete, you should be able to connect to the device with your SSH key.

## Launch Dashboard

The Snaps required by the sensor dashboard demo are preloaded into this image, but the plugs still need to be manually connected to the slots in order for the sensor to function. The kiosk apps need to be set to auto-launch and have the URL configured for the dashboard also. Use the following commands to complete these steps.

Info: A [custom gadget snap](https://documentation.ubuntu.com/core/how-to-guides/image-creation/build-a-gadget-snap/) can be used to automatically connect slots on first boot up.

```terminal
# connect plugs for Blinka
sudo snap connect bme280-dashboard:i2c pi:i2c-1
sudo snap connect bme280-dashboard:hardware-observe

# Enable autolaunch and configure kiosk URL
snap set ubuntu-frame daemon=true
snap set wpe-webkit-mir-kiosk url=http://localhost:8080/
```

The sensor dashboard should load onto the screen after a moment.

![Raspberry Pi next to an HDMI display. The Pi is running an environmental sensor dashboard in a full screen kiosk mode](https://cdn-learn.adafruit.com/assets/assets/000/144/486/medium800/temperature___humidity_dashboard.png?1780595602 )


## Guide Products

### Raspberry Pi 5 - 4 GB RAM

[Raspberry Pi 5 - 4 GB RAM](https://www.adafruit.com/product/5812)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_ processor, USB 3.0 ports, and an updated Gigabit Ethernet chip with PoE...

In Stock
[Buy Now](https://www.adafruit.com/product/5812)
[Related Guides to the Product](https://learn.adafruit.com/products/5812/guides)
### Raspberry Pi 4 Model B - 4 GB RAM

[Raspberry Pi 4 Model B - 4 GB RAM](https://www.adafruit.com/product/4296)
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing _better_! And what could make the Pi 4 better than the 3? How about a&nbsp;_faster_ processor, USB 3.0 ports, and updated Gigabit Ethernet chip with...

In Stock
[Buy Now](https://www.adafruit.com/product/4296)
[Related Guides to the Product](https://learn.adafruit.com/products/4296/guides)
### Raspberry Pi 3 - Model B - ARMv8 with 1G RAM

[Raspberry Pi 3 - Model B - ARMv8 with 1G RAM](https://www.adafruit.com/product/3055)
Did you really think the Raspberry Pi would stop getting better? At this point, we sound like a broken record, extolling on the new Pi’s myriad improvements like we’re surprised that the folks at the Raspberry Pi Foundation are continuously making their flagship board better.&nbsp;...

In Stock
[Buy Now](https://www.adafruit.com/product/3055)
[Related Guides to the Product](https://learn.adafruit.com/products/3055/guides)
### Adafruit Pi Stemma QT Breakout for Raspberry Pi and Compatibles

[Adafruit Pi Stemma QT Breakout for Raspberry Pi and Compatibles](https://www.adafruit.com/product/6365)
The **Adafruit Pi Stemma** is a small, easily removable breakout that easily adds a 4-pin JST SH pin (Stemma QT or [Qwiic](https://www.adafruit.com/?q=qwiic)) connector to your Raspberry Pi. The 2x3 socket design allows you to plug securely into the Pi's I2C bus...

In Stock
[Buy Now](https://www.adafruit.com/product/6365)
[Related Guides to the Product](https://learn.adafruit.com/products/6365/guides)
### Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor

[Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor](https://www.adafruit.com/product/2652)
Bosch has stepped up their game with their new BME280 sensor, an environmental sensor with temperature, barometric pressure&nbsp;and&nbsp;humidity! This sensor is great for all sorts of indoor environmental sensing and can even be used in both I2C and SPI!

This precision sensor from...

In Stock
[Buy Now](https://www.adafruit.com/product/2652)
[Related Guides to the Product](https://learn.adafruit.com/products/2652/guides)
### Official Raspberry Pi 45W USB-C Power Supply

[Official Raspberry Pi 45W USB-C Power Supply](https://www.adafruit.com/product/6320)
If you want a general-purpose USB Power Delivery supply, the official Raspberry Pi 45W USB-C power supply makes for a good quality PD supply that provides high current at a large option of voltages, including 12V which is not always supported, and 5A and 5V which also is a bit rare but makes...

In Stock
[Buy Now](https://www.adafruit.com/product/6320)
[Related Guides to the Product](https://learn.adafruit.com/products/6320/guides)
### Micro HDMI to HDMI Cable - 2 meter

[Micro HDMI to HDMI Cable - 2 meter](https://www.adafruit.com/product/1322)
Connect an HDMI device with a micro HDMI port to one with a regular size HDMI port together with this basic HDMI cable. It has nice molded grips for easy installation, and is 2 meter long (about 6 feet). This is a HDMI 1.3 cable. Works great with a BeagleBone or Raspberry Pi 4  
  
<img...></img...>

In Stock
[Buy Now](https://www.adafruit.com/product/1322)
[Related Guides to the Product](https://learn.adafruit.com/products/1322/guides)
### 5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable

[5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable](https://www.adafruit.com/product/1995)
Our all-in-one 5V 2.5 Amp + MicroUSB cable power adapter is the perfect choice for powering single-board computers like Raspberry Pi, BeagleBone, or anything else that's power-hungry!

This adapter was specifically designed to provide 5.25V, not 5V, but we still call it a 5V USB...

In Stock
[Buy Now](https://www.adafruit.com/product/1995)
[Related Guides to the Product](https://learn.adafruit.com/products/1995/guides)

## Related Guides

- [Raspberry Pi Care and Troubleshooting](https://learn.adafruit.com/raspberry-pi-care-and-troubleshooting.md)
- [Adafruit Pi Stemma QT Breakout](https://learn.adafruit.com/adafruit-pi-stemma-qt-breakout.md)
- [Matrix Portal Creature Eyes](https://learn.adafruit.com/matrix-portal-creature-eyes.md)
- [How to Make Games in MakeCode Arcade](https://learn.adafruit.com/how-to-make-games-on-makecode-arcade.md)
- [Holiday Card Maker on Fruit Jam](https://learn.adafruit.com/holiday-card-maker-on-fruit-jam.md)
- [CompuCanvas 101 - Transitions](https://learn.adafruit.com/compucanvas-101.md)
- [iNTERCEPT + SDR for Signal Monitoring on Raspberry Pi](https://learn.adafruit.com/intercept-and-sdr-for-monitoring-signals-on-raspberry-pi.md)
- [Minesweeper on the Fruit Jam and Metro RP2350](https://learn.adafruit.com/minesweeper-on-metro-rp2350.md)
- [No-Code IKEA Vindriktning Air Quality Sensor Hack with Adafruit IO](https://learn.adafruit.com/no-code-ikea-vindriktning-hack-with-qt-py-esp32-s3-and-adafruit-io.md)
- [HalloWing Jump Scare Trap](https://learn.adafruit.com/hallowing-jump-scare-trap.md)
- [Programming with Scratch 2 or 3 on Raspberry Pi](https://learn.adafruit.com/programming-with-scratch-on-raspberry-pi.md)
- [LLM Agent Embodiment Kit](https://learn.adafruit.com/llm-agent-embodiment-kit.md)
- [Adafruit Speaker Bonnet for Raspberry Pi](https://learn.adafruit.com/adafruit-speaker-bonnet-for-raspberry-pi.md)
- [Multi-Sensor IoT Environmental Sensor Box With CircuitPython](https://learn.adafruit.com/remote-iot-environmental-sensor.md)
- [Return to The Matrix with the Metro RP2350 or Fruit Jam](https://learn.adafruit.com/return-to-the-matrix-with-the-metro-rp2350.md)
- [NeoTrellis Tabletop RPG Soundboard](https://learn.adafruit.com/neotrellis-dungeon-crawl-soundboard.md)
- [Adafruit AMG8833 8x8 Thermal Camera Sensor](https://learn.adafruit.com/adafruit-amg8833-8x8-thermal-camera-sensor.md)
