Duinotech Hall Effect Sensor with RaspberryPi

Hi everyone,

This is just a quick post to cover how the Duinotech hall effect sensor module (XC-4434) can be hooked up to a RaspberryPi.

Sample Code

The code below will output a zero when the sensor is activated by a magnet, otherwise a zero.


import time
import datetime
import RPi.GPIO as GPIO

# Define constants
BUCKET_HALL_EFFECT_SIG_PIN = 14

# Setup GPIO pins
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(BUCKET_HALL_EFFECT_SIG_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Important

while True:
print(str(GPIO.input(BUCKET_HALL_EFFECT_SIG_PIN))
time.sleep(0.5)

Wiring

Example

When near a magnetic field the light on the sensor will turn on. If you’re using the sample code above, a zero will be shown when close to a magnet, otherwise a 1.

Misc

Purchased from: https://www.jaycar.com.au/arduino-compatible-hall-effect-sensor-module/p/XC4434

Spec Sheet: Z7275

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s