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

The AH49E is a versatile, linear Hall effect device that is driven by the magnetic field of a permanent magnet or an electromagnet. The output voltage is set by the supply voltage and varies proportionally to the strength of the magnetic field. The integrated circuit features low output noise, eliminating the need for external filtering. The sensor features precision resistors for increased temperature stability and accuracy.

The sensor provides an analog voltage signal via its output, which indicates the strength of the magnetic field.

Technical data

Chipset AH49E
A low-noise output makes filtering practically superfluous
Reacts to positive and negative Gauss (Gauss is the unit in which Magnetic Force is measured)
Measuring range -40 °C to 85 ° C
Electricity consumption 3.5mA at 5 V
Functional area 3,3 V to 5 V

Pin Assignment

Code example Arduino

Connection assignment Arduino

Arduino Sensor
Pin A5 Signal
5 V +V
GND GND

The program measures the current voltage value on the sensor, calculates the current resistance value of the sensor from this and the known series resistor, and outputs the results on the serial output.

int sensorPin  =  A5 ;  //  Here the input-Pin is declared
 
// Serial output in 9600 baud
void setup ( )
{
    Serial.begin (9600);
}
 
// The program measures  the current voltage value on the sensor,
// calculates from these and the known serial resistance the current
// Resistance value of the sensor and outputs the results on the serial output
 
void loop ( )
{      
        //  Current voltage value is measured...
    int  rawValue = analogRead (sensorPin);
        float  voltage  =  rawValue *   (5.0/1023)   *  1000;
        
        float resitance  =  10 000  *   (voltage / (5000.0 – voltage));
        
    //  ... and here output to the serial interface
    Serial.print("Voltage value: ") ;  Serial.print(voltage) Serial.print("mV") ;
    Serial.print (", resistance value:");  Serial.print(resitance) Serial.println("Ohm") ;
    Serial.println (“---------------------------------------”)  ;

    delay (500)  ;
}

Sample program download

KY035-Arduino.zip

The AH49E is a versatile, linear Hall effect device that is driven by the magnetic field of a permanent magnet or an electromagnet. The output voltage is set by the supply voltage and varies proportionally to the strength of the magnetic field. The integrated circuit features low output noise, eliminating the need for external filtering. The sensor features precision resistors for increased temperature stability and accuracy.

The sensor provides an analog voltage signal via its output, which indicates the strength of the magnetic field.

Technical data

Chipset AH49E
A low-noise output makes filtering practically superfluous
Reacts to positive and negative Gauss (Gauss is the unit in which Magnetic Force is measured)
Measuring range -40 °C to 85 ° C
Electricity consumption 3.5mA at 5 V
Functional area 3,3 V to 5 V

Pin Assignment

Code example Raspberry Pi

Pin assignment Raspberry Pi

Raspberry Pi Sensor
3,3 V [Pin 1] +V
GND [Pin 6] GND
- Signal
Sensor KY-053
Signal A0
+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 were published under the MIT license under the following link https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15. The required libraries are not included in the lower download package.

The program measures the current voltage value at the ADC with the help of the ADS1115 ADC, calculates the current resistance of the NTC, calculates the temperature in advance with the help of certain values for this sensor and outputs it to the console.

Please note that you need to 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

#  Create the I2C bus
i2c  =  busio. I2C (board. SCL, board. SDA)

#  Create the  ADC object  using the  I2C  bus
ads  =  ADS.ADS1115(i2c)
voltageMax  =  3.3
#  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)


while True:
    resistance  =  chan0.voltage / (voltageMax – chan0.voltage)   *  10 000

    print (“Voltage value: “,'%.2f'  % chan0.voltage”,V, resistance:  ",'%.2f' % resistance,  "Ω" )
    print("---------------------------------------------------")
    time.sleep(1)

Sample program download

KY035-RPi.zip

To start with the command:

sudo python3 KY035-RPi.py

The AH49E is a versatile, linear Hall effect device that is driven by the magnetic field of a permanent magnet or an electromagnet. The output voltage is set by the supply voltage and varies proportionally to the strength of the magnetic field. The integrated circuit features low output noise, eliminating the need for external filtering. The sensor features precision resistors for increased temperature stability and accuracy.

The sensor provides an analog voltage signal via its output, which indicates the strength of the magnetic field.

Technical data

Chipset AH49E
A low-noise output makes filtering practically superfluous
Reacts to positive and negative Gauss (Gauss is the unit in which Magnetic Force is measured)
Measuring range -40 °C to 85 ° C
Electricity consumption 3.5mA at 5 V
Functional area 3,3 V to 5 V

Pin Assignment

Code example Micro:Bit

Connection assignment Micro:Bit:

Micro:Bit Sensor
3,3 V +V
GND GND
- Signal
Sensor KY-053
Signal A0
+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-035.zip

The AH49E is a versatile, linear Hall effect device that is driven by the magnetic field of a permanent magnet or an electromagnet. The output voltage is set by the supply voltage and varies proportionally to the strength of the magnetic field. The integrated circuit features low output noise, eliminating the need for external filtering. The sensor features precision resistors for increased temperature stability and accuracy.

The sensor provides an analog voltage signal via its output, which indicates the strength of the magnetic field.

Technical data

Chipset AH49E
A low-noise output makes filtering practically superfluous
Reacts to positive and negative Gauss (Gauss is the unit in which Magnetic Force is measured)
Measuring range -40 °C to 85 ° C
Electricity consumption 3.5mA at 5 V
Functional area 3,3 V to 5 V

Pin Assignment

Code example Raspberry Pi Pico

Pin assignment Raspberry Pi Pico

Raspberry Pi Pico Sensor
GND GND
3 V +V
- Signal
Sensor KY-053
GND -
+V -
Signal A0
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 calculates the current voltage value at the sensor, calculates the current resistance value of the sensor from this and the known series resistance and then outputs text on the serial output under certain conditions.

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

# Initialization of the ADC
ADS1115.init(0x48, 1, 4, False)

# 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))

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

    # Query whether the analog value has changed with serial output
    if Analog >= 27000:
        print("Limit value: reached.")
        print("----------------------------------------")
    else:
        print("Limit value: not reached.")
        print("----------------------------------------")
    sleep(2)

Example program download

KY035-Pico.zip