• 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 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.

Note on use

This sensor is ideally suited for threshold measurement. This means that the sensor emits a digital high signal as soon as a threshold value set by the user is exceeded. However, this also means that the analog measured values are not suitable for conversions, as the analog signal is also influenced by the rotary potentiometer.

Digital output: If a magnetic field is detected, a signal is output here.

Analog output: Direct measured value of the sensor unit

LED1: Indicates that the sensor is supplied with voltage

LED2: Indicates that a magnetic field has been detected

Technical data

Chipset AH49E
Sensor Type Hall effect transistor/switch
Accuracy 9 to 12 Bit
Measuring range -40 °C up to +150 °C
Functional range 5V (Due to the components)

Functionality of the sensor

This sensor has three functional components on its circuit board: The front sensor unit, which physically measures the environment and outputs it as an analog signal to the second unit, the amplifier. This amplifies the signal depending on the resistance set on the rotary potentiometer and sends it to the analog output of the module.

Here it is to be noted: The signal is inverted. If a high value is measured, this results in a lower voltage value at the analog output.

The third unit represents a comparator, which switches the digital output and the LED when the signal falls below a certain value. This value (and thus the sensitivity of the module) can be adjusted via the rotary potentiometer:

Pin assignment

Code example Arduino

Pin assignment Arduino

Arduino Sensor
5 V +V
GND GND
Pin 3 Digital Signal
Pin A0 Analog Signal

The program reads the current voltage value, which can be measured at the analog output, and outputs it on the serial interface.

In addition, the state of the digital pin is also indicated in the console. This indicates whether the limit value has been exceeded.

// Declaration and initialization of the input pins
int Analog_Input = A0; // Analog output of the sensor
int Digital_Input = 3; // Digital output of the sensor
  
void setup ()
{
  pinMode (Analog_Input, INPUT);
  pinMode (Digital_Input, INPUT);
       
  Serial.begin (9600); // Serial output with 9600 bps
}

// The program reads the current values of the input pins
// and outputs them to the serial output
void loop ()
{
  float Analog;
  int Digital;
    
  //Actual values are read, converted to the voltage value....
  Analog = analogRead (Analog_Input) * (5.0 / 1023.0); 
  Digital = digitalRead (Digital_Input);
    
  //... and output at this position
  Serial.print ("Analog voltage value:"); Serial.print (Analog, 4); Serial.print ("V, ");
  Serial.print ("Limit value:");
  
  if(Digital==1)
  {
      Serial.println (" reached");
  }
  else
  {
      Serial.println (" not yet reached");
  }
  Serial.println ("----------------------------------------------------------------");
  delay (200);
}

Sample program download

KY024-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 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.

Note on use

This sensor is ideally suited for threshold measurement. This means that the sensor emits a digital high signal as soon as a threshold value set by the user is exceeded. However, this also means that the analog measured values are not suitable for conversions, as the analog signal is also influenced by the rotary potentiometer.

Digital output: If a magnetic field is detected, a signal is output here.

Analog output: Direct measured value of the sensor unit

LED1: Indicates that the sensor is supplied with voltage

LED2: Indicates that a magnetic field has been detected

Technical data

Chipset AH49E
Sensor Type Hall effect transistor/switch
Accuracy 9 to 12 Bit
Measuring range -40 °C up to +150 °C
Functional range 5V (Due to the components)

Functionality of the sensor

This sensor has three functional components on its circuit board: The front sensor unit, which physically measures the environment and outputs it as an analog signal to the second unit, the amplifier. This amplifies the signal depending on the resistance set on the rotary potentiometer and sends it to the analog output of the module.

Here it is to be noted: The signal is inverted. If a high value is measured, this results in a lower voltage value at the analog output.

The third unit represents a comparator, which switches the digital output and the LED when the signal falls below a certain value. This value (and thus the sensitivity of the module) can be adjusted via the rotary potentiometer:

Pin assignment

Code example Raspberry Pi

Pin assignment Raspberry Pi

Raspberry Pi Sensor
GPIO 24 [Pin 18] Digital Signal
3,3 V [Pin 1] +V
GND [Pin 6] GND
- Analog Signal
Sensor KY-053
Digital Signal A0
Analog Signal -
+V -
GND -
Raspberry Pi KY-053
GPIO 3 [Pin 5] SCL
GPIO 2 [Pin 3] SDA
3,3 V [Pin 1] VDD
GND [Pin 6] GND

Analog sensor, therefore the following must be considered: The Raspberry Pi has, in contrast to the Arduino, no analog inputs or there is no ADC (analog digital converter) integrated in the chip of the Raspberry Pi. This limits the Raspberry Pi, if you want to use sensors, which do not output digital values, but a continuously changing value (example: potentiometer -> different position = different voltage value).

To avoid this problem, our sensor kit X40 contains the KY-053, a module with a 16-bit ADC, which you can use on the Raspberry to expand it with 4 analog inputs. This module is connected to the Raspberry Pi via I2C, takes over the analog measurement and transfers the value digitally to the Raspberry Pi.

So we recommend to connect the KY-053 module with the mentioned ADC in between for analog sensors of this set. You can find more information on the KY-053 Analog Digital Converter information page.

The program uses the corresponding ADS1x15 and I2C Python libraries from Adafruit to control the ADS1115 ADC. These have been published at the following link https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 under the MIT license. The required libraries are not included in the download package below.

The program reads the current values of the input pins and outputs them to the console as a value in [mV].

Please note that you must enable I2C on your Raspberry Pi before using this example.

#!/usr/bin/python
# coding=utf-8

import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)

# Create the ADC object using the I2C bus
ads = ADS.ADS1115(i2c)

# Create single-ended input on channels
chan0 = AnalogIn(ads, ADS.P0)
chan1 = AnalogIn(ads, ADS.P1)
chan2 = AnalogIn(ads, ADS.P2)
chan3 = AnalogIn(ads, ADS.P3)

delayTime = 1
Digital_PIN = 24

GPIO.setup(Digital_PIN, GPIO.IN, pull_up_down = GPIO.PUD_OFF)

while True:
    analog = '%.2f' % chan0.voltage
 
    # output to console
    if GPIO.input(Digital_PIN) == False:
        print ("Analog voltage value:", analog, "V, ", "Limit: not yet reached")
    else:
        print ("Analog voltage value:", analog, "V, ", "Limit: reached")
    print ("---------------------------------------")
 
    # reset + delay
    button_pressed = False
    time.sleep(delayTime)

Sample program download

KY024-RPi.zip

To start with the command:

sudo python3 KY024-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 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.

Note on use

This sensor is ideally suited for threshold measurement. This means that the sensor emits a digital high signal as soon as a threshold value set by the user is exceeded. However, this also means that the analog measured values are not suitable for conversions, as the analog signal is also influenced by the rotary potentiometer.

Digital output: If a magnetic field is detected, a signal is output here.

Analog output: Direct measured value of the sensor unit

LED1: Indicates that the sensor is supplied with voltage

LED2: Indicates that a magnetic field has been detected

Technical data

Chipset AH49E
Sensor Type Hall effect transistor/switch
Accuracy 9 to 12 Bit
Measuring range -40 °C up to +150 °C
Functional range 5V (Due to the components)

Functionality of the sensor

This sensor has three functional components on its circuit board: The front sensor unit, which physically measures the environment and outputs it as an analog signal to the second unit, the amplifier. This amplifies the signal depending on the resistance set on the rotary potentiometer and sends it to the analog output of the module.

Here it is to be noted: The signal is inverted. If a high value is measured, this results in a lower voltage value at the analog output.

The third unit represents a comparator, which switches the digital output and the LED when the signal falls below a certain value. This value (and thus the sensitivity of the module) can be adjusted via the rotary potentiometer:

Pin assignment

Code example Micro:Bit

Pinout Micro:Bit:

Micro:Bit Sensor
Pin 1 Digital Signal
3,3 V +V
GND GND
- Analog Signal
Sensor KY-053
Analog Signal A0
Digital Signal -
+V -
GND -
Micro:Bit KY-053
Pin 19 SCL
Pin 20 SDA
3,3 V VDD
GND GND

Analog sensor, therefore the following must be observed: The Micro:Bit has analog inputs or there is an ADC (analog digital converter) integrated in the chip of the Micro:Bit. However, these are only limited to 10-bit and therefore offer only a rather low accuracy for analog measurements.

To avoid this problem, our sensor kit X40 contains the KY-053, a module with a 16-bit ADC, which you can use on the Micro:Bit to expand it by 4 analog inputs. This is connected to the Micro:Bit via I2C, takes over the analog measurement and transfers the value digitally to the Micro:Bit.

Therefore we recommend to connect the KY-053 module with the mentioned ADC in between for analog sensors of this set. More information can be found on the KY-053 Analog Digital Converter information page KY-053 Analog Digital Converter.

The program uses the corresponding library from us to control the ADS1115 ADC. This has been published under the following link pxt-ads1115 under the MIT-License.

Sample program download

microbit-KY-025

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 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.

Note on use

This sensor is ideally suited for threshold measurement. This means that the sensor emits a digital high signal as soon as a threshold value set by the user is exceeded. However, this also means that the analog measured values are not suitable for conversions, as the analog signal is also influenced by the rotary potentiometer.

Digital output: If a magnetic field is detected, a signal is output here.

Analog output: Direct measured value of the sensor unit

LED1: Indicates that the sensor is supplied with voltage

LED2: Indicates that a magnetic field has been detected

Technical data

Chipset AH49E
Sensor Type Hall effect transistor/switch
Accuracy 9 to 12 Bit
Measuring range -40 °C up to +150 °C
Functional range 5V (Due to the components)

Functionality of the sensor

This sensor has three functional components on its circuit board: The front sensor unit, which physically measures the environment and outputs it as an analog signal to the second unit, the amplifier. This amplifies the signal depending on the resistance set on the rotary potentiometer and sends it to the analog output of the module.

Here it is to be noted: The signal is inverted. If a high value is measured, this results in a lower voltage value at the analog output.

The third unit represents a comparator, which switches the digital output and the LED when the signal falls below a certain value. This value (and thus the sensitivity of the module) can be adjusted via the rotary potentiometer:

Pin assignment

Code example Raspberry Pi Pico

Pin assignment Raspberry Pi Pico

Raspberry Pi Pico Sensor
- Analog Signal
GND GND
3 V +V
GPIO18 Digital Signal
Sensor KY-053
Analog Signal A0
GND -
+V -
Digital Signal -
Raspberry Pi Pico KY-053
GPIO1 SCL
GPIO0 SDA
3 V VDD
GND GND

Analog sensor, therefore the following must be observed

The Raspberry Pi Pico has analog inputs for the internal ADC (analog digital converter) in the chip of the Raspberry Pi Pico, but this ADC has only a resolution of 12-bit.

To bypass this 12-bit ADC, our sensor kit X40 with the KY-053 has a module with 16-bit accurate ADC, which you can use on the Raspberry Pi Pico to expand it with 4 analog inputs. This module is connected to the Raspberry Pi Pico via I2C, takes over the analog measurement and passes the value digitally to the Raspberry Pi Pico.

Therefore we recommend to connect the KY-053 module with the mentioned ADC in between for analog sensors of this set. More information can be found on the information page for the KY-053 Analog Digital Converter.

The program uses the corresponding ADS1115-Micropython library from Joy-IT to control the ADS1115 ADC. This has been published under the following linkhttps://github.com/joy-it/ADS1115-Micropython under the MIT License. The required library is included in the download package below.

The program reads the current voltage value, which can be calculated by reading the analog output, and outputs it on the serial interface.

In addition, the state of the digital pin is also indicated in the console. This indicates whether the limit value has been exceeded.

# Load libraries
from machine import Pin
from time import sleep
import ADS1115

# Initialization of the ADC
ADS1115.init(0x48, 1, 4, False)
# Initialization of GPIO18 as input
digital = Pin(18,Pin.IN, Pin.PULL_UP)

# Endless loop for reading out the ADC
while True:
    Analog = ADS1115.read(0)
    # Conversion from analog value to voltage
    Volt = ADS1115.raw_to_v(ADS1115.read(0))
    Dig = digital.value()

    # Serial output of the analog value and the calculated voltage
    print("Analog value: " + str(Analog))
    print("Analog voltage value: " + str(An) + " V")

    # Query whether the digital value has changed with serial output
    if Dig == 1:
        print("Limit: reached.")
        print("----------------------------------------")
    else:
        print("Limit: not yet reached.")
        print("----------------------------------------")
    sleep(2)

Example program download

KY024-Pico.zip