The rear camera can focus down to 6 cm. You could move that tiny compass to the other side, mount it 6 cm away, capture an image, and write some image processing software to derive the needle's orientation.