Pi PICO
Build a Raspberry Pi Pico voltmeter
Tam Hanna uses the Raspberry Pi Pico’s analog-to-digital converter and an OLED display to create a small, but decently useful voltmeter.
OUR EXPERT
Tam Hanna has developed, and made hardware for various civil and militia applications. He lives in a bunker full of test equipment in Budapest, and is always looking for well-paid jobs…
QUICK TIP
This multimeter could also have been written in C. Doing so would have forced us to miss out on various libraries, which led to more compact code. In today’s age of highperformance microcontrollers (this is a 100MHz class unit), sacrificing some efficiency for faster development is a tradeoff worth considering.
F ew tasks in the life of an engineer can compete with the degree of satisfaction achieved by creating test equipment. Be it a testing rig or a generic piece of equipment, there’s always something to learn (and fun to be had).
This tutorial will see us take the first steps towards the creation of a basic multimeter. While our product won’t be seeing the multimeter designers at Agilent or, Danaher filing for unemployment benefits, the product will demonstrate aspects of analog and digital design. Most interestingly, we’ll implement auto-ranging to ensure that ADC resources are always used optimally.
Multimeters with graphical displays are a recent development – a few years ago, alphanumeric reigned supreme. Fortunately, Solomon Systech‘s SSD1306- based display controller made graphical displays affordable. The screen used in the following steps can be purchased at AliExpress for less than £4 a pop. Investing some more money leads to its larger brother – the SSD1351 provides full-colour output.
Should you ever feel like going into series production, be aware that not all OLEDs are created equal. In recent projects done by the author, contrast differences between different display vendors were visible.
Building new circuits is best done in a step-by-step process. With this in mind, let’s begin by bringing up the display in accordance with the figure (above).
Show and tell
Organic displays often display nothing if the software doesn’t compel them to. To achieve that, we need to download the library found at http://bit.ly/ lxf274ssd1306. Simply create a new tab in the Thonny IDE, and save it to the Raspberry Pi Pico.
Next, we commence with the actual program creation. Various hardware access classes need to be imported. After that, we start to configure the various hardware resources required for communication:
from machine import Pin, I2C, SPI, Timer
from ssd1306 import SSD1306_SPI
import framebuf
Solomon Systech integrates two special pins into its controller to streamline the communication protocol. The value of the DC pin decides if the incoming data is to be written into the command or the framebuffer storage area. Given that our Raspberry Pi Pico has more than enough general-purpose input-output pins, we simply dedicate two of them to bit-banging. The SPI engine of the Raspberry Pi Pico is unable to handle the chip select line so a third dedicated GPIO pin is required: