hwmontempsensor: Add support for BME280
This patch adds support for the Bosch BME280 environmental sensor, which
provides temperature, pressure, and humidity readings.
In addition, the sensor name mapping logic has been improved to use more
intuitive key names for pressure and humidity sensors. Previously, both
used the same key ("Name1"), which could lead to confusion. The mapping
has now been corrected to:
- Name -> Temperature
- NamePressure -> Pressure
- NameHumidity -> Humidity
This ensures correct identification and indexing of multi-function
sensors like the BME280, and generally improves the clarity of sensor
configuration.
This requires corresponding in entity-manager.
https://gerrit.openbmc.org/c/openbmc/entity-manager/+/82560
Change-Id: I128131c7c71c9d414a491fad18aac5e6c2aabb02
Signed-off-by: Naresh Solanki <naresh.solanki@9elements.com>
diff --git a/src/hwmon-temp/HwmonTempMain.cpp b/src/hwmon-temp/HwmonTempMain.cpp
index 918c926..874fbf0 100644
--- a/src/hwmon-temp/HwmonTempMain.cpp
+++ b/src/hwmon-temp/HwmonTempMain.cpp
@@ -64,6 +64,7 @@
static const I2CDeviceTypeMap sensorTypes{
{"ADM1021", I2CDeviceType{"adm1021", true}},
+ {"BME280", I2CDeviceType{"bme280", false}},
{"DPS310", I2CDeviceType{"dps310", false}},
{"EMC1403", I2CDeviceType{"emc1403", true}},
{"EMC1412", I2CDeviceType{"emc1412", true}},
@@ -385,12 +386,16 @@
// Temperature has "Name", pressure has "Name1"
auto findSensorName = baseConfigMap.find("Name");
int index = 1;
- if (thisSensorParameters.typeName == "pressure" ||
- thisSensorParameters.typeName == "humidity")
+ if (thisSensorParameters.typeName == "pressure")
{
- findSensorName = baseConfigMap.find("Name1");
+ findSensorName = baseConfigMap.find("NamePressure");
index = 2;
}
+ if (thisSensorParameters.typeName == "humidity")
+ {
+ findSensorName = baseConfigMap.find("NameHumidity");
+ index = 3;
+ }
if (findSensorName == baseConfigMap.end())
{