Getting 220C for the MAX30205 Temperature Sensor

@hamnahasan101

The MSB should be 22 then (for negative numbers it is different)

mmmm (thinking sounds)

Can you run, to see the configuration register.

#include <Wire.h>

const uint8_t addr = 0x48;   // Adjust if needed

void setup() {
  Serial.begin(115200);
  Wire.begin();
}

void loop() {
  uint8_t msb, lsb;

  Wire.beginTransmission(addr);
  Wire.write(0x01);                 // configuration register
  Wire.endTransmission(false);      // 
  Wire.requestFrom(addr, (uint8_t)1);

  if (Wire.available() == 1) {
    msb = Wire.read();
   Serial.println(msb);
  } else {
    Serial.println("I2C read error");
  }

  delay(1000);
}

Tahnk you so much for your help again, I really appreciate it. I get this output:

That is the default value for the config register. Most important the ONE SHOT == 0
meaning it does conversions in continuous mode.

Sorry, you do mind explaining what the means?

Can you run this to see the value of the hysteresis register

#include <Wire.h>

const uint8_t addr = 0x48;   // Adjust if needed

void setup() {
  Serial.begin(115200);
  Wire.begin();
}

void loop() {

  uint8_t msb, lsb;

  Wire.beginTransmission(addr);
  Wire.write(0x02);                 // Hysteresis register
  Wire.endTransmission(false);      // Repeated start
  Wire.requestFrom(addr, (uint8_t)2);

  if (Wire.available() == 2) {
    msb = Wire.read();
    lsb = Wire.read();

    int16_t raw = (int16_t)((msb << 8) | lsb);
    float tempC = raw / 256.0;
  Serial.print("MSB: ");
  Serial.println(msb);
  Serial.print("LSB: ");
  Serial.println(lsb);
    Serial.print("HY Temp C: ");
    Serial.println(tempC);
  } else {
    Serial.println("I2C read error");
  }

  delay(1000);
}

And this, for the OS register

#include <Wire.h>

const uint8_t addr = 0x48;   // Adjust if needed

void setup() {
  Serial.begin(115200);
  Wire.begin();
}

void loop() {

  uint8_t msb, lsb;

  Wire.beginTransmission(addr);
  Wire.write(0x03);                 // OS register
  Wire.endTransmission(false);      // Repeated start
  Wire.requestFrom(addr, (uint8_t)2);

  if (Wire.available() == 2) {
    msb = Wire.read();
    lsb = Wire.read();

    int16_t raw = (int16_t)((msb << 8) | lsb);
    float tempC = raw / 256.0;
  Serial.print("MSB: ");
  Serial.println(msb);
  Serial.print("LSB: ");
  Serial.println(lsb);
    Serial.print("OS Temp C: ");
    Serial.println(tempC);
  } else {
    Serial.println("I2C read error");
  }

  delay(1000);
}

Hysteresis Register:

OS Register:

OK those registers are all in their initial value.
This means that part of the MAX30205 seems to be correct.

It is all in the datasheet of the device, if you want to understand the devices you work with, you need to learn to read those - not to understand it all at once, but to get insight of what the device does. (took me a few years to learn to read them and still learning ).

The config register consists of 8 bits which are used to configure the behavior of the device. If you write a 1 to the SHUTDOWN bit (and keeping the others the same, the device will go into shutdown mode and stops converting. Writing a 0 (default value) does a wake up.
Similar the ONESHOT bit, writing a 1 to it when it is in SHUTDOWN mode, wakes the device up to make one single conversion and goes to sleep again.
When not in shutdown mode writing a 1 makes less sense as it is operation in full power.

Oh okay thank you so much, I’ll take a look at those datasheets.

Back to reading the device, now with an appropriate wake up time after POR (power on reset).

#include <Wire.h>

const uint8_t addr = 0x48;   // Adjust if needed

void setup() {
  Serial.begin(115200);
  Wire.begin();

  delay(100);  //  be sure the device has woken up.
}

void loop() {

  uint8_t msb, lsb;

  Wire.beginTransmission(addr);
  Wire.write(0x00);                 // temperature register
  Wire.endTransmission(false);      // Repeated start
  Wire.requestFrom(addr, (uint8_t)2);

  if (Wire.available() == 2) {
    msb = Wire.read();
    lsb = Wire.read();

    int16_t raw = (int16_t)((msb << 8) | lsb);
    float tempC = raw / 256.0;
  Serial.print("MSB: ");
  Serial.println(msb);
  Serial.print("LSB: ");
  Serial.println(lsb);
    Serial.print("Temp C: ");
    Serial.println(tempC);
  } else {
    Serial.println("I2C read error");
  }

  delay(1000);
}

This is the output of the new code:
The values are still negative.

The next trick is not documented in the datasheet,
It is just a try because the config register DATAFORMAT bit is 0.

#include <Wire.h>

const uint8_t addr = 0x48;   // Adjust if needed

void setup() {
  Serial.begin(115200);
  Wire.begin();

  delay(100);  //  wake up
}

void loop() {

  uint8_t msb, lsb;

  Wire.beginTransmission(addr);
  Wire.write(0x03);                 // OS register
  Wire.endTransmission(false);      // Repeated start
  Wire.requestFrom(addr, (uint8_t)2);

  if (Wire.available() == 2) {
    msb = Wire.read()  & 0x3F;   //  <<<<<<<<<<<<  mask extended range bits.
    lsb = Wire.read();

    int16_t raw = (int16_t)((msb << 8) | lsb);
    float tempC = raw / 256.0;
  Serial.print("MSB: ");
  Serial.println(msb);
  Serial.print("LSB: ");
  Serial.println(lsb);
    Serial.print("OS Temp C: ");
    Serial.println(tempC);
  } else {
    Serial.println("I2C read error");
  }

  delay(1000);
}

Please post the output as text as the images takes up extra storage and bandwidth.

There is a mode on that chip which extends the temperature range. If it is set, to convert the reading you have to add 64.

-42+64 = 22

Looks like that’s what is happening.

Pete

indeed
That is the DATAFORMAT bit in the configuration register.
This bit it is not set in the register but the device seems to behave as if the bit is set.

The 0x3F masking of the MSB (sign + 64 bit together ) in my last code proposal would indeed change -42 => 22.

That worked! Thank you so so much! I really appreciate your help.

It may look like it is working, but your sensor is broken as it is in extended mode without the configuration says so.
Thus at least I would not trust it for 100%, definitely not for medical applications.
The remark of a broken sensor has been made earlier in post 4 above.

I have seen small non-functioning sections like this in counterfeit parts before.
Things working as per datasheet for 99%.
Leo..

I haven’t touched this sensor to anything but 3.3V, is there another reason why it would be broken? I have tested it with different temperatures and it seems to be reading correctly.

You said you had used an Uno, assuming R3. Which puts 5volt on the I2C lines.
You should have used an I2C level shifter, or at least disable the internal pull up in software.
A fake/counterfeit chip is more likely though.
Leo..