[Resolved] PulseSensor_SP Library not compiling

I’m attempting to use a Pulse Sensor on my Photon, using the PulseSensor_SP community library, but it’s failing to compile on even an empty project.

This is my first time attempting to use external libraries so I’ve probably messed something up, but I cannot figure it out.

Here is the error I’m encountering:

PulseSensor_Spark/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::interrupt_SIT(action)':
PulseSensor_Spark/SparkIntervalTimer.cpp:358:15: warning: variable 'TIMx' set but not used [-Wunused-but-set-variable]
  TIM_TypeDef* TIMx;
               ^
PulseSensor_Spark/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::start_SIT(intPeriod, bool)':
PulseSensor_Spark/SparkIntervalTimer.cpp:265:43: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIM_ITConfig(TIMx, TIM_IT_Update, ENABLE);
                                           ^
PulseSensor_Spark/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::stop_SIT()':
PulseSensor_Spark/SparkIntervalTimer.cpp:344:18: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIM_DeInit(TIMx);
                  ^
PulseSensor_Spark/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::resetPeriod_SIT(intPeriod, bool)':
PulseSensor_Spark/SparkIntervalTimer.cpp:474:23: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIMx->PSC = prescaler;
                       ^
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.pulseTimer+0x0): multiple definition of `pulseTimer'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.fadeRate+0x0): multiple definition of `fadeRate'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.fadePin+0x0): multiple definition of `fadePin'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.fadePin+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.blinkPin+0x0): multiple definition of `blinkPin'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.blinkPin+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.pulsePin+0x0): multiple definition of `pulsePin'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.pulsePin+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.QS+0x0): multiple definition of `QS'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.Pulse+0x0): multiple definition of `Pulse'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.IBI+0x0): multiple definition of `IBI'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.IBI+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.Signal+0x0): multiple definition of `Signal'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.BPM+0x0): multiple definition of `BPM'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.secondBeat+0x0): multiple definition of `secondBeat'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.firstBeat+0x0): multiple definition of `firstBeat'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.firstBeat+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.amp+0x0): multiple definition of `amp'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.amp+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.thresh+0x0): multiple definition of `thresh'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.thresh+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.T+0x0): multiple definition of `T'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.T+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.data.P+0x0): multiple definition of `P'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):(.data.P+0x0): first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.lastBeatTime+0x0): multiple definition of `lastBeatTime'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.sampleCounter+0x0): multiple definition of `sampleCounter'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
../../../build/target/user/platform-6/libuser.a(PulseSensor_Spark.o):(.bss.rate+0x0): multiple definition of `rate'
../../../build/target/user/platform-6/libuser.a(moretestingpleasework.o):/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/functional:2069: first defined here
collect2: error: ld returned 1 exit status
make: *** [d594ecf34b0da68919cf867b1e86d6022997ca7d13ef8526b012bf343519.elf] Error 1

I’ll have to have a look at the library, but I guess that lib brings some files which you imported otherwise again.

BTW, if you add a link to the respective libs, it makes investigating matters a bit easier :wink:

Can you provide a screenshot of your Build window with the code drawer (<>) open?

For me the sample coming with the lib builds fine
https://build.particle.io/libs/55fab71c0d73c3ef8b000c90/tab/PulseSensorAmped_Arduino_1dot4.ino

2 Likes

Here’s a picture of my project (well…there’s nothing in it now).

I originally tried to copy over the example, and, when that failed, I tried running it in an empty project.

Also, I’m sorry for the slow response - someone pulled the fire alarm in the dorm I live in.

You don’t need to copy over the sample.
You just select the lib, click on the respective sample file and press USE THIS EXAMPLE.

But I can’t see anything wrong in your screenshot - maybe shorten that project name a bit :wink:


After looking at the sample I found there is no #include "PulseSensor_Spark/PulseSensor_Spark.h" but a bunch of extern variables.
If you replace the automaticly added #include with this, the errors go away

#include "PulseSensor_Spark/SparkIntervalTimer.h"

extern int pulsePin;
extern int blinkPin;
extern volatile int BPM;;
extern volatile int Signal;;
extern volatile int IBI;
extern volatile boolean Pulse;
extern volatile boolean QS;
extern int fadePin;
extern int fadeRate;
2 Likes

I’m not sure what I was doing wrong, but I’ve got it working now. Thanks!

Edit: Well, now I know what I was doing wrong - thanks again!

2 Likes