Magnetometer Readings

Updating my C++ library to handle the new firmware. Started with the magnetometer since there is another recent question about it. The results of reading the mag are not making sense. Here’s what is happening.

  • The calibration routine runs, i.e. RVR spins about 360 degrees on the carpet. About 720 degrees on a hard surface.
  • The calibration complete response is returning true and a value,
  • The request for data provides 3 floating-point values.

The article uses a different mag to explain how the mag works and how to calculate heading. Other articles say the same.

The values don’t look correct because as the RVR is manually rotated they don’t provide the sine/cosine curves, except very roughly, as shown in figure 4 of the article. Here are some results with the rough direction they are pointing:

N	-142.00	1.00	-84.00
NE	-187.00	-44.00	-68.00
E	-174.00	-77.00	-65.00
SE	-141.00	-106.00	-80.00
S	-111.00	-110.00	-87.00
SW	-86.00	-74.00	-90.00
W	-87.00	-53.00	-95.00
NW	-92.00	-7.00	-94.00

The values are always whole numbers, i.e. no fractional parts. Also, don’t understand why the Z values change since the surface is flat. Are these scaled uTesla values?

Any suggestions on whether I’m getting the wrong values or other ideas on why this appears to not work?

Hi @rmerriam,

Stray magnetic fields from the motors, the PCB, or nearby ferrous materials also get picked up by the magnetometer. This is why the raw readings aren’t particularly useful. We made them available since people asked for them, but your best bet is really to use the built-in calibration routine. I just merged Feature/magnetometer examples by Jim-Konish · Pull Request #15 · sphero-inc/sphero-sdk-raspberrypi-python · GitHub to make the calibration examples more functional.


SPHERO Email Marketing -