bguegan
Posts: 2
Joined: Sun Feb 25, 2018 4:40 am

Grove - Finger-clip Heart Rate Sensor with shell

Sun Feb 25, 2018 4:48 am

Hello,

I'm trying to make this sensor work on a grove map, but the python code is bad. Do you have C code that would work? Or, a Python solution to my problem?

My config :
Raspbian : stretch
Latest grove API
RaspBery PI2

Regards,
Bruno

https://www.seeedstudio.com/Grove-Finge ... -2420.html

bguegan
Posts: 2
Joined: Sun Feb 25, 2018 4:40 am

Re: Grove - Finger-clip Heart Rate Sensor with shell

Sat Mar 03, 2018 7:21 am

Hello,

Python script fail, i have make :
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

And : sudo avrdude -c gpio -p m328p -e

And script is :

Code: Select all

import time,sys
import RPi.GPIO as GPIO
import smbus

class HeartbeatSensor(object):

    def __init__(self):
        """
        Connect to an I2C port.
        """
        rev = GPIO.RPI_REVISION
        if rev == 2 or rev == 3:
            self.bus = smbus.SMBus(1)
        else:
            self.bus = smbus.SMBus(0)
        self.address = 0x50

    def get(self):
        """
        Returns the heart rate of the wearer.
        :return: Integer
        """
        return self.bus.read_byte(0x50)

if __name__ == "__main__":

    pulse = HeartbeatSensor()
    while True:
        try:
            rate = pulse.get()
            print(rate)
        except IOError:
            print("Error")
        time.sleep(5)
When i am running this script :

128
128
0
128
0
0
216
219
91
Error
Error
Error
Error
169
Error
Error
Error
Error
Error
Error
Error

After i run :
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I loose the i2c device ! Do you have an idea ?

Regards,
Bruno

EngineerJRG
Posts: 2
Joined: Mon Mar 05, 2018 4:31 am

Re: Grove - Finger-clip Heart Rate Sensor with shell

Mon Mar 05, 2018 4:37 am

I've been looking for a solution for a while. I did have a little success by changing the default "baud-rate" of the Pi's I2C to 50000. When I did that I would get two "error" readings back to back ever so often but it would not lock up the Pi and would not drop the I2C communication with the Pi. BUT this is not a true fix cause eventually the the Pi will lock up. I found that it most likely would lock up while I passed the sensor around to get different peoples readings. I trying to convert one to serial to see if that would solve the issue (cause I have read that the I2C chip on the Pi can have issue with some devices) but cannot find the WiKI page anymore that had some information on it. Please let me know if this helps you or you find a better solution to our common problem.

EngineerJRG
Posts: 2
Joined: Mon Mar 05, 2018 4:31 am

Re: Grove - Finger-clip Heart Rate Sensor with shell

Mon Mar 05, 2018 5:45 am

It seems that this device uses clock stretching and that may be the cause of this issue.

viewtopic.php?p=146272

http://www.advamation.com/knowhow/raspb ... c-bug.html

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 1 guest