PComp : The Tail Saga – episode 2

The Sensor

The sensor was the main question here. What kind should i use?

Pulse Sensor

I was really leaning towards the small round ones that measure heartbeat using iR close to the skin, but they proved to be unreliable by anyone who tried them around iTP

UPDATE: apparently this sensor HAS to be from the original KickStarter manufacturer that designed it. Those are much better, though still not as good as ECG

I genuinely left the research up to the collective iTP community that tested various heart beat related projects and saw the ECGs are actually the most reliable ones of the bunch! ECGs measure the microcurrents that pass through the heart with each of it’s contraptions using one side of the body as the input, one for ground, and one for reference.

ECG Sensor Placement

The sensor’s breakout board almost does everything: it measures the beat and outputs it as an analog input to the arduino where you can measure it from 0-1023 and count the peaks to get the Beat Rate.

This is the result i got just by using the default plotter on the Arduino IDE. Similar results were achieved with a Processing sketch:

Next is detecting the BPM. Which would then enable us to put a standard threshold on it. The most basic way of doing that is to use an IF condition as a pseudo high-pass filter and record the timestamp, wait for the next one and compare it with the previous, get the time and use a simple formula to get the BPM.

BPM Math

After going through all of that, i was able to get a BPM with +-2 accuracy. The reason for the inaccuracy is that the curve can hit the threshold at any point in the curve depending on the clock frequency. The solution is to use a peak detection algorithm which is one of those questions with too many solutions! I wrote a simple 1D Time Series peak detection algorithm that used a 10 element array and pick the highest one. Though in the end i used a piece of code from another pulse detector that used the same analog input which yielded much more stable results.

by this point the logic of the code is done. Though one point is to be careful with EEG electrodes. People at 3M REALLY know how to make things stick! Took me 10 minutes to pull all three from my skin!