Skip to main content

Your submission was sent successfully! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates from Canonical and upcoming events where you can meet our team.Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

  1. Blog
  2. Article

Rhys Davies
on 30 April 2020

How to use the Raspberry Pi High Quality camera on Ubuntu Core


The new High Quality (HQ) camera from the people over at Raspberry Pi is now available. And as they say, it is really rather good. It has the option for interchangeable lenses, a 12 MP sensor, a distinct improvement from the previous 8MP V2 camera, and a tripod screw mount. In this post, I’ll walk you through the steps to stream video on Ubuntu Core and how to properly focus the camera for different lenses with and without the C mount.

What you will need

If you plan on following along with this guide, this is the list of things you will need:

  • A microSD card (4GB minimum, 8GB recommended)
  • A computer with a microSD card drive
  • A Raspberry Pi 2, 3 or 4
  • A micro-USB power cable (USB-C for the Pi 4)
  • A Wi-Fi network or an ethernet cable with an internet connection
  • A monitor with an HDMI interface
  • An HDMI cable for the Pi 2 & 3 and a micro HDMI cable for the Pi 4
  • A USB keyboard
  • The new HQ Raspberry Pi Camera
  • C and or CS-mount compatible lenses. 
These things, among others

Setting up Ubuntu Core with the HQ Camera

First, to get going with Ubuntu we’re going to need to install and set up Ubuntu Core on the Raspberry Pi. The best way to do this is to open the tutorial in a new tab, follow along to where you can SSH into the Pi, and come back when you’re done.

Once you’re in, we need to enable the camera for the board. This is a little hacky at the moment as you need to go into the config file to do it, but don’t worry. It’s nice and easy and we are working on making this process much more seamless. More on that later. 

Enable the camera to work with Ubuntu Core

Access the uboot config file with this command:

sudo vi /boot/uboot/config.txt

Once the file is open, scroll down to the last line and then type the following commands:

‘a’ 

This will initiate insertion mode so you can add to the file. Next scroll to the bottom of the file and type:

start_x=1 

This is the line that enables the camera. That’s it. Now to save and exit the file hit ‘Esc’ escape on your keyboard to exit insertion mode and type

 ‘:x!’ 

to save and exit the file. To be clear: 

Next, we need to install picamera-demo-application. This is a snap in the snap store developed and maintained by Ogra, a Canonical engineer. To do this use the following command:

snap install picamera-streaming-demo

Connect the camera and connect to the web

Now we can wire the camera up to the Raspberry Pi. In this example, we use the Raspberry Pi 3 Model B. It is important to connect the camera in the right way, pay attention in the following image to the orientation of the ribbon cable. The blue side facing towards the USB ports.

To connect it in this way, pull the black tab gently upwards until you feel it click. Slot the ribbon, orientated as shown, into the space, and press the black tab back down to secure it.

For clarity, this is an example of how not to connect it (in the wrong port):


This would be foolish, that is not the CSI port for the camera. Always take pretty photos after you have set everything up and it’s working.

Once that’s connected, reboot the Raspberry Pi with:

sudo reboot

Wait a few moments and in your browser type:

http://<board IP address>:8000/

And you will be able to see what your camera sees in a web page like this:

This image was taken using the 6mm lens, with bad lighting and then saved using a screenshot tool so doesn’t show quite how quality these photos can be. 

Focusing with and without the C-mount

Being able to focus the camera, is of course, crucial. For a photography novice like me, it took a while to work out how to do it. The C-mount is a type of mount usually found on 16mm cameras. Of the two lenses I bought, one required the C-mount, the other a CS-mount. A CS-mount lens is designed to be mounted ~ 5mm closer to the image sensor than a C lens. It’s important to note this before playing around with the lenses and misplacing the C-mount bracket and wondering why your 16mm lens won’t focus for an hour or so.

C-mount bracket for focusing C-mount lenses

What’s next

We are working to do a lot more to improve the user experience of Ubuntu on Raspberry Pi. This tutorial was non-typical. Usually, tutorials live at ubuntu.com/tutorials, where you can find ‘how-tos’ on getting set up with Ubuntu Server, or other projects, like building a Raspberry Pi cluster using MicroK8s

This tutorial utilises Ubuntu Core, Ubuntu Core is not developer-friendly, we recommend its use for appliances, for fire-and-forget devices and for production. If you want to try other applications or build applications for the Raspberry Pi on Ubuntu we recommend you look into snaps and Ubuntu Server and take it from there. 


Related posts


Gabriel Aguiar Noury
21 November 2024

EdgeIQ and Ubuntu Core; bringing security and scalability to device management 

Internet of Things Article

Today, EdgeIQ and Canonical announced the release of the EdgeIQ Coda snap and official support of Ubuntu Core on the EdgeIQ Symphony platform. EdgeIQ Symphony helps you simplify and scale workflows for device fleet operations, data consumption and delivery, and application orchestration. Distributing EdgeIQ Coda as a snap brings the power ...


Canonical
19 November 2024

Getting started with Azure IoT Operations on Ubuntu

Ubuntu Article

Introduction With the recent announcement of the release of Azure IoT Operations, Microsoft has provided its customers with a unified data plane offering significant improvements in node data capture, edge-based telemetry processing, and cloud-ingress.  Combining Azure IoT Operations with Ubuntu provides the perfect pairing to build secur ...


Edoardo Barbieri
29 October 2024

Meet Canonical at SPS 2024

Ubuntu Article

SPS (Smart Production Solutions) 2024 is almost here! With over 1,200 national and international exhibitors, SPS is the main gathering of industrial manufacturing to experience the latest trends and developments in the automation industry first-hand. Join Canonical, the company behind Ubuntu, at SPS 2024 to discuss open source innovation ...