mongoose-os-libs / sht31-i2c

Mongoose OS library implementing an I2C driver for SHT31
Apache License 2.0
1 stars 5 forks source link

First read right after boot uses cached value when it should not #4

Closed stopthatcow closed 1 year ago

stopthatcow commented 2 years ago

This line precludes reading the sensor before system uptime exceeds MGOS_SHT31_READ_DELAY. This means any reads before this uptime results in the read returning 0.0 for both temperature and humidity.

A proposed solution to this is to gate this check on sensor->stats.read_success != 0 or initialize sensor->stats.last_read_time to DBL_MIN.

pimvanpelt commented 2 years ago

Either is fine - please send PR

On Sun, Sep 11, 2022 at 4:20 AM Nicholas Wiles @.***> wrote:

This https://github.com/mongoose-os-libs/sht31-i2c/blob/b1e36326caa80b303e091e60202062017a1661c7/src/mgos_sht31.c#L136 line precludes reading the sensor before system uptime exceeds MGOS_SHT31_READ_DELAY. This any reads before this uptime results in the read returning 0.0 for both temperature and humidity.

A proposed solution to this is to gate this check on sensor->stats.read_success != 0 or initialize sensor->stats.last_read_time to DBL_MIN.

— Reply to this email directly, view it on GitHub https://github.com/mongoose-os-libs/sht31-i2c/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDRSPNPJ5N5TGV56R35HU3V5U6VXANCNFSM6AAAAAAQJSM2CA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Pim van Pelt @.***> PBVP1-RIPE - http://www.ipng.nl/