adafruit / Adafruit_HMC5883_Unified

48 stars 35 forks source link

Missing gain setting (0.88 G) #9

Open groundstate opened 3 years ago

groundstate commented 3 years ago

The code does not support the 0.88 G setting. I've added it myself and it seems to work. Is there a reason it's missing?

ladyada commented 3 years ago

this sensor is discontinued many years ago so we can't test or verify anything about it - we dont own one anymore!

groundstate commented 3 years ago

OK, but versions of the board are still available and it's still useful because it has lower noise than eg the LIS3MDL.

For anyone reading this who wants to use the 0.88G mode, just add HMC5883_MAGGAIN_0_9 = 0x00, // +/- 0.88 to the magnetometer gain settings in the .h and case HMC5883_MAGGAIN_0_9: _hmc5883_Gauss_LSB_XY = 1370; _hmc5883_Gauss_LSB_Z = 1370; break; to Adafruit_HMC5883_Unified::setMagGain() in the .cpp I have used conversions from the datasheet but maybe you want to scale the Z conversion (decrease by 12%) like the others in the switch(gain)

ladyada commented 3 years ago

yah current breakouts are not real hmc's, they're knockoffs - you could submit a PR and we may do a sweep at some point to merge in!