drivers: sensor: sgp40: fix humidity formula
Fix the formula used to compute RH/ticks formula according to the Table 9 of the datasheet. This patch also fixes coverity issue 238360. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
9dab2b3c5c
commit
09048f843a
1 changed files with 1 additions and 1 deletions
|
@ -82,7 +82,7 @@ static int sgp40_attr_set(const struct device *dev,
|
|||
int32_t tmp;
|
||||
|
||||
tmp = CLAMP(val->val1, SGP40_COMP_MIN_RH, SGP40_COMP_MAX_RH);
|
||||
rh_ticks = (tmp * 0xFFFF / 100U) + 0.5;
|
||||
rh_ticks = (tmp * 65535) / 100;
|
||||
sys_put_be16(rh_ticks, data->rh_param);
|
||||
data->rh_param[2] = sgp40_compute_crc(rh_ticks);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue