# Pulse Sensor Amped Incompatible with OS 5.3.0

**URL:** <https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313>\
**Category:** Firmware\
**Tags:** argon\
**Created:** [April 5, 2023, 9:33pm UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313 "2023-04-05T21:33:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rob7](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@rob7](https://community.particle.io/u/rob7)\
**Post date:** [April 5, 2023, 9:33pm UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313/1 "2023-04-05T21:33:43Z")

</div>

I use the [Pulse Sensor Amped](https://www.adafruit.com/product/1093) 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?

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [April 5, 2023, 11:09pm UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313/2 "2023-04-05T23:09:52Z")

</div>

Which library are you using? There are two different libraries listed at that link.

---

<div class="post-metadata">

**Author:** ![rob7](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@rob7](https://community.particle.io/u/rob7)\
**Post date:** [April 6, 2023, 5:27am UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313/3 "2023-04-06T05:27:47Z")

</div>

The library I’m using is listed as `PulseSensorAmped` in Workbench. I think this is the link in the community library: [Particle PulseSensorAmped](https://docs.particle.io/reference/device-os/libraries/p/PulseSensorAmped/)

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [April 6, 2023, 11:44am UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313/4 "2023-04-06T11:44:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rob7](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@rob7](https://community.particle.io/u/rob7)\
**Post date:** [April 7, 2023, 12:28am UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313/5 "2023-04-07T00:28:32Z")

</div>

@rickkas7 thank you!

This is awesome! The `analogRead` solved the problem with the SOS mode.

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [April 8, 2023, 1:38am UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313/9 "2023-04-08T01:38:02Z")

</div>

@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.

> **[Particle Web IDE](https://build.particle.io/shared_apps/5c94423c5893c4000ab8a158)**
>
> Write and flash code to your Particle devices

---

<div class="post-metadata">

**Author:** ![rob7](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@rob7](https://community.particle.io/u/rob7)\
**Post date:** [April 13, 2023, 2:46am UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313/10 "2023-04-13T02:46:46Z")

</div>

Thank you! I’ll look into that for next semester 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/3/2/3291e3c9351789fe8620ae5bcec8d3fec67ff221.png) [@system](https://community.particle.io/u/system)\
**Post date:** [May 13, 2023, 12:47pm UTC](https://community.particle.io/t/pulse-sensor-amped-incompatible-with-os-5-3-0/64313/11 "2023-05-13T12:47:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
