How to filter or eliminate earths magnetic field from 3D Magnetic sensor?

Im using the SparkFun MAG3110 3D sensor: SparkFun Triple Axis Magnetometer Breakout - MAG3110 - SEN-12670 - SparkFun Electronics

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): Fun With a Non-Contact Magnetic Joystick - YouTube

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 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

  1. Is there any way to do this?

  2. Are any of my considerations practical or possible?

3 .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?

  1. 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?

Show the FFT frequency spectrum of the signal that you describe as 'noise' generated by the earths magnetic field.

Use a strong magnet and ignore the tiny offset due to the Earth's magnetic field.

Is the joystick bolted to a large block of concrete? What happens if it is moved during operation?

Use a stronger magnet closer to the sensor.