#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include "MAX30100_PulseOximeter.h"
#define REPORTING_PERIOD_MS 1000
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
PulseOximeter pox;
uint8_t oxyMeterAddress = 0x57;
uint8_t mlxAddress = 0x5A;
uint32_t tsLastReport = 0;
int irPin = D3;
int irValue=0;
float temp = 0;
int heartRate;
int SpO2;
void setup() {
Wire.begin();
// Wire.setClock(100000);
Serial.begin(115200);
pinMode(irPin,INPUT);
Serial.println("Initializing");
// pox.begin();
delay(1000);
mlx.begin(mlxAddress);
Serial.println("Done");
// if (!pox.begin()) {
// Serial.println("FAILED");
// }
// if(pox.begin()){
// Serial.println("SUCCESS");
// }
// pox.begin();
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
}
void oxyMeter(){
while(SpO2 < 100 && heartRate < 90){
pox.update();
if(millis() - tsLastReport > REPORTING_PERIOD_MS){
heartRate = pox.getHeartRate();
SpO2 = pox.getSpO2();
Serial.print("Heart rate:");
Serial.print(heartRate);
Serial.print("bpm / SpO2:");
Serial.print(SpO2);
Serial.println("%");
tsLastReport = millis();
if(SpO2 >80 && heartRate > 80) {
Wire.endTransmission();
pox.shutdown();
break;
}
}
}
}
void loop() {
irValue = digitalRead(irPin);
if(irValue ==0){
Serial.println("Calculating Temperature...");
delay(3000);
temp = mlx.readObjectTempF();
Serial.print("*Body Temp = "); Serial.print(temp); Serial.println("*F");
while(temp<95){
Serial.println("Place Your Finger Again");
Serial.println("Calculating Temperature...");
delay(3000);
temp = mlx.readObjectTempF();
Serial.print("*Body Temp = "); Serial.print(temp); Serial.println("*F");
}
if(temp>95 && temp <99){
Serial.println("Please Proceed Through The gate");
delay(2000);
pox.begin();
oxyMeter();
}
if(temp > 99){
Serial.println("WARNING WARNING , Can't Enter The gate");
}
Serial.println();
}
}
This is my code
I want to use both the sensors together as they work on I2C,
all the connections are correct also I have tried changing that value from 400000UL to 100000UL in the "MAX30100.h" file, so as soon as both the sensor begins working, I get NaN value from the temperature sensor.
This is the NaN result I am getting,
P.S both sensors work perfectly fine individually but create problems when used together