Hall Sensor (AH1815, from Treston)
Overview
Hall sensors are available from the Treston. The presence of a magnetic field switches their output pin (pin 3) from HIGH to LOW.
Detection distance: ~1cm
Pictures illustrating short range of sensor
To test the range of the Hall sensor. I used my nametag magnet and held it far away from the sensor. I slowly brought the magnet close until I read a low signal on the digital pin to which I wired the output of this sensor (yellow jumper wire going to Arduino digital pin 8). The images below demonstrate the threshold distance close enough to trigger the sensor, as well as the fact that the sensor detects a field behind or in front of it.
Magnetic field operating point: ~350 Gauss (a cheap kitchen magnet is around 100 Gauss, a strong magnet is 200-2,000 Gauss)
Pinout for the AH1815, note the orientation/non-flat face is up
How to use
You will need to add a pull-up resistor to the output pin. I'd recommend a 10k resistor.
Image above is from this component's data sheet
See if you can wire this circuit just based off of the image above!
Need help?
I will show you an image below of how I wired it onto a breadboard. Importantly, you could wire this differently, or solder on longer wires onto each pin of the Hall sensor, or solder this onto a protoboard.
Regardless of whether you are using a breadboard or soldering, you need to make sure that:
- Leftmost pin goes to power (2.5-5.5V input range, so you can use this with a 3.3V microcontroller)
- Middle pin goes to ground
- Rightmost pin goes to a digital pin on your microcontroller
- Add a 10kOhm resistor between power and rightmost (output) pin
- Add a 100 nF capacitor across power and ground to decrease noise
Sample Arduino code
Troubleshooting
1) There's no output when I run the code above
- Make sure you've opened the Serial monitor and the baud rate in the code matches that in the dropdown menu
2) The output bounces all over the place
- Verify that you have the pull-up resistor installed between power and output
- Verify that the value of the pull-up resistor is between 10k and 100kOhms
3) The output thinks there is a magnet there when there isn't
- Verify that a pull-up resistor is present
4) It's too slow
- Decrease the delay(100) to delay(10), etc.





