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):
<iframe src="//commons.wikimedia.org/wiki/File:Hall_Sensor.webm?embedplayer=yes" width="640" height="480" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
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.
Get KY-024 Module
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.Wiring
Wiring can be found below.
The wiring is easy, the module can be powered using 5V/GND, then there are 2 outputs wired with Analog/Digital pins.Codes
Code can be found below
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.Test
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.
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.