How to use blynk in arduino uno with esp8266 for pulse rate

I think the PulseSensorPlayground library already attaches an interrupt to A0 when this code is used…

const int PulseWire = 0;  

pulseSensor.analogInput(PulseWire);

The problem is that the library is setting the callback function that’s called when an interrupt occurs. The library is also using a timer to calculate BPM and returning this back to the code when this library function call is made:

int myBPM = pulseSensor.getBeatsPerMinute();

There’s a bit more detail here:

I don’t think that there’s gong to be a simple solution to making this work with Blynk, unless Blynk is able to live with the if (pulseSensor.sawStartOfBeat()) statement in the void loop and use that to trigger a Blynk.virtualWrite. That would be the first thing I’d try.

The alternative is to not use the pulse sensor library, and handle the interrupts within the code, but then you’d have to keep a rolling BPM count in the code, probably using a 60 object array and a timer that’s called once per second.
The principal is the same as what I do with my rain gauge as described here:

Pete.

1 Like