adafruit / Adafruit-MLX90614-Library

Arduino library for the MLX90614 sensors in the Adafruit shop
Other
128 stars 97 forks source link

Return NaN if reading failed #28

Closed szerwi closed 3 years ago

szerwi commented 3 years ago

Currently the library returns 54.67 for the readObjectTempC() if the sensor is not connected and it is hard to determine if the reading was successful or not (without calling begin()). I suggest to add checks if the reading is successful or not. If it's not, the function should return NaN

EDIT: It seems like the function is returning -273.01, not 54.67 when the sensor is not connected. However, I still believe that returning NAN would be better. EDIT 2: I've noticed that if the sensor is not connected readObjectTempC() sometimes returns -273.01 and sometimes 54.67 which makes it even harder to check if the reading i successful.

ladyada commented 3 years ago

any PR to change / update behavior is welcome

szerwi commented 3 years ago

@ladyada I've created PR ;)

ladyada commented 3 years ago

thanx!!