Peter,
My apologies, I thought you had one of these units. Your comment did get me thinking and I finally got it figured out. I socketed the ehealth unit onto the mega and attached pin 6(ehealth) to pin A15(mega). I deleted the original pin change folder and added the new 2.19 beta to my library. I changed the void in the .cpp file to the following:
void eHealthClass::readPulsioximeter(void)
{
uint8_t digito[41];
uint8_t A = 0;
uint8_t B = 0;
uint8_t C = 0;
uint8_t D = 0;
uint8_t E = 0;
uint8_t F = 0;
uint8_t G = 0;
for (int i = 0; i<41 ; i++) { // read all the led's of the module
A = !digitalRead(13);
B = !digitalRead(12);
C = !digitalRead(11);
D = !digitalRead(10);
E = !digitalRead(9);
F = !digitalRead(8);
G = !digitalRead(7);
digito[i] = segToNumber(A, B, C ,D ,E, F,G);
delayMicroseconds(300); //300 microseconds
}
SPO2 = 10 * digito[24] + digito[20];
BPM = 100 * digito[18] + 10 * digito[2] + digito[0];
}
and used the following sketch.
#include <PinChangeInt.h>
#include <eHealth.h>
int cont = 0;
void setup() {
Serial.begin(115200);
eHealth.initPulsioximeter();
PCintPort::attachInterrupt(A15, &readPulsioximeter, RISING);
}
void loop() {
Serial.print(" PRbpm : ");
Serial.print(eHealth.getBPM());
Serial.print(" %SPo2 : ");
Serial.print(eHealth.getOxygenSaturation());
Serial.print("\n");
Serial.println("=============================");
delay(500);
}
//Include always this code when using the pulsioximeter sensor
//=========================================================================
void readPulsioximeter(){
cont ++;
//Serial.println("ISR");
if (cont == 50) { //Get only of one 50 measures to reduce the latency
eHealth.readPulsioximeter();
cont = 0;
}
}
This worked for me, every once in a while you get a delayed pulse but the output is pretty stable otherwise.
Thanks Again!