# how far must a magnetometer be away form a magnet

Hello,

I am thinking to use a magnetometer to obtain the angle of my robot respect to the magnetic north pole so i can get find which direction i am going on the platform. Problem is i am thinking of using a electromagnet with my robot to grab some stuff. I have two dc motor 3-6V nominal voltage. Electromagnet i am planning to use have a current about 50-100mA with 7V battery. How far should i have to place the magnetometer from the DC motors and electromagnet to get rid of the magnetic effect of the other components? Is it a bad idea to use magnetometer for this project? Is it more convenient to use rotary encoders for both wheels?

I don't know if it is affecting. I am planning to buy one but before that i want to learn if it is suitable for my project. I should give some details. Robot has two wheels and shaped as circle. Radius of the surface of robot is about 60mm. I have an electormagnet and it can grab a specimen i have to take from some place and put it another location. Specimen is shaped as circle and radius of specimen is 10mm. It is stell and weigh about 50gr=0.1pounds. Also electomagnet is going to be placed 100mm away from the robot.

I thought instead of a gripper, it would be better to use an electromagnet. It is more practical. However i doubt that this electromagnet and dc motors may affect the magnetic field so the magnetometer gives me the wrong direction. As i learnt, the magnetic field value of the world is about 0.6Gauss. But it doesn't mean anything for me :D.

I think if i place the magnetometer enough away from the electromagnet, its effect on the magnetic field around the magnetometer becomes much lower because of the inverse square law. But i don't know anything about calculating magnetic field of an electromagnet and value of magnetic field around a point in the space. So i don't know how far should i place the magnetometer.

With rotay encoder, i know how much each whell turns, with this information i can calculate the difference and calculate how much does the system turns with the knowledge of the distance between wheels :D I don't know if it is a lopng shot because of the accumulation errors or whell slipping or other reasons. But i have no choice to calculate the angle data without these two option.

By the way platform which robot works on is a rectangle and size of the rectangle is 1meterX1meter

I would be inclined to say that “yes - an external magnet is going to introduce some form of error in the reading from the magnetometer”; its just like a compass - nearby external magnets and ferrous materials will affect the readings.

However, since you know where you magnet will be, and it won’t be shifting around on the robot (right?), you can factor out the error; take a reading without the magnet on, take another with the magnet on, and note the difference - then apply this difference in reading when you are reading with the magnet on to get what the reading would be “normally”.

At least, that’s how I would approach things…

the magnetic field value of the world is about 0.6Gauss. But it doesn't mean anything for me

The field is similar to that of a bar magnet.

So it sounds like your magnet is going to be about the same strength as the field you are trying to measure. Fortunately the magnetic field drops of as the inverse cube of the distance so it rapidly diminishes with distance. So in answer to you question, it must be as far as possible but each time you double the distance you get 1/12th of the field.