I would like to mount a bracket onto the head tube of a bike frame to measure the degree of rotation the bike's handlebars have been turned. Ideally, this would be a contactless solution to increase the chance of the bracket fitting correctly.

Two of the options I have researched are:

  • A Hall Effect sensor on the fixed head tube and a magnet on the rotating bike fork
  • Optical sensor on the fixed head tube and encoded object on the rotating bike fork

Before I delve too deep into creating a Hall Effect prototype, does anyone have a better suggestion than the above options or any tips on how to best design this sensor?

Thanks in advance!


@TelaClavo @RocketMagnet Thankyou both of you guys for the detailed answers. I think due to the requirement of mounting the sensor(s)/magnet on the perimeter of the head tube I am more favoured towards TelaClavo's solution. The sensor would be located in a bracket fitting on the front of the head tube, just above the moving ring between the head tube and fork. The magnets attached around the ring.

The assumption I am making now, is that in order to accommodate head tubes of different diameters, a universal bracket can be manufactured to house the PCB components and sensors to fit flush to the head tube in both the sensor and magnets.

  • \$\begingroup\$ Some kind of ratchet wheel which flicks a momentary SPDT switch left or right. (Think: Wheel of Fortune). If you turn left, it clicks left-left-left, and if you turn right, it clicks right-right-right. There could be an extra switch which is flicked when you pass center by a lone peg, causing recalibration. \$\endgroup\$
    – Kaz
    May 16, 2012 at 22:54

3 Answers 3


With a single Hall-effect sensor, if you don't want to deal with the mechanical complexity of having to position your magnet right on the axis of rotation, and the sensor close to it, but steady, and choose to place the magnet in a spot on the perimeter of the rotating tube, and the sensor on the fixed tube, you won't have a very good SNR when the magnet is away from the sensor. I would use a few (three or four) sensors, and one magnet. Create a PCB with the shape of an arc of a circle, and put there the N sensors, concentrically, plus your analog circuitry (if needed), and your MCU (with N ADC channels). Secure the PCB to the fixed tube, and the magnet, to the rotating tube. Reading the N input signals, you'll be able to deduce the angle of the handle bar with more than decent resolution.

Responses to comments: (I don't have enough space there).

  • Rocketmagnet: In the second half of your answer, the AM8192B1 is not a single Hall-effect sensor. It is an IC with many Hall-effect sensors inside. See page 1 of the datasheet: "The AM8192B1 uses Hall sensor technology to detect the magnetic flux density distribution at the surface of the silicon. Hall sensors are placed in a circular array around the center of the IC and deliver a voltage representation of the magnetic field distribution." That's exactly my answer. As far as your comment, you were right, and I've edited my answer.
  • \$\begingroup\$ Normally, your answers are excellent, but this is just wrong. You certainly can tell the angle with a single magnet and single sensor. \$\endgroup\$ May 17, 2012 at 8:23
  • 1
    \$\begingroup\$ @Rocketmagnet See answer to your comment in my text. \$\endgroup\$
    – Telaclavo
    May 17, 2012 at 9:37

My suggestion would definitely be the Hall Effect solution. We use these extensively for rotation measurement, and they work very well. There are two ways to do it:

Ratiometric Hall Effect:

Use a device like the A1324. It's a 3-pin device which gives an analog voltage proportional to the magnetic field strength. For a magnet, you have two options:

  • A diametrically polarised ring magnet mounted on the steering column. The sensor should sit at the circumference of the magnet, facing the centre.
  • An axially polarised button magnet. Mount it on the steering column with its diameter colinear with the rotation axis.

Hall effect sensors

As the steering column rotates, the analog output voltage will vary sinusoidally with angle. Therefore, if you need to know the exact angle, you'll need to calibrate it. Take readings with the handlebars at several known angles. Then create either a piecewise linear function, or find the correct parameters for the perfect inverse sin function. Added: This option only works if we assume that the handle bars don't rotate more than about ±75º, preferably less than that.

Rotary Magnetic Encoder IC


RLS have several good Hall Effect based rotary sensor chips. You simply place a diametrically polarised button magnet on top of them, and it can tell you the rotation to 13-bit resolution. The AM8192B1 is the highest resolution one. Added: This is the option to choose if you need to measure rotations beyond ±90º degrees.

  • \$\begingroup\$ Suppose your top left figure. Let's define Theta=0 when N points to your sensor. What voltages will the sensor output when Theta= +10º and when Theta= -10º ? \$\endgroup\$
    – Telaclavo
    May 17, 2012 at 9:35
  • \$\begingroup\$ @Telaclavo - You have this all wrong. You should never let N or S point to the sensor. When the handle bars are straight, the sensor should be half way between N and S. At this point, the sensor will output 2.5v. When the handle bars turn left, the output falls. When the handle bars turn right, the output rises. \$\endgroup\$ May 17, 2012 at 10:05
  • \$\begingroup\$ @Telaclavo - Obviously, this only works for mechanisms which rotate less than about 150º, like handle bars. Preferably no more than 100º for good SNR. \$\endgroup\$ May 17, 2012 at 10:07
  • \$\begingroup\$ You are right. I just couldn't find in the datasheet what's the axis with respect to which the projection of B is measured and outputted. Ok, the axis is perpendicular to the branded surface (man, they should put that in the first page, and not hidden in page 5). And yes, you can tell the sign with a single sensor. However, to do that, you need to place the magnet right on the axis of rotation or otherwise the distance between magnet and sensor will be too long, for many angles. Having the magnet on the axis will make it slightly more cumbersome to hold the sensor steady close to it. \$\endgroup\$
    – Telaclavo
    May 17, 2012 at 11:52

Accelerometer+Gyro for handle bar would probably work. If you add a Hall sensor, it could be compensated for drift very well.

I almost design something like this for a customer but at the end he couldn't find the money and I end up just dreaming it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.