@wardur this is my stripped down code I use to read data from the BME280
Adafruit_BME280 bme; // I2C
uint8_t BME280_i2caddr = 0x76;
..
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgPress(CHILD_ID_BARO, V_PRESSURE);
..
void setup()
{
Serial.begin(MY_BAUD_RATE);
metric = getControllerConfig().isMetric; // was getConfig().isMetric; before MySensors v2.1.1
Wire.begin(); // Wire.begin(sda, scl)
if (!bme.begin(BME280_i2caddr)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
// weather monitoring
Serial.println("-- Weather Station Scenario --");
Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
Serial.println("filter off");
bme.setSampling(Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1, // temperature
Adafruit_BME280::SAMPLING_X1, // pressure
Adafruit_BME280::SAMPLING_X1, // humidity
Adafruit_BME280::FILTER_OFF,
Adafruit_BME280::STANDBY_MS_1000);
// suggested rate is 1/60Hz (1m)
}
void loop()
{
bme.takeForcedMeasurement();
float HUM = bme.readHumidity();
float TEMP = bme.readTemperature();
float BARO = bme.readPressure() / 100;
send(msgHum.set(HUM, 2));
send(msgTemp.set(TEMP, 2));
send(msgPress.set(BARO, 1));
}