Projects / Pico knob voltmeter

Pico knob voltmeter

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. PICO

    Wire the knob

    Outer legs to 3V3(OUT) and GND, wiper to GP26.

  2. PICO

    Wire the display

    SDA to GP0, SCL to GP1, power at 3.3 V.

  3. PICO17.2 mASSD1306

    Install the ssd1306 module

    Using Thonny packages.

  4. PICO

    Save the program as main.py

    On the Pico.

  5. PICO

    Run it

    Volts and counts appear.

  6. PICO

    Turn the knob

    Both change smoothly.

  7. PICO

    Measure the 3.3 V pin

    Set VREF to match.

In short

How do you build a pico knob voltmeter?

A Pico reads a knob with its ADC and shows the volts and the raw 16-bit number on an OLED. You need Raspberry Pi Pico H, Potentiometer 10 kΩ, SSD1306 OLED Display and Breadboard 830 Tie Points. It takes 7 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
4

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Pot outer legsPico 3V3(OUT) pin 36 and GNDVoltage divider
Pot wiperPico GP26 pin 31 (ADC0)Analog input
OLED VCC and GNDPico 3V3(OUT) and GNDPower at 3.3 V
OLED SDA and SCLPico GP0 pin 1 and GP1 pin 2I2C data and clock

Code

An ADC turns a voltage into a number. The Pico ADC is really 12 bits, 4096 steps, and MicroPython scales the answer to a 16-bit number so programs look the same on every board. That is why the raw value moves in steps of 16, and why the program also shows the value shifted back down to 12 bits. Dividing the 16-bit count by 65535 and multiplying by the reference gives the voltage. The reference is the board supply, not an exact 3.300 volts, so measure the 3V3(OUT) pin with a multimeter and set VREF to match. The ADC can only read between 0 V and 3.3 V, so never connect anything higher to a pin. Averaging sixteen reads calms the noise, but the last digit is still indicative only, because the Pico ADC is not a precision part.

import time
from machine import ADC, Pin, I2C
from ssd1306 import SSD1306_I2C

adc = ADC(26)
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
VREF = 3.3                                       # measure the 3V3(OUT) pin and adjust

while True:
    total = 0
    for _ in range(16):
        total += adc.read_u16()                  # average 16 reads to calm the noise
    raw = total // 16
    volts = raw * VREF / 65535
    oled.fill(0)
    oled.text("Knob voltmeter", 0, 0)
    oled.text("{:.3f} V".format(volts), 0, 20)
    oled.text("Raw: {}".format(raw), 0, 40)
    oled.text("12-bit: {}".format(raw >> 4), 0, 52)
    oled.show()
    time.sleep_ms(150)

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Wiper at GNDAbout 0 V
Wiper at 3.3 VAbout 3.3 V
Knob in the middleAbout 1.65 V
Raw count stepsMove in steps of about 16
Compared with a multimeterWithin a few tens of millivolts after setting VREF

If it does not work

Value stuck at maximum

Check the wiper goes to GP26.

Readings jump

Keep wires short and add 100 nanofarad from GP26 to GND.

Values do not match the meter

Measure 3V3(OUT) and update VREF.

ImportError for ssd1306

Install the micropython-ssd1306 package.

Blank screen

Check the OLED address 0x3C and the GP0 and GP1 wires.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the pico knob voltmeter?

Raspberry Pi Pico H, Potentiometer 10 kΩ, SSD1306 OLED Display and Breadboard 830 Tie Points.

How long does the pico knob voltmeter take to build?

About 120 minutes for a intermediate maker, in 7 steps.

How do I know the pico knob voltmeter works?

Wiper at GND: About 0 V. Wiper at 3.3 V: About 3.3 V. Knob in the middle: About 1.65 V.

Value stuck at maximum: what should I check?

Check the wiper goes to GP26.

Readings jump: what should I check?

Keep wires short and add 100 nanofarad from GP26 to GND.

Values do not match the meter: what should I check?

Measure 3V3(OUT) and update VREF.

ImportError for ssd1306: what should I check?

Install the micropython-ssd1306 package.