Hall-effect switches are monolithic integrated circuits with tighter magnetic specifications, meaning that the sensor is made of one piece, has increased sensitivity to magnetic fields, and that everything needed is already built directly into the sensor itself, which is suitable for continuous operation over temperatures up to +150°C and is more stable to temperature as well as supply voltage changes. Each unit includes a voltage regulator for operation with supply voltages from 4.5 to 24 volts, a reverse polarity protection diode, a square Hall voltage generator, temperature compensation circuitry, small signal amplifier, Schmitt trigger and an open collector output to sink up to 25 mA. The transistor switches through if the module is held in a magnetic field. This can then be read out at the signal output as an analog voltage value.

Technical data

chipset A3141
Measuring range -40°C to +150°C
Sensor Type Hall Effect Transistor/Switch
Function range 4.5V up to 24V

Pin Assignment

Code example Arduino

Pin assignment Arduino

Arduino Sensor
pin 10 signal
5V +V
ground GND
Arduino Sensor
Pin 13 LED+
ground LED-

This is an example program, which lights up a LED, if a signal is detected at the sensor. The modules KY-011, KY-016 or KY-029 can also be used as LEDs, for example.

int Led = 13 ;// declaration of the LED output pin
int Sensor = 10 ;// Declaration of the sensor input pin
int val; // Temporary variable
void setup ()
  pinMode (Led, OUTPUT) ; // Initialize output pin
  pinMode (Sensor, INPUT) ; // Initialize sensor pin
  digitalWrite(Sensor, HIGH) ; // Activate internal pull-up resistor
void loop ()
  val = digitalRead (Sensor) ; // The current signal at the sensor is read out
  if (val == HIGH) // If a signal could be detected, the LED is switched on.
    digitalWrite (Led, LOW);
    digitalWrite (Led, HIGH);

Sample program download


Code example Raspberry Pi

Pin assignment Raspberry Pi

Raspberry Pi Sensor
GPIO 24 [Pin 18] Signal
3.3V [Pin 1] +V
Ground [Pin 6] GND

This is a similar example program with the difference that here no LED is lit but something is output to the console when a signal is detected.

# import the needed modules and set them up
import RPi.GPIO as GPIO
import time
# Here the input pin is declared, to which the sensor is connected. Additionally the PullUP resistor at the input will be activated
GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
print ("Sensor test [press CTRL+C to exit test]")
# This outputFunction is executed on signal detection
def outputFunction(null):
        print("Signal detected")
# When a signal is detected (falling signal edge) the output function is executed
GPIO.add_event_detect(GPIO_PIN, GPIO.FALLING, callback=outputFunction, bouncetime=100) 
# main program loop
        while True:
# clean up after the program is finished
except KeyboardInterrupt:

Sample program download


To start with the command:

sudo python3 KY003.py

Code example Micro:Bit

Pinout Micro:Bit:

Micro:Bit Sensor
Pin 1 Signal
3V +V
Ground GND

This is a MakeCode example for Micro:Bit which essentially does the same as the examples of the other two variants. However, this example is closer to the Raspberry Pi example than the Arduino example.

Sample program download