Skip to content

Interfacing Hall-Effect sensor with Arduino []


Get your Hall Effect sensor Buy here !

      Hello everyone, and welcome to another tutorial Sponsored by: DigitSpace

This is a fast and straightway tutorial on how to interface you Hall-Effect sensor with Arduino board, here I’m using Arduino UNO as usual. So the Hall-Effect is the production of a voltage difference (the Hall voltage) across an electrical conductor, transverse to an electric current in the conductor and to an applied magnetic field perpendicular to the current.
Here in the media below you can see a simple visualisation of the effect (Source: Wikipedia):


This effect is exploited to detect position, speed, current and proximity sensing, today we gonna use it with a magnet, to detect the magnetic field and check the values given by the sensor.

In the picture below you can see the sensor I’m using, it’s a KY-024, and as you can see that board is pretty much common, it’s used for different sensors.

Hall Effect sensor

The module is powered by 5V and has 2 outputs, one is Analog and its DC offset can be set using the trimmer potentiometer, and there’s a Digital output that can be either HIGH or LOW depending on the magnetic field strength and the threshold you’ve set using the trimmer potentiometer.


The wiring is easy, the module can be powered using 5V/GND, then there are 2 outputs wired with Analog/Digital pins:

Wiring 1_bb


No libraries is needed for this module.


One easy code has been made and it’s just for test, it can display the Analog and Digital output values on the Serial monitor, and of course those two values can be exploited in your project based on this module.

Here you can download the code: Download code


So here in the test as I didn’t have a straight magnet, I used a speaker magnet which has a radial magnetic field, which means that there’s a pole on the outside circle and one on the inside circle, and here I just put the sensor on some places of the magnet.

Test 1
(Click to expand) The values are around 512 which is the middle of the Arduino ADC on standby mode
Test 2
(Click to expand) Here I’m putting the sensor on the outside part of the magnet and the LED lights up, but the analog value drops down to around 470
Test 3
(Click to expand) On the middle of the speaker magnet the LED is turned off and the analog value is Up to 620

And don’t forget that the Digital output threshold can be set by the trimmer potentiometer, it can set the DC offset of the Analog output aswell.

Big thanks to the tutorial sponsor


Yassine View All

Automation and Electrical Engineer, Electronics amateur trying to share my little projects.

Leave a Reply

%d bloggers like this: