Reading data from Pulse sensor using Particle IDE

@naveed, are they correct?

YES, The values are correct.

Then your code is causing the problem! If S is the raw signal in your code and it looks correct on Serial then you need to see how you calculate B and Q such that they are not refreshing.

Yes you are right and also I am wondering the same if statement becomes true and execute the serialOutput() function. However, the same if statement used for executing serialOutputWhenBeatHappens() but it doesn’t execute it and only give output for serialOutput() in serial monitor. could you suggest something thatwhy this happens ?

@naveed, compare your code in loop() with the code in the original example. You should be able to stop the problem immediately.

@peekay123 Ok Thanks and Could you please recommend any other heart rate sensor that can be easily integrated with the photon red bear duo board for detecting and reading ecg values ?

@naveed, did you spot your mistake? I haven’t tested it yet but the MAX30100 or MAX30102 have lots of available libraries, use I2C and seem like much better devices. I have ordered a MAX30102 board from Aliexpress for testing but it may take a while to get.

@peekay123 Ok Thanks and No, Not yet and even try again the original example without any changes and has the same output that only give rawsignal values.

Thanks

@naveed, in your code, look at where the serialOutputWhenBeatHappens(); is located with respect to the if (QS == true){ line.

If previously the original code worked and now it doesn’t the something changed. Make sure to check that you are compiling the correct code and that you are getting pulses being detected.

1 Like

@peekay123 [quote=“peekay123, post:52, topic:38767”]
serialOutputWhenBeatHappens(); is located with respect to if (QS == true){.
[/quote]

Yes its located at right place bur the serialOutputWhenBeatHappens() is not working properly as it doesn’t calculate B & Q values even in the orignal example as i am using now the orignal example.

@naveed, you code puts it BEFORE the QS==true test, whereas it should be AFTER since this is when a new pulse has been detected. Compare the two again and try to understand why yours will not work as you expect.

Yes, You are right when i put it AFTER the if statement it is not executed then. i don’t know why ?

Maybe because condition never becomes true - just a wild guess :wink:

@peekay123 and @ScruffR you both were absolutely right . I was making a mistake in the code and didn’t realise it but finally figure it out. In the original code the pulsePin=A2 and in my setup i was using A0 when i make that change in the code using extern keyword. Also, after experimenting with changing threshold value , i fix it to thresh =1536 for my code as shown in given share link (https://go.particle.io/shared_apps/5a7c1dcfd6fcccb29d00017b) and get the correct output of BPM and IBI as shown in image

.

Now i want to store the values of ECG , BPM and IBI in a table using mysql via webhook(https://console.particle.io/integrations/webhooks/5a799ecaf68aca28b05dde62). As i am using json and was able to store the rawSignal value in table but i am wondering How to store the BPM and IBI values. As i am confused that how json can pass multiple data values via webhook ?
The php code and output in Table is shown in the following figures (

) .

I will be thankful if you guide me that how i can also parse BPM and IBI values from webhook to my table ?

Thanks

Naveed

This - pulled from one post of yours - is an example of how to pass multiple fields in one JSON string

And there are lots of examples to be found in this forum when searching for JSON

1 Like

@ScruffR Thanks for your quick response. Yes i did it for getting one value but i am wondering that how can i split and extract all three values from the data varible as when i use it it only gives one value. Please if you can give a simple example. i will be thankful. Thanks

I want to get values from these three publish statements.
Particle.publish(“heartrate”, String(rawSignal), PRIVATE);
Particle.publish(“BPM”, String(BPM), PRIVATE);
Particle.publish(“IBI”, String(IBI), PRIVATE);

@ScruffR and @peekay123 Many Thanks to both of you for help and guidance and able to get the desired output. I was able to read the correct values and also save the values in sql database using webhook as given in the following figures.

Thanks again for all your help and guidance.

Regards
Naveed

2 Likes

Hi! i am having few problems with pulse sensor code.can you help me with that?

@Amna, yes, we CAN help you. However, can you be more specific and explain what “problems” you are having, what you tried, what system firmware you are using, etc.

2 Likes