Skip to main content

Posts

Showing posts from June, 2025

Interfacing Vibration Sensor with Raspberry Pi 3 💥

Interfacing Vibration Sensor with Raspberry Pi 3 💥 🎯 Objective To detect vibration or shock using a Vibration Sensor module (SW-420) with Raspberry Pi 3. Useful in industrial machinery monitoring and security systems. 🧰 Components Required Component Quantity Raspberry Pi 3 1 SW-420 Vibration Sensor Module 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) GPIO27 (Pin 13) 🧠 Python Code import RPi.GPIO as GPIO import time VIBRATION_PIN = 27 GPIO.setmode(GPIO.BCM) GPIO.setup(VIBRATION_PIN, GPIO.IN) try: while True: if GPIO.input(VIBRATION_PIN): print("💥 Vibration Detected!") else: print("🟢 No Vibration.") time.sleep(0.5) except KeyboardInterrupt: GPIO.cleanup() 📊 Output 💥 Displays "Vibration Detected!" if vibration is sensed. 🟢 Displa...

Interfacing Hall Effect Sensor with Raspberry Pi 3 🧲

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

Interfacing Flex Sensor with Raspberry Pi 3 🤸

Interfacing Flex Sensor with Raspberry Pi 3 🤸 🎯 Objective To read the bending position of a Flex Sensor using an ADC (MCP3008) with Raspberry Pi 3. This setup is useful in gesture control and wearable electronics. 🧰 Components Required Component Quantity Raspberry Pi 3 1 Flex Sensor 1 10KΩ Resistor 1 MCP3008 ADC 1 Breadboard & Jumper Wires As required ⚡ Circuit Connections Flex Sensor + MCP3008 + Raspberry Pi 3 MCP3008 Pin Connect To VDD & VREF 3.3V (Pin 1) AGND & DGND GND (Pin 6) CLK GPIO11 (Pin 23) DOUT GPIO9 (Pin 21) DIN GPIO10 (Pin 19) CS/SHDN GPIO8 (Pin 24) CH0 Flex sensor voltage divider output 🧠 Python Code import spidev import time spi = spidev.SpiDev() spi.open(0, 0) spi.max_speed_hz = 1350000 def read_channel(channel): adc = spi.xfer2([1, (8 + channel) 📊 Output Shows analog value corresponding to how much the sensor is bent. The more it bends, the higher the value. 💡 App...

Interfacing Pulse Sensor with Raspberry Pi 3 ❤️

Interfacing Pulse Sensor with Raspberry Pi 3 ❤️ 🎯 Objective To detect heartbeats using a Pulse Sensor and monitor pulse rate on a Raspberry Pi 3 using an MCP3008 ADC. 🧰 Components Required Component Quantity Raspberry Pi 3 1 Pulse Sensor 1 MCP3008 ADC 1 Jumper Wires As required Breadboard 1 ⚡ Circuit Connections Connect the Pulse Sensor to MCP3008 and Raspberry Pi 3 as follows: Pulse Sensor Pin Connect To VCC 3.3V (RPi Pin 1) GND GND (RPi Pin 6) Signal CH0 of MCP3008 🔄 MCP3008 to Raspberry Pi Connections MCP3008 Pin RPi Pin VDD, VREF 3.3V (Pin 1) AGND, DGND GND (Pin 6) CLK GPIO11 (Pin 23) DOUT GPIO9 (Pin 21) DIN GPIO10 (Pin 19) CS/SHDN GPIO8 (Pin 24) 🧠 Python Code import spidev import time spi = spidev.SpiDev() spi.open(0, 0) spi.max_speed_hz = 1350000 def read_channel(channel): adc = spi.xfer2([1, (8 + channel) 📊 Output Prints analog values that represent the pulse waveform. Can be p...

Interfacing CO₂ Sensor with Raspberry Pi 3 🌫️

Interfacing CO₂ Sensor with Raspberry Pi 3 🌫️ 🎯 Objective To measure carbon dioxide (CO₂) levels using a CO₂ sensor (like MG-811 or MH-Z19) with Raspberry Pi 3 for air quality monitoring. 🧰 Components Required Component Quantity Raspberry Pi 3 1 CO₂ Sensor (MG-811 or MH-Z19) 1 Level Shifter / Logic Converter 1 (for UART sensors) Jumper Wires As required Breadboard 1 ⚡ Circuit Connections For MH-Z19 CO₂ sensor (using UART): MH-Z19 Pin Connect To VCC 5V (RPi Pin 2) GND GND (RPi Pin 6) TX GPIO15 (RX, Pin 10) via level shifter RX GPIO14 (TX, Pin 8) via level shifter 🧠 Python Code import serial import time ser = serial.Serial("/dev/serial0", baudrate=9600, timeout=1) def read_co2(): ser.write(b"\xFF\x01\x86\x00\x00\x00\x00\x00\x79") response = ser.read(9) if len(response) == 9: high = response[2] low = response[3] co2 = (high 📊 Output Displays CO₂ concentration i...

Interfacing IR Temperature Sensor with Raspberry Pi 3 🌡️

Interfacing IR Temperature Sensor with Raspberry Pi 3 🌡️ Interfacing IR Temperature Sensor with Raspberry Pi 3 🌡️ Infrared temperature sensors are non-contact sensors that detect the temperature of objects by sensing emitted infrared radiation. Today, we’ll learn how to interface an IR sensor (like MLX90614) with a Raspberry Pi 3. 🎓 🔧 Components Required Component Quantity Raspberry Pi 3 1 IR Temp Sensor (MLX90614) 1 Jumper Wires 4 Breadboard (optional) 1 🪛 Pin Connections Sensor Pin Raspberry Pi Pin Pin Number VCC 3.3V Pin 1 GND Ground Pin 6 SDA GPIO 2 (SDA) Pin 3 SCL GPIO 3 (SCL) Pin 5 Figure: IR Sensor connected to Raspberry Pi 3 ⚙️ Enabling I2C on Raspberry Pi Open terminal: sudo raspi-config Go to Interfacing Options > I2C and enable it. Reboot your Raspberry Pi. 💻 Python Code import smbus import time bus = smbus.SMBus(1) addres...

Interfacing GPS Module with Raspberry Pi 3 🌍

Interfacing GPS Module with Raspberry Pi 3 🌍 Interfacing GPS Module with Raspberry Pi 3 🌍 Global Positioning System (GPS) modules help us get location data like latitude, longitude, speed, altitude, and more! Let's learn how to connect a GPS module (like NEO-6M) to Raspberry Pi 3 and read real-time location. 🛰️📡 🔧 Components Required Component Quantity Raspberry Pi 3 1 GPS Module (NEO-6M) 1 Jumper Wires 4 USB to TTL Converter (Optional) 1 🔌 GPS Module to Pi Connections GPS Pin Raspberry Pi Pin Pin Number VCC 3.3V / 5V Pin 1 or 4 GND Ground Pin 6 TX GPIO15 (RXD) Pin 10 RX GPIO14 (TXD) Pin 8 Figure: GPS Module connected to Raspberry Pi 3 ⚙️ Enable Serial Interface Run: sudo raspi-config Go to Interfacing Options > Serial Disable shell access over serial and enable serial hardware Reboot your Raspberry Pi 📦 Install Required Packages...

Interfacing Load Cell with Raspberry Pi 3 (via HX711) ⚖️

Interfacing Load Cell with Raspberry Pi 3 (via HX711) ⚖️ Interfacing Load Cell with Raspberry Pi 3 (via HX711) ⚖️ A load cell is a transducer that converts force (weight) into an electrical signal. The HX711 is a precision 24-bit analog-to-digital converter (ADC) designed for weigh scales. Today we’ll connect a load cell to Raspberry Pi 3 using the HX711 module. 🧪 🔧 Components Required Component Quantity Raspberry Pi 3 1 Load Cell 1 HX711 Module 1 Jumper Wires 6 Breadboard (optional) 1 🔌 Pin Connections HX711 Pin Raspberry Pi Pin Pin Number VCC 5V Pin 2 GND Ground Pin 6 DT GPIO 5 Pin 29 SCK GPIO 6 Pin 31 Figure: Load Cell connected to Raspberry Pi 3 via HX711 💻 Python Code from hx711 import HX711 import RPi.GPIO as GPIO import time hx = HX711(dout_pin=5, pd_sck_pin=6) hx.set_reading_format("MSB", "MSB") hx.set_reference_unit(1) hx.reset()...

Interfacing Color Sensor (TCS3200) with Raspberry Pi 3 🎨

Interfacing Color Sensor (TCS3200) with Raspberry Pi 3 🎨 Interfacing Color Sensor (TCS3200) with Raspberry Pi 3 🎨 The TCS3200 color sensor can detect various colors using its array of photodiodes and filters. Let’s interface it with Raspberry Pi 3 and detect different object colors! 🌈 🔧 Components Required Component Quantity Raspberry Pi 3 1 TCS3200 Color Sensor 1 Jumper Wires 8 🔌 Pin Connections Sensor Pin Raspberry Pi Pin Pin Number VCC 3.3V Pin 1 GND Ground Pin 6 S0 GPIO 17 Pin 11 S1 GPIO 27 Pin 13 S2 GPIO 22 Pin 15 S3 GPIO 23 Pin 16 OUT GPIO 24 Pin 18 Figure: TCS3200 Color Sensor connected to Raspberry Pi 3 💻 Python Code import RPi.GPIO as GPIO import time # Set up GPIO pins for S0-S3 and OUT GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.OUT) GPIO.setup(27, GPIO.OUT) GPIO.setup(22, GPIO.OUT) GPIO.setup(23, GPIO.OUT) GPIO.setup(24, GPIO.IN) GPIO.output(...

Interfacing pH Sensor with Raspberry Pi 3 🌿

Interfacing pH Sensor with Raspberry Pi 3 🌿 Interfacing pH Sensor with Raspberry Pi 3 🌿 pH sensors help us monitor the acidity or alkalinity of water and soil. This guide explains how to interface a pH sensor (via MCP3008 ADC) with Raspberry Pi 3 for real-time monitoring. 🧪🌱 🔧 Components Required Component Quantity Raspberry Pi 3 1 pH Sensor 1 MCP3008 ADC 1 Jumper Wires Several Breadboard 1 🔌 Pin Connections MCP3008 Pin Connection Raspberry Pi Pin VDD, VREF 3.3V Pin 1 AGND, DGND GND Pin 6 CH0 pH Sensor Output - DIN MOSI GPIO10 (Pin 19) DOUT MISO GPIO9 (Pin 21) CLK Clock GPIO11 (Pin 23) CS Chip Select GPIO8 (Pin 24) Figure: pH Sensor interfaced with Raspberry Pi 3 using MCP3008 💻 Python Code import spidev import time spi = spidev.SpiDev() spi.open(0, 0) spi.max_speed_hz = 1350000 def read_channel(channel): adc = spi.xfer2([1, (8 + channel...

Interfacing Joystick Module with Raspberry Pi 3 🎮

Interfacing Joystick Module with Raspberry Pi 3 🎮 Interfacing Joystick Module with Raspberry Pi 3 🎮 A joystick module is a fun way to capture directional input using two potentiometers and a switch. With Raspberry Pi 3, it’s great for games, robot control, and UI navigation! 🕹️ 🔧 Components Required Component Quantity Raspberry Pi 3 1 Joystick Module (Analog) 1 ADC MCP3008 1 Jumper Wires Multiple 🔌 Pin Connections The joystick gives analog values. Since RPi doesn't support analog input, we use MCP3008 ADC. MCP3008 Pin RPi Pin Joystick Channel CH0 Joystick VRx X-axis CH1 Joystick VRy Y-axis DOUT GPIO 9 (MISO) - DIN GPIO 10 (MOSI) - CLK GPIO 11 (SCLK) - CS GPIO 8 (CE0) - VDD/VREF 3.3V - AGND/DGND GND - Figure: Joystick interfaced using MCP3008 to Raspberry Pi 3 💻 Python Code import spidev import time spi = spidev.SpiDev() spi.open(0, 0) sp...

🪪Interfacing RFID Reader (RC522) with Raspberry Pi 3

Interfacing RFID Reader (RC522) with Raspberry Pi 3 🪪 Interfacing RFID Reader (RC522) with Raspberry Pi 3 🪪 The RC522 is a widely used RFID reader for 13.56 MHz tags. With a Raspberry Pi 3, we can use it to identify and authenticate users using RFID cards. 🧾 🔧 Components Required Component Quantity Raspberry Pi 3 1 RC522 RFID Reader 1 RFID Tags/Cards 1+ Jumper Wires 7 🔌 Pin Connections RFID Pin Raspberry Pi Pin Pin Number SDA GPIO 8 (CE0) Pin 24 SCK GPIO 11 (SCLK) Pin 23 MOSI GPIO 10 (MOSI) Pin 19 MISO GPIO 9 (MISO) Pin 21 IRQ Not Connected - GND Ground Pin 6 3.3V 3.3V Pin 1 Figure: RFID Reader RC522 connected to Raspberry Pi 3 💻 Python Code # Install library # git clone https://github.com/pimylifeup/MFRC522-python.git import RPi.GPIO as GPIO from mfrc522 import SimpleMFRC522 reader = SimpleMFRC522() try: print("Place your tag...") ...

🌫️ Interfacing Raspberry Pi 3 with MQ-135 Air Quality Sensor

MQ-135 Sensor with Raspberry Pi 3 🎯 Objective In this project, we will use the MQ-135 Air Quality Sensor with Raspberry Pi 3 to monitor air pollution levels. This sensor is often used in indoor air quality systems. 🧰 Components Required Component Quantity Raspberry Pi 3 1 MQ-135 Air Quality Sensor 1 MCP3008 ADC Module 1 Breadboard 1 Jumper Wires As needed Power Supply 1 💡 MQ-135 provides analog output. RPi needs MCP3008 ADC to convert analog to digital. ⚡ Circuit Connections Sensor to MCP3008: From (MQ-135) To VCC 5V (RPi3) GND GND (RPi3) AOUT CH1 (MCP3008) MCP3008 to RPi3: MCP3008 Pin RPi3 GPIO VDD, VREF 3.3V AGND, DGND GND CLK GPIO11 DOUT GPIO9 DIN GPIO10 CS GPIO8 🧠 Python Code import spidev import time spi = spidev.SpiDev() spi.open(0, 0) spi.max_speed_hz = 1350000 def read_channel(channel): adc = spi.xfer2([1, (8 + channel) << 4, 0]) data = ((adc[1] & 3) << 8) + ...