From 677d377299f5a919c2fcd8f5769f9b2d14708187 Mon Sep 17 00:00:00 2001 From: Josep Puigdemont Date: Fri, 21 Jul 2023 17:48:36 +0200 Subject: [PATCH] sensor: bme280: BMP280 has no humidity sensor Return ENOTSUP when getting the humidity channel if the driver is used with a BMP280, since this device does not provide humidity readings. Signed-off-by: Josep Puigdemont --- drivers/sensor/bme280/bme280.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/sensor/bme280/bme280.c b/drivers/sensor/bme280/bme280.c index 0b2b395461..f2bd7514c0 100644 --- a/drivers/sensor/bme280/bme280.c +++ b/drivers/sensor/bme280/bme280.c @@ -245,6 +245,10 @@ static int bme280_channel_get(const struct device *dev, (((data->comp_press & 0xff) * 1000U) >> 8); break; case SENSOR_CHAN_HUMIDITY: + /* The BMP280 doesn't have a humidity sensor */ + if (data->chip_id != BME280_CHIP_ID) { + return -ENOTSUP; + } /* * data->comp_humidity has 22 integer bits and 10 * fractional. Output value of 47445 represents