Hi,
I tried to to convert Grove Ear clip Heart Rate Sensor to Sparks and I am having problem getting the signal from the Ear clip sensor to my Spark Core. Any advise ?
I test the sensor on Arduino and it’s working fine with 5 V in to the Ear Clip sensor and Sensor O/P to D2 to Arduino.
If you used the demo sketch from here problem lies in this line
attachInterrupt(0, interrupt, RISING);//set interrupt 0,digital port 2
You’d need to change the 0
for D2
, but I’d go for a 5V tolerant pin (D0, D1, D3, D4, D5, D6 and D7), if you’ve got your sensor powerd off 5V.
I would also keep the interrupt service routine shorter.
If you’ve got your own code, we’d need to see it
1 Like
Yes. I did change the ‘0’ to D1 and used D1 to trigger the ISR routine. And I used Vin to power the Grove Sensor.
void setup()
{
//.....
earclipInit();
attachInterrupt(D1, earclipISR, RISING);//set interrupt 0,digital port 1
}
void earclipISR()
{
noInterrupts();
times[counter] = millis();
heartState = !heartState;
if (counter == 0)
{
sub = times[counter] - times[20];
}
else
{
sub = times[counter] - times[counter-1];
}
Serial.println(sub);
// if no response after max duty cycle reset counter
if (sub > maxHeartPulseDuty)
{
counter = 0;
data_effect = false;
Serial.println("Heart Rate Measure Error !, Restart Test");
earclipInit();
}
if (counter == 20 && data_effect)
{
counter = 0;
sum();
}
else if (counter<20 && data_effect )
{
counter++;
}
else
{
counter = 0;
data_effect = true;
}
interrupts();
}
I used a wire connected to 3V3 and touches the D1 and the ISR is called.
So, will level shifter help ?
Yes. Level Shifter did help. The other thing is i need to set D1 as INPUT.
i.e. pinMode(D1, INPUT);
1 Like