MKR1000: PULSE SENSOR BPM_ALTERNATIVE

Hi, I’m the beginner in MKR1000

I want to do heart rate sensor(pulse sensor) with MKR1000

I did Firmware update+board manager+port(COMxx(ARDUINO/GENUINO MKR1000)

I found in MKR, there’re some specification that can’t use arduino uno interrupt

From it, because I want to use “BPM( not more like IBI,…)” so I started to edit

.cpp file of library

  1. "/*
    Formatting of Serial output from PulseSensors.
    See https://www.pulsesensor.com to get started.

Copyright World Famous Electronics LLC - see LICENSE
Contributors:
Joel Murphy, https://pulsesensor.com
Yury Gitman, https://pulsesensor.com
Bradford Needham, @bneedhamia, https://bluepapertech.com

Licensed under the MIT License, a copy of which
should have been included with this software.

This software is not intended for medical use.
*/
#include “PulseSensorSerialOutput.h”

PulseSensorSerialOutput::PulseSensorSerialOutput() {
pOutput = NULL;
OutputType = SERIAL_PLOTTER;
}

void PulseSensorSerialOutput::setSerial(Stream &output) {
pOutput = &output;
}

Stream *PulseSensorSerialOutput::getSerial() {
return pOutput;
}

void PulseSensorSerialOutput::setOutputType(byte outputType) {
OutputType = outputType;
}

void PulseSensorSerialOutput::outputSample(PulseSensor sensors, int numSensors) {
if (!pOutput) {
return; // no serial output object has been set.
}

switch (OutputType) {
case SERIAL_PLOTTER:
if (numSensors == 1) {
pOutput->print(sensors[0].getBeatsPerMinute());
pOutput->print(F(","));
pOutput->print(sensors[0].getInterBeatIntervalMs());
pOutput->print(F(","));
pOutput->println(sensors[0].getLatestSample());
} else {
for (int i = 0; i < numSensors; ++i) {
if (i != 0) {
pOutput->print(F(","));
}
pOutput->print(sensors*.getLatestSample());*

  • // Could output BPM and IBI here.*
  • }*
  • pOutput->println();*
  • }*
  • break;*
  • case PROCESSING_VISUALIZER:*
  • // Don’t print bpm and ibi here; they’re printed per-beat.*
  • if (numSensors == 1) {*
  • outputToSerial(‘S’, sensors[0].getLatestSample());*
  • } else {*
  • // PulseSensor 0 = a; #1 = b; #2 = c, etc.*
  • for(int i = 0; i < numSensors; ++i){*
    _ outputToSerial(‘a’ + i, sensors*.getLatestSample());_
    _
    }_
    _
    }_
    _
    break;_
    _
    default:_
    _
    // unknown output type: no output*_
    * break;*
    * }*
    }
    void PulseSensorSerialOutput::outputBeat(PulseSensor sensors[], int numSensors, int sensorIndex) {
    * if (!pOutput) {*
    * return; // no serial output object has been set.*
    * }*
    * switch (OutputType) {*
    * case SERIAL_PLOTTER:
    _ /
    * The plotter doesn’t understand occasionally-printed data,*
    * so we print nothing per-beat.*
    /_
    _
    break;_
    case PROCESSING_VISUALIZER:
    _ / if (numSensors == 1) {
    * outputToSerial(‘B’, sensors[sensorIndex].getBeatsPerMinute());*
    * outputToSerial(‘Q’, sensors[sensorIndex].getInterBeatIntervalMs());*
    * } else {*
    * // PulseSensor 0 = A, M; #1 = B, N; etc.*
    * outputToSerial(‘A’ + sensorIndex*
    * , sensors[sensorIndex].getBeatsPerMinute());*
    * outputToSerial(‘M’ + sensorIndex*
    * , sensors[sensorIndex].getInterBeatIntervalMs());*
    * }*
    break;/_
    _
    default:_
    _
    // ★modified*_
    * outputToSerial(‘B’, sensors[sensorIndex].getBeatsPerMinute());*
    * break;*
    * }*
    }
    * // // testing feedback*
    * // void printThreshSetting() {*
    * //*
    * // }*
    void PulseSensorSerialOutput::outputToSerial(char symbol, int data) {
    * if (!pOutput) {*
    * return; // no serial output object has been set.*
    * }*
    * pOutput->print(symbol);*
    * pOutput->println(data);*
    }
    "
    ==================
    When I modified some "★"part in library(GitHub - WorldFamousElectronics/PulseSensorPlayground: A PulseSensor library (for Arduino) that collects our most popular projects in one place.)
    but it still prints like
    0,362,780
    0,362,782
    0,362,782
    0,362,781
    0,362,784
    0,362,782
    How I can get only “BPM” value by edit some cpp code?

You should use CODE TAGS ( </> ) when posting error messages or sketches.

This has come up a couple of times in the past with no clear answer apart from the one which suggests a library re-write to take into account the different MCU.
You could put in a github request but make sure it is on the most used and current library.

As you have found most of the heartbeat libraries are AVR only.
Had the same issues here and reverted to an Arduino mini for my project.

Thank you for your help!

I didn’t know about </> haha

I got some answer on github-issue part(https://github.com/WorldFamousElectronics/PulseSensorPlayground/issues/74 )

I will try it !

Thank you!