Reading data from Pulse sensor using Particle IDE

Hi I am trying to calculate and Read bpm from pulse sensor using Particle IDE, I am using the following the steps and code from this link http://www.instructables.com/id/Particle-Photon-Pulse-Sensor/ and the setup is given in Figure 1

, However, when i try to verify the code it gives the following errors as shown in Figure 2 even i included the pulse sensor library form the library list.

Can you please guide me what i have missed in my code and help in identifying the error.

Thanks
Naveed

What we are seeing in that screenshot are only warnings - these don’t prevent the build from succeeding.
You shoule post the whole error output as text.

If you wrap that into a set of these the format will also be easier on the eyes

 ```text
 ... output here

Also posting a link to a <kbd>SHARE THIS REVISION</kbd> snapshot of your project helps reproducing the errors you see.

,text,

what you meany by [quote=“ScruffR, post:5, topic:38767”]
Also posting a link to a SHARE THIS REVISION snapshot of your project helps reproducing the errors you see
[/quote]

what you mean bu this. i didn’t understand it. could you please expalin?

The following is the output error file. Thanks

..............................Output here................................. 
/src/ecg.cpp: In function 'void setup()':
/src/ecg.cpp:29:2: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:390): Spark is now Particle. [-Wdeprecated-declarations]
 extern int fadePin;
  ^
lib/SparkIntervalTimer/src/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::interrupt_SIT(action)':
lib/SparkIntervalTimer/src/SparkIntervalTimer.cpp:360:15: warning: variable 'TIMx' set but not used [-Wunused-but-set-variable]
  TIM_TypeDef* TIMx;
               ^
lib/SparkIntervalTimer/src/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::start_SIT(intPeriod, bool)':
lib/SparkIntervalTimer/src/SparkIntervalTimer.cpp:276:23: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIM_Cmd(TIMx, ENABLE);
                       ^
lib/SparkIntervalTimer/src/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::stop_SIT()':
lib/SparkIntervalTimer/src/SparkIntervalTimer.cpp:346:18: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIM_DeInit(TIMx);
                  ^
lib/SparkIntervalTimer/src/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::resetPeriod_SIT(intPeriod, bool)':
lib/SparkIntervalTimer/src/SparkIntervalTimer.cpp:476:23: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIMx->PSC = prescaler;
                       ^
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.bss.pulseTimer+0x0): multiple definition of `pulseTimer'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.bss.fadeRate+0x0): multiple definition of `fadeRate'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.data.fadePin+0x0): multiple definition of `fadePin'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.fadePin+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.data.blinkPin+0x0): multiple definition of `blinkPin'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.blinkPin+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.data.pulsePin+0x0): multiple definition of `pulsePin'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.pulsePin+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.bss.QS+0x0): multiple definition of `QS'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.bss.Pulse+0x0): multiple definition of `Pulse'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.data.IBI+0x0): multiple definition of `IBI'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.IBI+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.bss.Signal+0x0): multiple definition of `Signal'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.bss.BPM+0x0): multiple definition of `BPM'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.bss.secondBeat+0x0): multiple definition of `secondBeat'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.data.firstBeat+0x0): multiple definition of `firstBeat'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.firstBeat+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.data.amp+0x0): multiple definition of `amp'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.amp+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.data.thresh+0x0): multiple definition of `thresh'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.thresh+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.data.T+0x0): multiple definition of `T'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.T+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.data.P+0x0): multiple definition of `P'
../../../build/target/user/platform-88/libuser.a(ecg.o):(.data.P+0x0): first defined here
../../../build/target/user/platform-88/libuser.a(PulseSensor_Spark.o):(.bss.lastBeatTime+0x0): multiple definition of `lastBeatTime'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.bss.sampleCounter+0x0): multiple definition of `sampleCounter'
../../../build/target/user/platform-88/libuser.a(ecg.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-88/libuser.a(PulseSensor_Spark.o):(.bss.rate+0x0): multiple definition of `rate'
../../../build/target/user/platform-88/libuser.a(ecg.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: *** [1bf6c46e5eb8c42a8ab9b4bb3c1779bdc24611f654831c3772c6931f9699.elf] Error 1

I have reformatted your post the way I said.
If you want to know how I did that, just click the :pencil2: icon at the bottom of your post and see how I added

 ```text

before the text block and

after which caused the block in between to be formatted as it is now.

And about <kbd>SHARE THIS REVISION</kbd> just look in Web IDE here
<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/particle/original/3X/8/9/89bb3558118eb4dbc64a3df0b086eccc1f83ddba.png" width="350">
Then you will get a link to copy/paste here

BTW, in your error log you can see loads of `multiple definition` errors. I'd try to locate the reason for this and remove those.
1 Like

Hmm. i understand it very well now and Thanks very much for proper guidance. I copy the following the link from Share this revision.
https://go.particle.io/shared_apps/5a5de25b60ddd1c4ae00191c

Many Thaks

Naveed

The PulseSensor_Spark library is redefining a class Signal while the Particle framework also defines such a class.
Consequently the library needs to be changed.

I have filed an issue on @peekay123 repo for that lib

So should i wait till the library is changed and do you have any suggestion to come up for executing this code on Particle IDE ?

Thanks
naveed

@naveed, I am working on updating the library as we speak!

1 Like

@peekay123 ok Thanks very much.

@naveed, I just published the updated library (v.1.5.5). Make sure to attach the latest (v1.3.8) SparkIntervalTimer library to the project for it to compile. I test compiled with the latest v0.8.0-rc.1 formare version without errors.

I think that's not required anymore since libraries v2.0 allowing for dependencies.
Don't manually import the secondary libraries and leave that to the primary library's library.properties file.


Update:
Paul, I've just now seen your GitHub reply - now I understand what you mean, but I think it'd be less hassle for users of the lib if they didn't have to think of importing secondary libraries they're not using themselves and as long a previous version works with the primary lib no need to update.
If the update is "required" to remove the warings just up the dependency to pull in - only my 2cent.

@ScruffR, I sit on the fence on this one. On one side, the user has no control and requires the library owner to make the change. One the other side, it means the user has to attach a library. In this case, I chose the former since I also expect to update the SparkIntervalTimer library soon to use the new low latency interrupts added to 0.8.0.

1 Like

@peekay123, another example for "more info - more clarity"
With that background, things are clearing up a bit more again.

So if I understand correctly, you wanted to push the fix for the pulse library as quickly as possible, but for your own quality standards you’d also like to have the yet to come reworked SparkInervalTimer library in the dependencies. But both targets are mutually exclusive and so you opted for a workaround, right?

If so, fine by me - although I’d not have any say anyway :blush: You’re the master of these libs :+1:

1 Like

@peekay123. and @ScruffR Thanks very much for your prompt response and library update. I can see now on Particle IDE in the library list that the SparkInervalTimer (v1.3.8) library is updated. However the PulseSensor_SPARK is still in showing (v 1.5.4) as given in Figure.

Did you mean the library PulseSensor_SPARK is updated to (v. 1.5.5) ?

Please correct me if i am wrong ?

Thanks
Naveed

@naveed, not enough coffee this morning. The correct version is 1.5.4 :wink:

1 Like

@peekay123 No problem Thanks for your kind help … :slight_smile:

1 Like

@peekay123 and @ScruffR Still getting same error even after including the updated libraries. I also clear the cache of Particle IDE and web browser but still unable to verify the code. Still i am doing something wrong. The following is the share this revision link for checking
https://go.particle.io/shared_apps/5a5e190445e9a7fdd900039c

Please guide if am doing something wrong or missing something.

Thanks
Naveed

@naveed, can you first try the example that comes with the Pulse library to see if that works as expected.

@peekay123, yes i tried the examples for both and and it works fine without any error.