Ky-003 Hall Effect Sensor

Source: https://dragitanywhere.com/product/hall-effect-magnetic-sensor-module/

About the Sensor

The Ky-003 is a hall effect sensor, which is a type of sensor that detects magnetic fields. The hall effect sensor has three pins indicated from left to right in the image above: ground, power, and signal. The ground pin connects to ground on the arduino, the power pin connects to 5v, and the signal pin can connect to any of the digital pins. The sensor also has a built in LED that turns on when a magnet is nearby.

How it Works

The hall effect (source: https://store.techmaze.ae/product/99187578/)

The sensor uses the hall effect to act like a switch that can be turned on and off by a magnetic field. In its natural state, it sends electrons down a conductor and outputs a voltage. When a magnetic field is introduced, the magnet disrupts this flow of electrons and causes some of them to gather at one end of the conductor and the rest to gather at the opposite end. This disruption creates a charge known as the hall voltage, which is measured by the sensor. When the sensor detects the hall voltage, this indicates that a magnetic field is present, and the sensor’s voltage output is lowered. You can therefore detect a magnet using the hall effect sensor by checking to see if the voltage output value is low, which would indicate a nearby magnet. When there is no magnet detected, the voltage output will be high. Hall effect sensors have many practical uses such as acting as switches, detecting the speed of wheels, and sensing proximity.

Setting It Up

As you can see above, the first pin on the sensor connects to ground, the second connects to 5v, and the third connects to pin 3 on the arduino.

I got my sensor to work by following the tutorial from ArduinoModules, which led me to use the wiring setup shown above. I first tested its functionality just by having the LED 13 on the arduino light up when a magnet was near. When you remove the magnet, the LED is turned off. During my first tests, I found that this particular hall effect sensor only detects one side of a magnet, not both. I also found that a larger magnet like the one on the left in the image below was able to trigger the sensor from a further distance than the one on the right. The thinner magnet on the right needed to be touching the sensor to set it off. 

Motor Switch

After getting the sensor to work with the simple LED, I wanted to use it for a more practical application. As previously stated, hall effect sensors are often used as switches, especially the ky-003 because it only has digital output and not analog like other hall effect sensors. This means we can only read if the value is a 1 (there is no magnet present) or a 0 (there is a magnet present), whereas other hall effect sensors with analog output can provide data like the strength of the magnetic field. I used my hall effect sensor as a switch to trigger my servo motor. When the magnet is present, the motor moves to position 0. When the magnet is not present, the motor stays at position 90. Below are the schematics for the sensor and servo motor setup, as well as the code I used.

The main difference between this wiring setup and the previous setup is that I have connected ground and 5v to the positive and negative column rails on the breadboard, and then connected the sensor to ground and 5v via these rails. I also added in the servo motor, which connects to ground and 5v through the rails, as well as connecting to pin 9 on the arduino. 

My wiring set up with the servo motor

As you can see in the code above, you can set the sensor pin as an input and the LED and servo motor pins as the output. You can then read the value of the sensor using digitalRead(). If that value is low, this means there is a magnet present, and I told the LED 13 pin on the arduino to turn on and the servo motor to move to its new position (0). When the value is high, this means there is no magnet present, and I told the LED to turn off and the servo motor to return to its initial position (90). 

Video

Resources

Information on the ky-003 and the original schematics: https://arduinomodules.info/ky-003-hall-magnetic-sensor-module/

Information on the hall effect and how the sensor works and is commonly used: https://www.elprocus.com/hall-effect-sensor-working-principle-and-applications/

More information on the ky-003 and the hall effect: https://store.techmaze.ae/product/99187578/

Information on the servo motor was taken from the Elegoo Super Starter Kit for UNO tutorial: https://www.elegoo.com/blogs/arduino-projects/elegoo-uno-project-super-starter-kit-tutorial


Posted

in

by

Tags:

Comments

Leave a Reply

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