• Arduino
  • Raspberry Pi
  • Raspberry Pi Pico
  • Micro:Bit

Hall-effect switches are integrated circuits with magnetic specifications. This means that all required components are already integrated in the sensor and it has an increased sensitivity with respect to magnetic fields. The sensor is suitable for continuous operation at temperatures up to +150 °C and is characterized by its stability to temperature and supply voltage changes. Each unit is equipped with a reverse polarity protection diode, a square Hall voltage generator, temperature compensation circuit, 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 A3144
Measuring range -40°C to +150°C
Sensor Type Hall Effect Transistor/Switch
Function range 5V (Due to the LED)

Pin Assignment

Code example Arduino

Pin assignment Arduino

Arduino Sensor
Pin 10 signal
5 V +V
GND GND
Arduino Sensor
Pin 13 LED+
GND 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, for example, 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);
  }
  else
  {
    digitalWrite (Led, HIGH);
  }
}

Example program download

KY003-Arduino.zip

Hall-effect switches are integrated circuits with magnetic specifications. This means that all required components are already integrated in the sensor and it has an increased sensitivity with respect to magnetic fields. The sensor is suitable for continuous operation at temperatures up to +150 °C and is characterized by its stability to temperature and supply voltage changes. Each unit is equipped with a reverse polarity protection diode, a square Hall voltage generator, temperature compensation circuit, 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 A3144
Measuring range -40°C to +150°C
Sensor Type Hall Effect Transistor/Switch
Function range 5V (Due to the LED)

Pin Assignment

Code example Raspberry Pi

Pin assignment Raspberry Pi

Sensor with 5V logic level: In contrast to the Arduino, the Raspberry Pi does not have a 5V logic level. This limits the Raspberry Pi, if you want to use sensors that have a supply voltage of 5V.

To avoid this problem, our sensor kit X40 contains the KY-051, a module for logic level conversion, which you can use on the Raspberry. This is simply connected to the Raspberry Pi with 5V, 3.3V and ground. On the pins A1 to A4 are then connected the lines that lead to the Raspberry Pi and on the pins B1 to B4 are then connected the lines that come from the sensors.

Therefore we recommend to use the KY-051 module for sensors with 5V logic level of this set. More information can be found on the information page for the KY-051 Voltage Translator.

Raspberry Pi Sensor
- Signal
5V [Pin 4] +V
GND [Pin 6] GND
KY-051 Sensor Raspberry Pi
A1 - GPIO 24 [Pin 18]
B1 Signal -
Vcca - 3,3V [Pin 1]
Vccb - 5V [Pin 4]
GND - GND [Pin 6]

This is a sample program that prints a console output when as signal is detected at the sensor.

from gpiozero import Button
import time

# The sensor is initialized as a button object with the internal pull-up resistor activated.
sensor = Button(24, pull_up=True)

print("Sensor test [press CTRL+C to end the test]")

# This function is executed when a signal is detected (falling edge).
def ausgabeFunktion():
    print("Signal recognized")

# The 'outputFunction' function is bound to the 'when_pressed' event of the sensor.
sensor.when_pressed = ausgabeFunktion

# Main program loop
try:
    while True:
        time.sleep(1)

# Clean-up work after the program has been completed
except KeyboardInterrupt:
    print("Program ended")

Example program download

KY003-RPi.zip

To start with the command:

sudo python3 KY003-RPi.py

Hall-effect switches are integrated circuits with magnetic specifications. This means that all required components are already integrated in the sensor and it has an increased sensitivity with respect to magnetic fields. The sensor is suitable for continuous operation at temperatures up to +150 °C and is characterized by its stability to temperature and supply voltage changes. Each unit is equipped with a reverse polarity protection diode, a square Hall voltage generator, temperature compensation circuit, 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 A3144
Measuring range -40°C to +150°C
Sensor Type Hall Effect Transistor/Switch
Function range 5V (Due to the LED)

Pin Assignment

Code example Micro:Bit

Pinout Micro:Bit:

Micro:Bit Sensor
- Signal
5V [External] +V
GND GND
KY-051 Sensor Micro:Bit
B1 Signal -
A1 - Pin 1
Vcca - 3,3V
Vccb - 5V [External]
GND - GND + [External GND]

Example program download

microbit-KY-003.zip

Hall-effect switches are integrated circuits with magnetic specifications. This means that all required components are already integrated in the sensor and it has an increased sensitivity with respect to magnetic fields. The sensor is suitable for continuous operation at temperatures up to +150 °C and is characterized by its stability to temperature and supply voltage changes. Each unit is equipped with a reverse polarity protection diode, a square Hall voltage generator, temperature compensation circuit, 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 A3144
Measuring range -40°C to +150°C
Sensor Type Hall Effect Transistor/Switch
Function range 5V (Due to the LED)

Pin Assignment

Code example Raspberry Pi Pico

Pin assignment Raspberry Pi Pico

Raspberry Pi Pico Sensor
- Signal
5V [External] +V
GND + [External GND] GND
KY-051 Sensor
B1 Signal
A1 -
Vcca -
Vccb -
GND -
KY-051 Raspberry Pi Pico
B1 -
A1 GPIO26
Vcca 3,3V
Vccb 5V [External]
GND GND + [External GND]

This is a sample program that outputs serial text when a signal is detected at the sensor.

# Load libraries
from machine import Pin, Timer
from time import sleep

# Initialization of GPIO as input
sensor = Pin(26, Pin.IN, Pin.PULL_DOWN)

# Continuous loop for continuous serial output
while True:
    if sensor.value() == 0:
        print("No magnetic field")
    else:
        print("Magnetic field")

    print("------------------------------------------------------")
    sleep(0.5)

Example program download

KY003-Pico.zip