It has been awhile! After months of experiment I have managed get a custom code running. However, the Pulse Sensor is returning inaccurate data. The BPM is constantly a lot higher and not even close to the real supposed values.
It is not a hardware problem as I have tried only running the pulse sensor amped with supplied code 1.4 on its own with all the other sensor attached and it was fine. It is only once I have combined all the code together that it starts returning unwanted number.
Here is the code, a big thanks in advance! I have tried embedding the code within the post but it has gone over the character limit so i have attached it to the post!
In an interrupt handler, where interrupts are already disabled?
sei(); // enable interrupts again
return; // IBI value is unreliable so discard it
When leaving an interrupt handler, when interrupts are already going to be enabled?
int sensorValue = analogRead(A0);//Pulse Sensor
That would be the one that the interrupt handler is reading, right?
int sensorValue1 = analogRead(A1);
//Humidity Calculation=========
float Vout = analogRead(analogHumidityPin);
Why are you reading this pin twice, too? Why are you storing the reading in two different type variables?
serialvalue = Serial.read(); // read a byte of serial data
started = 1; // set the started flag to on
if (serialvalue==14)
What is sending the serial data?
Serial.print(sensorValue4); // print the second input
Serial.print(" "); // print a space
Serial.print(sensorValue5); // print the second input
Serial.print(" "); // print a space
Serial.print(sensorValue6); // print the second input
When you have useless comments, they look really stupid when they don't match the code.
I suspect that your interrupts, for the timer and the MPU are interfering with each other, and you are not reading the beat sensor as often as you need to.