Pulse Sensor Amped Incompatible with 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.

2 Likes