AD8232 BPM calculation

I am in the process of integrating the AD8232 Heart Rate sensor on an Arm Mbed platform with Arduino compatible headers. Now, gettting a readout from AnalogIn isn’t the problem, but I’m struggling to getting my head around the conversion used in the [Heart Rate Display code. My question is if there is a way to simply convert the values returned from the analog output to BPM, as my project would only need this integer value and not any visual representations.

If it is of any help, the returned value using the Mbed AnalogIn read_u16 function (returns values between 0x0 and 0xFFFF)

30551

33448

21723

31959

11689

30647

31383

42688

Also, I expected the returned data to be 0 if the sensors aren’t hooked up, but I get seemingly random readings even if they aren’t hooked up at about half the time, anyone knows why that is?](AD8232_Heart_Rate_Monitor/Software/Heart_Rate_Display_Processing/Heart_Rate_Display/Heart_Rate_Display.pde at master · sparkfun/AD8232_Heart_Rate_Monitor · GitHub)

That code is Processing code that runs in Processing on your computer, it’s not for a micro controller. It’s also designed to be used when an Arduino with a 10 bit ADC is sending data, you’d need to modify it to work with a 16 bit ADC because the data is so much larger than the code is.

Essentially, the code is looking for a peak in data, that corresponds with a heartbeat. If you know how much time between heartbeats, you can calculate heart rate.

For your random values when nothing is connected, that’s because your analog input is floating. It’s no 0 volts, it’s not 3.3 volts, it’s a random voltage in between. You might even be able to influence the readings by moving your hands around the analog input. If you want to lock it at zero with nothing connected, a 1 meg resistor to ground will work.

That made more sense. However, I still can’t seem to figure out exactly how to use this analog signal to detect beats. The LED indicator on the sensor itself looks like it is reading beats correctly, so I could just use a couple of pointers so as to extract a beat and separate this from the noise.

Also the 1meg resistor to ground did not lock the readings to 0 when disconnected. If the LED is still to be believed, it seems to lock at “maximum” by default (e.g. the LED is fully lit) when it is not connected.

Write your code to look at the highest received analog value then start a timer.

Look for another highest received value and see how much time has elapsed.

Do this about another 8 times, add up all the times between highest received values and divide by 10 to get an average time between peaks. (a beat is a peak) Then calculate how many times that goes into 60 seconds to get BPM.

AD8232_Heart_Rate_Arduino_Serial_Plotter.jpg