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) << 4, 0])
data = ((adc[1] & 3) << 8) + adc[2]
return data
try:
while True:
pulse_value = read_channel(0)
print("❤️ Pulse Sensor Reading:", pulse_value)
time.sleep(0.1)
except KeyboardInterrupt:
spi.close()
📊 Output
- Prints analog values that represent the pulse waveform.
- Can be plotted or used to count BPM (beats per minute).
💡 Applications
- Heart rate monitoring
- Wearable fitness devices
- Health monitoring systems
🎯 उद्दिष्ट
Pulse Sensor वापरून हृदयाचे ठोके (Pulse) मोजणे आणि Raspberry Pi 3 वर त्याचे वाचन करणे.
🧰 लागणारे साहित्य
घटक | संख्या |
Raspberry Pi 3 | 1 |
Pulse Sensor | 1 |
MCP3008 ADC | 1 |
जंपर वायर | गरजेनुसार |
ब्रेडबोर्ड | 1 |
⚡ सर्किट कनेक्शन
Pulse Sensor पिन | जोडणी |
VCC | 3.3V |
GND | GND |
Signal | MCP3008 च्या CH0 वर |
🔄 MCP3008 ते Raspberry Pi कनेक्शन
MCP3008 | RPi पिन |
VDD, VREF | 3.3V |
AGND, DGND | GND |
CLK | GPIO11 |
DOUT | GPIO9 |
DIN | GPIO10 |
CS/SHDN | GPIO8 |
🧠 पाइथन कोड
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) + adc[2]
return data
try:
while True:
pulse_value = read_channel(0)
print("❤️ Pulse Sensor वाचन:", pulse_value)
time.sleep(0.1)
except KeyboardInterrupt:
spi.close()
📊 आउटपुट
- Pulse Sensor चे एनालॉग वाचने दाखवते.
- हृदयाचे ठोके मोजण्यासाठी किंवा ग्राफ काढण्यासाठी वापरता येते.
💡 उपयोग
- हृदय गती मापन
- फिटनेस वाच उपकरणे
- आरोग्य देखरेख प्रणाली
Comments