Hall Effect Switch Tutorial

Hi All,

I recently picked up some cheap hall effect switches. Under the microscope, they say 44E 938. I think these are allegro hall effect sensors, though I’m usure as to the model number. I’ve been trying to figure out which pins are which on this switch, and which was is “left” on these switches, as well as their normal state. They’re normally “on” switches, as opposed to the normally “off” type I thought they were.

It took me a little while to figure out what they were and some characteristics about them, so I thought I’d document my findings for others to use should they also want to use a hall effect switch as an endstop. The switches themselves are cheap — around 20 cents or so each. They work with small magnets, with the field strength determining distance to activation. They need a 10K pull up resistor.

Wiring:

20130315-222708.jpg

With the numbers facing you on the table, ( So writing side up ), and the leads on the bottom, like in the picture, the leftmost pin is VCC ( +5V ), the middle pin is GND ( 0V ), and the right pin is signal. You need to attach a 10K resistor between the left pin and the right pin( aka a Pullup resistor between VCC and Signal ). The center pin goes to your MCU ground, the left pin goes to your +5V logic, and the right pin goes to your MCU’s input pin. So, if you’re using an Arduino UNO as your MCU, wire it up like this tutorial: I used pin 2 as my input pin.

http://www.hobbytronics.co.uk/arduino-tutorial11-hall-effect

Magnetic characteristics:

The output of the sensor is 1 when there is no magnet nearby ( HIGH ), and LOW(0) when there is a magnet nearby. The strength of the field depends on how far away the magnet can be. The more powerful the magnet, the farther away the switch will activate. The switch needs a surprisingly strong magnet — I used a very small neodymium magnet, about the size of a medium grain of rice, cubed( 3mm cubed )and got a reading at about 1/2 an index finger’s worth of distance. The switch also seems to be pole sensitive — I don’t know if it reads north or south — but the switch reads only one pole of the magnet.

Code:

Here’s the Arduino code to make it work.

int val = 0; // This holds the read value.
void setup()
{
pinMode(2, INPUT); // Read the input on pin 2
pinMode(13, OUTPUT); // I used pin 13 since it has an LED on the UNO built-in.
Serial.begin(9600); // I also wanted to confirm the value I read.
}

void loop()
{

val = digitalRead( 2 ); // Go read the pin.
Serial.println(val); // just to see on the serial monitor what I read.

if ( val == HIGH )
digitalWrite ( 13, HIGH ); // Turn on the LED when the value is high.
else
digitalWrite ( 13, LOW ); // Turn off the LED when the value is low.

}