budryerson / TFMini-Plus

Arduino library for the Benewake TFMini-Plus and TFMini-S LiDAR distance sensors.
68 stars 23 forks source link

Temperature in celcius correctly calculated? #51

Open jonaspiela opened 2 months ago

jonaspiela commented 2 months ago

This line gives me values of 66 (degrees celcius i suppose?) in environments where it is more 21°C. https://github.com/budryerson/TFMini-Plus/blob/90f1fcd86283f51a48ce8752aabe2ecbae762e43/src/TFMPlus.cpp#L168-L170

For reference, this is my specific code:

temperature = dataPuffer[6] + dataPuffer[7] * 256;
temperature = (temperature >> 3) - 256;

Only using

temperature = dataPuffer[6] + dataPuffer[7] * 256;

Gives me values of 2576 after a few minutes. Assuming this could be 25.76°C, it would be more realistic.

Am I missing something? What is the correct way to get the temperature in celcius?

budryerson commented 2 months ago

• The variable temperature represents chip temperature, not ambient temperature. • What I can see of your code appears to be a correct way to get temperature in Celsius. I hope that helps