~/work/gps-compass.md
Case study

Programmable GPS compass

A handheld Arduino device whose arrow doesn't point north — it points to whichever GPS coordinates you loaded onto it. Also the project where I first prototyped the modular Arduino pattern I've reused on every embedded project since.

role
Solo · hardware, firmware, host-side protocol
client
name withheld
sector
Embedded · navigation aids
stack
Arduino (AVR) · GPS module · digital compass · PC-side loader over serial
surface
Programmable target coordinates · live arrow pointing
01 / Problem

A compass that points anywhere

A regular compass points north. The client wanted one that points wherever they told it to. Load a GPS coordinate from a PC, hand the device to someone, and its arrow will keep rotating to indicate the bearing from where they are standing to that fixed point — hike toward the arrow and you arrive. Useful for scenarios where a person needs to walk to a place without reading maps on a screen.

Demo of the device in action
02 / Firmware

The Arduino pattern that outlived the project

The fun part was organising the firmware. I'd built several Arduino projects before this one, and each time the same bits had reappeared — the serial-line protocol for talking to a host, small state machines, shared configuration storage. On this project I finally sat down and extracted a module-registry pattern: each feature is a small self-contained module that registers itself into setup() and loop(), and a sketch is assembled by composing modules rather than by growing one big .ino file.

That pattern shipped on the GPS compass and then quietly travelled — the Arduino firmware on the Višnjan observatory (dome, focuser, fans) uses the same shape, as do later embedded side-projects. Not a grand design; just the kind of small structural decision that pays back for years.

03 / Side quest

The inclination gotcha

A thing I learned the hard way: Earth's magnetic field does not flow horizontally along the surface. At European latitudes it comes up out of the ground at a steep angle — the effect is called magnetic inclination (not to be confused with magnetic declination). If you hold the device flat, the digital compass reads cleanly. Tilt it, and the arrow goes off like crazy — the tilt component projects the vertical field into the horizontal plane and spins the reading.

A full 3D correction is manageable — college-level linear algebra, runnable on an AVR — but the client needed the product soon and only ever used it flat. The fix stayed on the drawing board for a hypothetical future project.

04 / Tech stack

Tools

  • Arduino (AVR) · C/C++
  • GPS module · digital compass IC
  • Serial protocol for PC-side configuration
  • Module-registry firmware pattern (reused since)
~/work
01 / 01 navigate · Esc close