Pulse sensoring with Makepython

A project log for MakePython

Python development board based on ESP8266/ESP32/nRF52840, etc., for Python Development and Projects

MakerfabsMakerfabs 12/21/2019 at 02:210 Comments

A simple& cheap Pulse Sensor is a photoelectric reflex analog sensor for pulse and heart rate measurement. Wear it on finger, earlobe and so on, make use of the body tissue in the vascular pulse caused by different transmittance to measure pulse. Then the heart rate value can be obtained by simple calculation.

On the left is the s-pin of the signal output, in the middle is the positive power supply VCC (3.3v ~5V), and on the right is the negative power supply GND.

The special pin for ADC collection is IO0.The input voltage is 0V~ 1.0v and the measured value is 0~1024, The s-pin is connected to IO0, the middle pin is connected to 3V3, and the "-" pin is connected to GND:

the MicroPython codes:

#from machine import Pin,I2C,RTC
import machine
from micropython import const
import time
import ssd1306
import math

WIDTH = const(128)	#Set the screen width
HEIGHT = const(64)		#Set the screen high
pscl = machine.Pin(5, machine.Pin.OUT)
psda = machine.Pin(4, machine.Pin.OUT)
i2c = machine.I2C(scl=pscl, sda=psda)
oled = ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c)


while True:
adc = machine.ADC(0)			#Create an ADC object on an ADC pin			#ADC data acquisition
  oled.line(counttime,40,counttime,adcValue//16,1)   #Drew the heart rate

    oled.fill(0)      #Clear the screen