OH137 Arduino Hall Switch Tutorial

Introduction the Unipolar Hall Switch

OH137 Hall SwitchThis what is referred to as a Unipolar Magnetic Switch.   In a magnet, the lines of flux flow from the magnetic north pole to the magnetic south pole.

If these magnet lines of flux flow from the magnetic south pole, through the face of the device in sufficient density, the output will be sent low.   A more complete description what is being described here a little later.

These are often used for speed detection.  They can even be used to detect the proximity of physicals objects.

Where to buy these switches

These switches are available on both Amazon and eBay.




OH137 Hall Switch Pin Outs and Specifications

This device is supplied with power and ground.  When in the presence of a magnetic south pole, the output is sent low.  The image shows these pins.


OH137 Hall Pin Outs

VCC:  Anywhere from 4.5 to 12VDC

GND:  Circuit common or ground

OUT:  Goes low (25mA sink) in the presence of a properly oriented magnetic field of sufficient strength.

OH137 and the Magnetic Field Direction

As previously discussed, the OH137 is a unipolar device.  By that it means that the magnetic field must of sufficient strength and mus be oriented in the right direction to get an output.  The image below,  illustrates the what is required to produce a low output from the output pin.

OH137 Hall Switch Magnetic Field Direction


OH137 Hall Switch with an Arduino Tutorial

Connect Your Arduino to the OH137

You will need a 820 Ohm Resistor and a 20 pF capacitor ( a 22 pF will do ) to complete this set up.

OH137 Hall Arduino Tutorial Connections

Copy Paste and Upload the OH137 Tutorial Sketch


//Henry's Bench
//OH137 Hall Sensor Tutorial

int hallPin = 0; // Use Pin 0 as our Input
int hallVal = HIGH; // This is where we record the OH137 Input
boolean bMagneticField = false;

unsigned long lastDetectTime; // Record the time that we measured a Magnetic Field

int magFieldHoldTime = 500; // How long to hold the magnetic field detection on.

void setup ()
  pinMode (hallPin, INPUT) ; // input from the OH137
void loop ()
  hallVal = digitalRead (hallPin) ; // read OH137 Value
  if (hallVal == LOW) // means magnetic field detected
    lastDetectTime = millis(); // record the last time mag field was detected
    // The following is so you don't scroll on the output screen
    if (!bMagneticField){
      Serial.println("MAGNETIC SOUTH POLE DETECTED");
      bMagneticField = true;
    if( (millis()-lastDetectTime) > magFieldHoldTime  &&  bMagneticField){
      Serial.println("no magnetic field");
      bMagneticField = false;

Verify That the OH137 Works

Open your Arduino IDE serial monitor.   Now move a magnetic south pole close to the face of your switch.  If it is detected, the output on your serial monitor will indicate that a magnetic south pole has been detected as shown in the picture below.

OH137 Hall Arduino Tutorial Output

One Comment

  1. peter December 16, 2016

Leave a Reply

Your email address will not be published. Required fields are marked *