Interfacing Hall Effect sensor with Arduino

Interfacing Hall Effect sensor with Arduino © GPL3+

Easy way to interface Hall Effect sensor to be used later for proximity sensing, speed measuring and switching

  • 749 views
  • 0 comments
  • 4 respects

Components and supplies

About this project

Tutorial video if needed

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.

Code

Hall_Effect_Test.inoArduino
Straight test
/* This code is to be used with KY-024 Hall effect sensor
 * It displays both Analog and Digital values given by the sensor
 * Refer to www.surtrtech.com for more details
 */

#define Hall_Sensor A0          //A0 used with analog output, D2 with digital output
#define Hall_Sensor_D 2

int Val1=0,Val2=0;             //Here you can store both values, the Val2 can be boolean


void setup() {
  Serial.begin(9600);
  pinMode(Hall_Sensor_D,INPUT);
 

}

void loop() {
  
   Val1=analogRead(Hall_Sensor);            //We read both values and display them raw on the serial monitor
   Serial.print(Val1);
   Val2=digitalRead(Hall_Sensor_D);
   Serial.print("\t");
   Serial.println(Val2);
}

Schematics

wiring_1_bb_Yg5YBPWTMq.png
Straight wiring
Wiring 1 bb yg5ybpwtmq

Comments

Similar projects you might like

Displaying Sensor Values on LCD

by Wimpie van den Berg

  • 73,639 views
  • 6 comments
  • 52 respects

How to Use a Soil Moisture Sensor

by MisterBotBreak

  • 35,579 views
  • 13 comments
  • 44 respects

Simple Homemade Flex Sensor

by Shahir nasar

  • 8,811 views
  • 1 comment
  • 11 respects

DHT11 Temperature/Humidity Sensor

Project tutorial by Zachary Haslam

  • 71,098 views
  • 7 comments
  • 64 respects
Add projectSign up / Login