I've wanted to build a digital compass myself, but cheap and reliable solutions elude me.
There are sensors which only output 8 cardinal directions and can't be calibrated thus basically useless. And there are sensors/modules like the Hitachi HM755B which have useful outputs which are somewhat expensive.
I got a $10 digital compass with LCD display, with a calibration mode, from Harbor Freight Tools. It's got two 2-wire devices about 3/4" long and maybe 0.1" diameter. They're mounted perpendicular, one is perpendicular to the main board and they had to cast the case specifically to accomodate it.
I'm assuming it's a type of inductor, but otherwise I don't get it. If ONLY that stupid module had a serial port output.