sparkfun/SparkFun_BME280_Arduino_Library

readFloatHumidity doesn't return decimals

TheAustrian opened this issue · 1 comments

Hi! First of all thanks for the library!

I used the code from one of your examples to read the humidity into an array I initialized as follows:
float humidityBuffer[buffersize+1] = {0.0};
and later I read from the sensor with:
humidityBuffer[bufferposition] = mySensor.readFloatHumidity();
and I get values like "38" but with no decimal places. It works for temperature and with a division by 100 for pressure in hectopascals as well.

What am I doing wrong or is this an error in the library? I'm using the version from the library manager in Arduino IDE with an ESP8266.

I took a look at your issue, the library package works properly and outputs a float. I believe the issue is in your code.

You can try test our library using File > Examples >SparkFun BME 280 > Example1_BasicReadings. Modify line 44 from: Serial.print(mySensor.readFloatHumidity(), 0);
to Serial.print(mySensor.readFloatHumidity(), 3); and you will see the print statement output up to 3 decimal places.