← Back to Musings

projects

Bike Compass Navigation with Raspberry Pi Pico

Bike Compass Navigation with Raspberry Pi Pico

Want a tiny, low‑cost navigation aid for your bike that shows a compass direction and can receive simple images (like turn arrows) from your phone? This guide walks you through building a circular display board based on the Raspberry Pi Pico, wiring a compass sensor, a small round TFT screen, and a Bluetooth module for phone communication. All parts are inexpensive and the software is straightforward MicroPython.

Why the Pico?

The Raspberry Pi Pico (or Pico W) is perfect for this project: - Low cost – under $10 for the base board. - Tiny footprint – fits easily on a handlebar mount. - Enough compute – dual‑core ARM Cortex‑M0+ at 133 MHz, plenty for reading sensors, driving a display, and handling Bluetooth. - Easy to program – MicroPython or C/C++ SDK; we’ll use MicroPython for rapid iteration. - Flexible I/O – plenty of GPIO for SPI (display), I²C (compass), and UART (Bluetooth).

Parts List

Part Approx. Cost Notes
Raspberry Pi Pico (or Pico W) $6 Pico W adds Wi‑Fi/Bluetooth but we’ll use external BT for simplicity.
1.3″ Round TFT LCD (240×240, ST7789 driver) $8 Circular display; SPI interface.
QMC5883L Triple‑Axis Magnetometer (Compass) $2 I²C, tilt‑compensated heading.
HC‑05 Bluetooth Module $4 Classic Bluetooth SPP; easy to pair with Android/iOS apps.
220 Ω Resistors (x4) $0.10 Level‑shifting for 3.3V Pico → 5V tolerant pins (if needed).
Jumper wires, breadboard, or perfboard $5 For prototyping; later solder to a small PCB.
Handlebar mount / 3D‑printed case $0‑$10 Depends on your preference.
Total ~$25 Well under $30 if you already have wires.

(If you choose the Pico W, you can skip the HC‑05 and use its built‑in Bluetooth, but the external module is often simpler for SPP serial.)

Wiring Diagram

All connections are 3.3V logic. The Pico’s GPIO are 3.3V tolerant; the HC‑05 accepts 3.3V on its RX pin (through a voltage divider if you’re cautious). The round TFT and QMC5883L are both 3.3V devices.

Pico Pin Function Connected To
GP18 (SPI0 SCK) SPI Clock TFT SCK
GP19 (SPI0 TX) SPI MOSI TFT SDA (MOSI)
GP16 SPI0 CS TFT CS
GP17 SPI0 DC TFT DC (Data/Command)
GP20 SPI0 Reset TFT RST
GP22 Backlight PWM (optional) TFT LED (via transistor or direct with resistor)
GP4 (I²C0 SDA) I²C Data QMC5883L SDA
GP5 (I²C0 SCL) I²C Clock QMC5883L SCL
GP8 (UART0 TX) UART Transmit HC‑05 RX (through voltage divider: 1kΩ + 2kΩ to ground)
GP9 (UART0 RX) UART Receive HC‑05 TX
3V3(OUT) Power TFT VCC, QMC5883L VCC, HC‑05 VCC
GND Ground All devices GND

Notes: - The TFT’s backlight can be driven straight from a GPIO through a 220 Ω resistor (adjust for brightness). - If you use a Pico W and want to use its internal Bluetooth, skip the HC‑05 wiring and use the Bluetooth API in MicroPython.

Software Overview

We’ll split the firmware into three tasks: 1. Read compass – calculate heading (0‑360°) from QMC5883L. 2. Draw on display – show a compass rose, a needle pointing to heading, and optionally an image (e.g., arrow) received via Bluetooth. 3. Bluetooth serial – receive simple commands from a phone app (e.g., "IMG:<base64>" or "DIR:<angle>") and update the screen.

Step‑by‑step MicroPython

  1. Flash MicroPython on the Pico (uf2 file from micropython.org).
  2. Copy libraries – we need drivers for ST7789 and QMC5883L. You can write simple ones or use existing ones:
    • st7789py.py (for the round display; adjust for 240×240).
    • qmc5883l.py (basic I²C magnetometer).
  3. Main loop (pseudo‑code):

    import machine, math, time
    from st7789py import ST7789
    from qmc5883l import QMC5883L
    from machine import UART, SPI, Pin
    
    # Init SPI for display
    spi = SPI(0, sck=Pin(18), mosi=Pin(19))
    tft = ST7789(spi, 240, 240,
                 reset=Pin(20), dc=Pin(17), cs=Pin(16),
                 rotation=0)  # adjust as needed
    
    # Init I2C for compass
    i2c = machine.I2C(0, sda=Pin(4), scl=Pin(5))
    compass = QMC5883L(i2c)
    
    # Init UART for HC-05
    uart = UART(0, tx=Pin(8), rx=Pin(9), baudrate=9600)
    
    def draw_compass(angle):
        tft.fill(0x0000)  # black background
        # Draw compass rose (simple circle + N/E/S/W labels)
        # Draw needle line from center to edge at `angle`
        # Optionally blit a received image
    
    while True:
        # Read compass
        x, y, z = compass.read()
        heading = math.degrees(math.atan2(y, x))  # adjust for declination if needed
        if heading < 0:
            heading += 360
    
        # Check for Bluetooth data
        if uart.any():
            cmd = uart.readline().decode().strip()
            if cmd.startswith("IMG:"):
                # decode base64 and show image (simplified)
                pass
            elif cmd.startswith("DIR:"):
                target = float(cmd[4:])
                # could show turn arrow pointing to target direction
    
        draw_compass(heading)
        time.sleep(0.1)
    
  4. Phone side – any Bluetooth serial terminal app (e.g., “Serial Bluetooth Terminal” on Android) can send text. For images, you’d encode a small bitmap (e.g., 32×32 arrow) as base64 and send IMG:<data>; the Pico would decode and draw it. For simplicity, you could just send direction commands like LEFT, RIGHT, STRAIGHT and draw appropriate arrows.

Making It Super Easy

Cost Comparison

Solution Approx. Cost Complexity
Pico + round TFT + compass + HC‑05 $25 Low (breadboard, MicroPython)
ESP32‑S2 + round TFT $30 Medium (Wi‑Fi/BT built‑in, but larger code)
STM32 + custom PCB $50+ High (requires PCB fab)
Commercial bike GPS (e.g., Garmin) $150+ Low (but locked‑in)

The Pico build wins on cost and simplicity while still being fully customizable.

Next Steps & Ideas

Give It a Try!

Grab the parts, wire them up on a breadboard, flash MicroPython, and copy the example code. Within an hour you’ll have a working compass display that talks to your phone. Once satisfied, solder everything onto a small perfboard or PCB, mount it on your handlebars, and enjoy a minimalist, distraction‑free navigation aid.

Happy riding!

Which Birds Appear Most Often

Not all birds are equally comfortable around industry. A few groups have essentially adopted it as a preferred habitat.

Peregrine Falcon

Nests on tall structures — bridges, power stations, cathedral-height chimneys. Many urban populations now nest almost exclusively on buildings.

Black Redstart

In the UK, strongly associated with industrial wasteland and brownfield sites. Rubble and broken concrete mimic its native rocky habitat.

Heron species

Grey and great blue herons are indifferent to surroundings as long as there is water and fish. Docks and industrial waterways suit them perfectly.

Corvids

Crows, ravens, jackdaws, and magpies are intensely curious and highly visible. They perch on machinery and cables with the confidence of owners.

Starlings

Their murmurations over industrial rooftops at dusk produce some of the most photographed wildlife spectacles in Europe.

Waders and Gulls

Sewage treatment works, settling pools, and port channels concentrate invertebrates. Gulls of every species, dunlin, redshank, and snipe all use these sites.

Practical Considerations for Photographers

Industrial bird photography requires a few adjustments in approach compared to shooting in natural settings.

Background management

In woodland or grassland, the background is often your enemy — clutter, branches, distracting colours. In an industrial setting, the background is the point. You need to actively compose for it rather than trying to eliminate it. Move around the subject to find angles where structural elements frame the bird, lead the eye toward it, or create a clean separation between the subject and the layers behind. Shooting slightly upward against open sky with infrastructure in the mid-ground often works well.

Exposure and colour

Industrial settings can fool a camera's metering. Very bright reflective surfaces, deep shadow pockets, and the mixed colour temperatures from different light sources all require manual or spot-metered exposure. Shoot in RAW if you can — the colour grading latitude is essential. Many photographers deliberately push the colour toward a cooler, desaturated palette to emphasise the contrast with the natural tones of the bird. Others lean into the warmth of rust and oxidised metal.

Timing

The same golden-hour logic applies here, but with an added dimension: industrial sites often have their own rhythms. Shift changes, loading operations, and processing cycles all move birds around. The hour after a site goes quiet — early morning before workers arrive, or late evening — is often the most productive. Birds that spend the day on the perimeter move in once the disturbance drops.

Safety and access

This matters more than it would in a nature reserve. Active industrial sites have genuine hazards. Even when shooting from public paths adjacent to a facility, be aware of vehicle movements and restricted-access zones. Some photographers build relationships with site managers to gain legitimate access — a signed photo of a peregrine nesting on the company's chimney is a reasonable trade for a one-day access pass.

The Broader Argument

There is something worth saying about what these photographs communicate beyond their immediate visual appeal. Industrial bird photography is, implicitly, a document of adaptation. The landscapes humans have built over the last two centuries were not designed with wildlife in mind, and yet a remarkable number of species have found ways to use them. Peregrines are more numerous in Britain now than before industrialisation. Black redstarts in Germany use rooftop gravel and industrial rubble almost exclusively for nesting. Ospreys in North America fish from aquaculture ponds and hatcheries alongside their ancestral lakes.

These images do not argue that industry is good for wildlife — it is usually not. But they do push back against a simple narrative in which nature and human infrastructure are always opposed. The birds appear in these places because the birds are practical. The photographers who follow them there are making the same pragmatic bet: that beauty is available wherever you are willing to look for it.

A pylon silhouetted against a pale winter sky with a kestrel on the top wire is not less beautiful than a kestrel over a wildflower meadow. It is differently beautiful — and for many photographers, that difference has become the whole point.

Photographers Worth Looking At

A handful of photographers have built recognisable bodies of work in this specific territory. These are three worth starting with.

Sam Hobson

samhobson.co.uk

Bristol-based wildlife photographer and one of the UK's foremost urban wildlife specialists. His multi-year urban peregrine project documents falcons living on Bristol's bridges and city-centre buildings — including the pair that nested near Battersea Power Station. His work has been published in National Geographic, BBC Wildlife, and Audubon, and his image Nosy Neighbour was used as the lead publicity image for the Wildlife Photographer of the Year exhibition. The urban section of his portfolio is a masterclass in combining artificial structure with wildlife behaviour.

Grzegorz Długosz

gdlugosz.com

Polish wildlife photographer based in Warsaw, winner of the Gold Award in the Urban Birds category at Bird Photographer of the Year 2024. His winning image documented a common goldeneye and her ducklings navigating a six-lane highway through central Warsaw — a perfect example of the tension this genre captures. His portfolio covers a wide range of bird behaviour, with a strong thread of urban and peri-urban settings throughout.

Spanish nature photographer with over 25 years of experience. His image Refinery Refuge, recognised in the Wildlife Photographer of the Year 2016 competition, shows white storks nesting on refinery pylons and rooftops — birds that have abandoned large trees in favour of industrial infrastructure as nest sites. The image is a quietly powerful argument for the whole genre: the storks are utterly indifferent to the flame stacks behind them.