Raspberry Pi Pico Camera (1): See and think on the $4 microcontroller

Arducam
5 min readMar 10, 2021

In 2021, Raspberry Pi enters the world of microcontrollers — a world that’s nothing new, but quite different from minicomputers.

How is it different? With respect to the camera applications we are discussing in this blog, there won’t be dedicated camera slots or official Pi camera modules for the Pico.

Most microcontroller boards are not designed with cameras in mind. For them, the image signal processing is not a simple task.

This is where Arducam comes in. Arducam is a long-time player of microcontroller cameras since the Arduino era.

Back in the old days, we managed to add 2MP OV2640 cameras to the Arduino, even multiple ones

This blog is a guide to setting up and using a camera with Pico. Read along for more details.

Connect a camera to Pico: Let’s Take a Look at Its I/O

If we want to connect a camera to Pico, the first thing to consider is how to interface the camera to the Raspberry Pi Pico’s pins. So let’s take a look at the pinout of Pico:

Raspberry Pi Pico Pinout

So here are our choices: UART, PIO, SPI and I2C. We’ll look at camera interfaces with these protocols.

Raspberry Pi Pico Camera using UART and PIO — OV2640 Breakout

The twitter user @The6P4C has got the OV2640 working on the Pico with a PIO program. The images are over UART, so the speed and resolution are limited: 352 x 288 image, non real-time.

About 20 pins are required in the wiring

The code is available on Github.

Raspberry Pi Pico Camera using SPI and I2C — Arducam Mini 2MP OV2640 SPI Camera Module

The Arducam Mini 2MP was originally designed for the Arduino platform. However, since it uses a general-purpose design using only the SPI and I2C signals, it’s easily portable to other microcontrollers.

Here is a comment from our user M. Mullin:

The Arducam is straightforward enough that it can be easily used with an Arduino, however this simple interface means that the Arducam is equally easily integrated with other single board computers such as the Raspberry Pi and the Beaglebone black. It isn’t just a camera for the Arduino, it’s a camera that because it can be easily interfaced to an Arduino, can be easily interfaced to any single board computer, either directly, or through an Arduino if needed for a larger system without exposed SPI/I2C busses. In short, the Arducam brings a plug and play solution to digital cameras at the hardware level.

It turns digital cameras into a standardized peripheral instead of a custom engineering nightmare

Getting Started with Raspberry Pi Pico Camera with Arducam and Raspberry Pi 4B or 400

The following tutorial is also available in our Pico Cam Github.

Getting started

See Getting Started with the Raspberry Pi Pico and the README in the pico-sdk for information on getting up and running.

Quick Pico Setup

If you are developing for Raspberry Pi Pico on the Raspberry Pi 4B, or the Raspberry Pi 400, most of the installation steps in this Getting Started guide can be skipped by running the setup script. You can get this script by doing the following:

git clone https://github.com/raspberrypi/pico-setup.git

Then run:

pico-setup/pico_setup.sh

The script will:

  • Create a directory called pico
  • Install required dependencies
  • Download the pico-sdk, pico-examples, pico-extras, and pico-playground repositories
  • Define PICO_SDK_PATH, PICO_EXAMPLES_PATH, PICO_EXTRAS_PATH, and PICO_PLAYGROUND_PATH in your ~/.bashrc
  • Build the blink and hello_world examples in pico-examples/build/blink and pico-examples/build/hello_world
  • Download and build picotool (see Appendix B). Copy it to /usr/local/bin. • Download and build picoprobe (see Appendix A).
  • Download and compile OpenOCD (for debug support)
  • Download and install Visual Studio Code
  • Install the required Visual Studio Code extensions (see Chapter 6 for more details)
  • Configure the Raspberry Pi UART for use with Raspberry Pi Pico

Once it has run, you will need to reboot your Raspberry Pi,

sudo reboot

Get Arducam

  • Download RPI-Pico-Cam
git clone https://github.com/ArduCAM/RPI-Pico-Cam.git
  • Compile
cd RPI-Pico-Cam/arducam_demo
mkdir build
cd build
cmake ..
make

Then you will creat some files under RPI-Pico-Cam/arducam_demo/build/Arducam path

BinDescriptionarducam_demo.elfwhich is used by the debugger.arducam_demo.uf2which can be dragged onto the RP2040 USB Mass Storage Device.

Test Arducam demo

AppDescriptionarducam_demo:This is a video streaming demo.

  • Hardware connection
  • Load and run arducam_demo The simplest method to load software onto a RP2040-based board is by mounting it as a USB Mass Storage Device. Doing this allows you to drag a file onto the board to program the flash. Go ahead and connect the Raspberry Pi Pico to your Raspberry Pi using a micro-USB cable, making sure that you hold down the BOOTSEL button to force it into USB Mass Storage Mode.

If you are logged in via ssh for example, you may have to mount the mass storage device manually:

$ dmesg | tail
[ 371.973555] sd 0:0:0:0: [sda] Attached SCSI removable disk
$ sudo mkdir -p /mnt/pico
$ sudo mount /dev/sda1 /mnt/pico

If you can see files in /mnt/pico then the USB Mass Storage Device has been mounted correctly:

$ ls /mnt/pico/
INDEX.HTM INFO_UF2.TXT
Copy your arducam_demo.uf2 onto RP2040:
sudo cp arducam_demo.uf2 /mnt/pico
sudo sync

What’s next?

Arducam has made it possible to use a custom CCM module based on HiMax QVGA image sensor HM01B0 on the Pico, and integrated the camera module to our own variant board Pico4ML with the RP2040 chip.

Please Follow us to learn more in the coming blogs!

--

--

Arducam

Camera solutions expert for embedded systems - like Raspberry Pi, NVIDIA Jetson, Arduino — from lens to sensor to driver to PCB and industrial design.