Experiment: Magnetic Ruler

From phyphox
Jump to navigation Jump to search
Magnetic Ruler
Experiment Magnetic Ruler
Category Tools
Used sensors Magnetometer

The experiment "Magnetic ruler" is not an experiment on its own, but a tool to measure distances and velocities. You have to set up a "magnetic ruler" by placing several magnets in fixed intervals along the path along which the phone will move. phyphox will use the magnetometer to detect the magnets and count how often and in which time it has passed a magnet. You have to provide the distance between the magnets, so phyphox can calculate the total distance and the average speed for each interval.


  • As this is not an experiment on its own, you need something that you want to measure. In the demo video, you can see an example where the speed of a toy train is found with this method.
  • You will need several magnets. When choosing the "right" magnets, you should consider how close they will get to your phone in your actual experiment. If the distance is large, you may have to pick stronger magnets (i.e. rare earth magnets), but you do not want to expose your phone to strong magnetic fields as this may damage your phone and especially its compass function. Therefore never (!) place a strong magnet directly at your phone. On the other hand, the signal should be stronger than the earth's magnetic field. If you are unsure about the choice of magnets or the appropriate distance for the magnets that you already have, start the "Magnetometer" experiment to get raw readings from the magnetometer and slowly move your magnet towards your phone while noting the measured field. Readings in the range of 100µT to 1000µT would be ideal, so choose your magnets or the distance in your setup accordingly.
  • As the phone usually is inaccessible in a moving setup, you certainly want to remote control it in this experiment. So a second device for the remote interface is usually required as well.


Place your magnets at equal distances along a path and enter the distance in the "magnetic ruler" experiment in phyphox. The experiment should be designed in such a way, that the phone passes every magnet in the same distance, because the magnetic field will depend heavily on this distance and magnets are easily missed if the distances vary. This method works best for setups with rails and it may help to find out where the magnetometer is located within your phone.

Start the experiment just before you start the movement while the phone is still resting. Let the phone move along the magnets. Then stop the measurement before removing the phone from the setup to avoid additional data from other magnetic fields. You should have a plot of the distance as well as the velocity over time.


Phyphox will consider the squared total field and remove constant and slowly changing contributions with a high pass. Each magnet should appear in the data as a separate strong peak with small negative parts next to it (a side effect of the high pass). A set of data is considered to be a single peak when all values in this range are larger than 10% of the maximum of all data recorded in this run. For each peak phpyhox will search for the maximum and take this as the point in time at which a magnet was passed.

Finally the distance just adds up for each magnet at the time it is passed and the velocity is the ratio of the distance of a single interval to the time between to passed magnets.

Problems and resolutions

  • Magnets are missed / detected unreliably. This is usually caused by varying distances to the magnets. Slight deviations may easily lead to significantly different fields, so make sure that each magnet is "seen" in the same way. Also make sure that the distance is not too small. If the fields influence each other, the result may become hard to interpret. Finally, you should check that the poles of all magnets are aligned in the same direction.
  • Strong fields are seen during the experiment independent from magnets. If an electric motor is part of your experiment you might see the fields generated by the motor. For example if you place your phone directly on the motor of a toy train, you will see a strong field that depends on the applied voltage. In such cases, you can try to add some padding between the motor and the phone to increase the distance. Also, it might help to accelerate more slowly as the magnet detection is less sensitive to slowly changing unwanted fields.
  • There is a huge distance step at the beginning/end. This usually happens when placing the phone or picking it up before or at the end of the experiment. You may get close to one of your magnets or just turn your phone in the earth's magnetic field and trigger the detection. Therefore, start the experiment when the phone is in place and stop it before picking up the phone again.

Demonstration video