HMC5883L is a surface-mount, multi-chip module designed for low-field magnetic sensing with a digital interface for applications such as lowcost compassing and magnetometry.
I2cConnectionSettings settings = new I2cConnectionSettings(1, Hmc5883l.I2cAddress);
// get I2cDevice (in Linux)
UnixI2cDevice device = new UnixI2cDevice(settings);
// get I2cDevice (in Win10)
//Windows10I2cDevice device = new Windows10I2cDevice(settings);
using (Hmc5883l sensor = new Hmc5883l(device))
{
// read direction vector
Vector3 directionVector = sensor.DirectionVector;
// read direction angle
double angle = sensor.Heading;
// use sensor
}
https://cdn.datasheetspdf.com/pdf-down/H/M/C/HMC5883L-Honeywell.pdf