Im using the SparkFun MAG3110 3D sensor: https://www.sparkfun.com/products/12670
My application is essentially to make a contactless "magnetic joystick" using a local magnet for accurate and constant 3D position sensing in x, y, x planes of a local magnet, exactly like in this video (skip to 1:06): https://www.youtube.com/watch?v=CO6y6bjFfmY
The magnet I'm using is constant, so i'm trying to figure out a way to remove the earths magnetic field noise around the sensor so it cannot interfere with the sensors readings as if the earths magnetic field was virtually not present.
I've already written code that takes about 50 samples in each plane (x,y,z) and takes the average of each of the planes and outputs those readings minus the average offset values (Ex: Serial.print(x-xavg), Serial.print(y-yavg), Serial.print(z-zavg)). I did this to basically "zero out" the earths magnetic field, like zeroing a weight scale.
That wasn't really effective and results were not anywhere near constant after introducing and removing the local magnet, over and over again.
I've considered:
- a low pass filter
- sensor fusion using my gyroscope/accelerometer module (I know that sensor fusion is usually used to calibrate the Magnometer to be a more accurate compass, but is there anyway to use this technique to eliminate the earths magnetic field?)
- using data from http://www.magnetic-declination.com/ to tie into my calculations to offset the readings
- Using an electromagnet module to output the earths magnetic field inverted continuously in an attempt to cancel out the earths magnetic field
- trying to find a whole new sensor completely that does not have a low enough sensitivity to even detect earths magnetic field
So my questions are:
- Is there any way to do this?
Are any of my considerations practical or possible?
Are there even any 3d magnetic sensors on the market that do NOT pick up the earths magnetic field? - I've contacted SparkFun, Arrow, ST, and other companies about this exact question and never really get a sure answer on this question specifically?
if not, how was this man in the video able to reduce noise around his sensor? - He shows visually that his sensor is starting to filter out noise, saying that he's using an "adaptive averages" algorithm and links to some code, but I was unable to see/find that and don't understand how he is doing that?