Connecting MAX30102 With Rasberry Pi Using I2C Protocol and reading ADC values
This blog helps you to connect the max30102 a heart rate sensor from maxim integrated to the Rasberry Pi.
Components required
- MAx30102 Datasheet
- Raspberry Pi (suggestion: better to use version greater than 3)
- connecting wires
Enabling I2C on Pi
- Open the terminal and enter the following command
sudo raspi-config
After typing the above command you will get a screen similar to the one as shown. Goto
- Interfacing Options > I2C > Enable
Now the Raspberry Pi supports I2c communication.
Installing the required libraries
The smbus2 library is used to communicate with the sensor using I2C.
The GPIO library helps to access the GPIO pins on the Raspberry Pi.
pip install smbus2
pip install RPi.GPIO
Connecting Pi to the sensor.
- Make the connection from the sensor to the Pi as shown below.
Here is an image for the pinout of the Pi for better understanding.
Running the program
Download the library from this link. File name max30102.py and put this in your present working directory. Then open a new file where u like to code in the same directory.
import max30102
m = max30102.MAX30102()
red, ir = m.read_sequential()
print("red values:",red,"/n","ir values:",ir)
The output will be something like this :
red values: [82014, 135086, 139003, 139005, 139118, 139366, 139662…….
ir values: [82000, 123334, 123450, 123431, 123459, 123551, 123678, ……
GIT LINK : link