I keep forgetting how to properly orientate the magnets for my the hall effect sensors. Courtesy of Allegro (the maker of these fine sensors) I copy the significant bit of their application guide.
Operating Mode Enhancements: Compound Magnets
Because the active area of a Hall switch is close to the branded face of the package, it is usually operated by approaching this face with a magnetic south pole. It is also possible to operate a Hall switch by applying a magnetic north pole to the back side of the package. While a north pole alone is seldom used, the push-pull configuration (simultaneous application of a south pole to the branded side and a north pole to the back side) can give much greater field strengths than are possible with any single magnet (see figure 43). Perhaps more important, push-pull arrangements are quite insensitive to lateral motion and are worth considering if a loosely fitting mechanism is involved.Figure 43. Examples of compound magnet configurations (either the Hall device or the magnet assembly can be stationary), with a south pole toward the branded face and a north pole toward the back side: (left) push-pull head-on and (right) push-pull slide-by
Figure 44 shows the flux-density curve for an actual push-pull slide-by configuration that achieves a magnetic slope of about 315 G/mm.Figure 44. Example of magnetic flux characteristic in push-pull slide-by magnet configuration
Another possibility, a bipolar field with a fairly steep slope (which also is linear), can be created by using a push-push configuration in the head-on mode (see figure 45).Figure 45. Example of a push-push head-on compound magnet configuration (either the Hall device or the magnet assembly can be stationary), with south poles toward both the branded face and the back side
In the push-push, head-on mode configuration shown in figure 45, the magnetic fields cancel each other when the mechanism is centered, giving zero flux density at that position. Figure 46 shows the flux-density plot of such a configuration. The curve is linear and moderately steep at better than 315 G/mm. The mechanism is fairly insensitive to lateral motion.
Figure 46. Example of push-push head-on mode magnet configuration, in which the fields cancel in the middle of the travel range