Boron Pulse Sensor and Spark Interval Timer

Hi. I am trying to use my Pulse Sensor with my Boron board. I have been trying to use the PulseSensor_Spark library to do so, however whenever I compile my .ino file it says that SparkIntervalTimer isn’t compatible with the Boron board. How can I add the timer/interrupts for the Boron into SparkIntervalTimer header file to make the pulse sensor work with my Boron?

@alyssawrong, the SparkIntervalTimer library is not compatible with Gen3 hardware. The library is ties to the STM32Fxxx hardware timers which are not available on Gen3. Currently, only one hardware timer is free on Gen3 devices. I am waiting for some decisions for the DeviceOS that might free up another timer before I write or adapt the SparkIntervalTimer library for mesh devices.

1 Like

hey @peekay123 do you have any time frames for this?

1 Like

@peekay123, is it possible to do a software timer for this instead? or are the hardware timers necessary for this? I’m currently trying to adjust the PulseSensor .cpp and .h files to use the Timer functions from Particle but am getting “multiple definitions for …” … all of my variables that have been defined in the header file and called back in my .ino file.

@alyssawrong, it may be possible given the 2ms timing interval. However, the existing code disables interrupts which may have adverse effects. However, it is worth trying. Do you have a pulse sensor to test with? It would be a trivial thing to adapt a Software Timer.

@peekay123, I do have a pulse sensor to test with. I’m just not sure how to go about starting a Software Timer. If I commented out the noInterrupts() and interrupts() functions, would this be a start? And then just figuring out how to use the Particle Timer() functions and where to put them is where I have been stuck for a while.

@alyssawrong, I can create a Web IDE app with the modified code that I can share so you can compile and test it.

@peekay123, this would be much appreciated!! I am currently attempting to do so as well, but will be looking out for yours in the mean time since I am struggling! Thanks again

@alyssawrong, give this a shot. I left the disable/enable interrupts stuff in for now.

https://go.particle.io/shared_apps/5c94423c5893c4000ab8a158

2 Likes

@peekay123, sweet! I just tried it with my pulse sensor and it works! When I first flashed it to my Boron it advised me to add the #include PulseSensor.h at the top of the main file, however when I did this it gave me the same error as I was getting when I was attempting to do the SWT (multiple definitions of all variables). I took the include statement out and it worked! Just a heads up for anyone else trying to tackle the same problem! Thanks so much again

1 Like

Thanks @peekay123! I used your project to get the Pulse Sensor working on an Argon.

Is there much effective difference between the code you posted and a version with hardware timers?

@rob7, the timer is used to “pump” a 2ms sampling interval of the sensor output so with the Hardware Timer the sampling is done in an ISR while with the Software Timer, it is done in the timer callback. Since both Gen2 and Gen3 devices support Software Timers, that approach is more universal. There is an actual proper library for this sensor but I hesitate spending time porting it since a) I don’t have this sensor and b) the demand is quite low. For pulse sensing, I use a MAX3010X pulse-oximeter sensor which uses I2C.

Thanks for that explanation!

I saw your post about the MAX chip. I was intrigued to see if I could get it to work with Argon.

Sorry if this is a silly question, but how to “physically” use the MAX? With the header pins I couldn’t imagine how it could be worn on the wrist for example.

@rob7, I have only tested the sensor on a fingertip and not on a wrist. It would be easy enough to do so. The sensor board would be mounted on a wrist band with the lens of the MAX3010X facing the skin at the correct point for picking up the pulse. However, it may be better to use a fingertip-mounted arrangement as it is less likely to move than a wrist strap IMO. BTW, I believe units like THESE use a MAX sensor.

Thanks! I just ordered one so we’ll see how it goes.

1 Like