Interfacing Hall Effect Sensor with Raspberry Pi 3 ๐งฒ
๐ฏ Objective
To detect the presence of magnetic fields using a Hall Effect Sensor and Raspberry Pi 3. Useful for speed sensing, door detection, and proximity sensing applications.
๐งฐ Components Required
Component | Quantity |
Raspberry Pi 3 | 1 |
Hall Effect Sensor Module | 1 |
Magnet | 1 |
Jumper Wires | As required |
Breadboard | 1 |
⚡ Circuit Connections
Sensor Pin | Connect To |
VCC | 3.3V (Pin 1 on RPi) |
GND | GND (Pin 6 on RPi) |
D0 (Digital Out) | GPIO17 (Pin 11) |
๐ง Python Code
import RPi.GPIO as GPIO
import time
HALL_SENSOR_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(HALL_SENSOR_PIN, GPIO.IN)
try:
while True:
if GPIO.input(HALL_SENSOR_PIN) == 0:
print("๐งฒ Magnet Detected!")
else:
print("✅ No Magnetic Field.")
time.sleep(0.5)
except KeyboardInterrupt:
GPIO.cleanup()
๐ Output
- Displays "๐งฒ Magnet Detected!" when magnet is near sensor.
- Displays "✅ No Magnetic Field." when magnet is not nearby.
๐ก Applications
- Door sensors
- Speed sensors in motors
- Proximity switches
๐ฏ เคเคฆ्เคฆिเคท्เค
เคนॉเคฒ เคเคซेเค्เค เคธेเคจ्เคธเคฐ เคตाเคชเคฐूเคจ เคुंเคฌเคीเคฏ เค्เคทेเคค्เคฐाเคी เคเคณเค เคชเคเคตเคฃे เคเคฃि เคฐाเคธ्เคชเคฌेเคฐी เคชाเคฏ 3 เคตเคฐ เคคो เคกेเคा เคตाเคชเคฐเคฃे.
๐งฐ เคฒाเคเคฃाเคฐे เคธाเคนिเคค्เคฏ
เคเคเค | เคธंเค्เคฏा |
Raspberry Pi 3 | 1 |
เคนॉเคฒ เคเคซेเค्เค เคธेเคจ्เคธเคฐ | 1 |
เคुंเคฌเค | 1 |
เคंเคชเคฐ เคตाเคฏเคฐ्เคธ | เคเคฐเคेเคจुเคธाเคฐ |
เคฌ्เคฐेเคกเคฌोเคฐ्เคก | 1 |
⚡ เคธเคฐ्เคिเค เคเคจेเค्เคถเคจ
เคธेเคจ्เคธเคฐ เคชिเคจ | เคोเคกเคฃी |
VCC | 3.3V (Raspberry Pi เคตเคฐ) |
GND | GND (Raspberry Pi เคตเคฐ) |
D0 | GPIO17 (Pin 11) |
๐ง เคชाเคเคฅเคจ เคोเคก
import RPi.GPIO as GPIO
import time
HALL_SENSOR_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(HALL_SENSOR_PIN, GPIO.IN)
try:
while True:
if GPIO.input(HALL_SENSOR_PIN) == 0:
print("๐งฒ เคुंเคฌเค เคเคขเคณเคฒा เคเคนे!")
else:
print("✅ เคोเคฃเคคेเคนी เคुंเคฌเคीเคฏ เค्เคทेเคค्เคฐ เคจाเคนी.")
time.sleep(0.5)
except KeyboardInterrupt:
GPIO.cleanup()
๐ เคเคเคเคชुเค
- ๐งฒ เคुंเคฌเค เคเคตเคณ เคเคฒ्เคฏाเคธ "เคुंเคฌเค เคเคขเคณเคฒा เคเคนे!" เค
เคธा เคธंเคฆेเคถ เคฆिเคธเคคो.
- ✅ เคเคฐ เคुंเคฌเค เคเคตเคณ เคจเคธेเคฒ เคคเคฐ "เคोเคฃเคคेเคนी เคुंเคฌเคीเคฏ เค्เคทेเคค्เคฐ เคจाเคนी." เค
เคธा เคธंเคฆेเคถ เคฆिเคธเคคो.
๐ก เคเคชเคฏोเค
- เคฆเคฐเคตाเคाเคे เคธेเคจ्เคธเคฐ्เคธ
- เคฎोเคเคฐเคฎเคงीเคฒ เคเคคी เคธेเคจ्เคธिंเค
- เคช्เคฐॉเค्เคธिเคฎिเคी เคธ्เคตिเคेเคธ
Comments