Arduino Uno + CMPS14 compass

Digital 3-axis compass

It's important to get a tilt compensation compass to get a proper bearing if the compass module can tilt. Probably not required on a drone which keeps level, but on a yacht that heals it is required.

Please note the Uno has built-in pull-up resistors.

Photo

I2C protocol3.3 volts

Copy/paste Sketch