from pulsesensor import Pulsesensor import time #this code assumes you have an MCP3008 with the analog heartbeat sensor on channel 0 p = Pulsesensor(channel=0, device=0) p.startAsyncBPM() try: while True: bpm = p.BPM if bpm > 0: print("BPM: %d" % bpm) else: print("No Heartbeat found") time.sleep(1) except: p.stopAsyncBPM()