I use the Pulse Sensor Amped with my students and the PulseSensorAmped library has worked fine, including on OS 5.0.0 and 5.0.1.
However, when the Argon has 5.3.0 firmware, flashing project with the PulseSensorAmped library immediately sends the device in SOS mode (flashing red). I’m pretty sure that it was Assertion failure.
Does anyone know if there is a workaround for this library and OS 5.3.0?
That library does a whole lot of things that are not particularly safe. However I think the quick workaround to fix the problem you are seeing is during setup() before initializing the library, do an analogRead() of the sensor pin.
The reason is that the library calls hal_adc_read which is an undocumented Device OS function from an ISR, and that’s not guaranteed to be safe, but usually works. However, the first time the pin is read, it has to initialize the ADC. In Device OS 5.3.0 it has to read the configured ADC reference setting, which is not interrupt safe. It previously always used 3V3, so it didn’t cause an issue in older versions of Device OS.
@rob7, if you are interested, I created a version of PulseSensorAmped 1.4 that uses a Software Timer instead of interrupts. I never published it as a library but here is the code.