Fix BME280 calculation (#1051)

* Fix BME280 calculation (#1051)
This commit is contained in:
arendst 2017-12-03 16:17:47 +01:00
parent 25a0e5bf7f
commit 7df979ed25
3 changed files with 21 additions and 9 deletions

View File

@ -1,9 +1,10 @@
/* 5.10.0a
* Add (experimental) support for sensor SHT3x
* Add (experimental) support for iTead SI7021 temperature and humidity sensor (#735)
* Fix BME280 calculation (#1051)
* Change ADS1115 default voltage range from +/-2V to +/-6V (#1289)
* Add multipress support and more user configurable options to Sonoff Dual R2 (#1291)
* Fix missed learned key if learned data contains 0x55 (End of Transmission) flag (#1095, #1294)
* Fix Sonoff Bridge missed learned key if learned data contains 0x55 (End of Transmission) flag (#1095, #1294)
*
* 5.10.0 20171201
* Upgrade library ArduinoJson to 5.11.2

View File

@ -2644,14 +2644,6 @@ void setup()
Serial.println();
seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
/*
snprintf_P(version, sizeof(version), PSTR("%d.%d.%d"), VERSION >> 24 & 0xff, VERSION >> 16 & 0xff, VERSION >> 8 & 0xff);
if (VERSION & 0x1f) {
idx = strlen(version);
version[idx] = 96 + (VERSION & 0x1f);
version[idx +1] = 0;
}
*/
SettingsLoad();
SettingsDelta();

View File

@ -172,6 +172,7 @@ double Bmp180ReadPressure()
#define BME280_REGISTER_CONTROLHUMID 0xF2
#define BME280_REGISTER_CONTROL 0xF4
#define BME280_REGISTER_CONFIG 0xF5
#define BME280_REGISTER_PRESSUREDATA 0xF7
#define BME280_REGISTER_TEMPDATA 0xFA
#define BME280_REGISTER_HUMIDDATA 0xFD
@ -235,6 +236,7 @@ boolean Bmx280Calibrate()
Bme280CalibrationData.dig_P7 = I2cReadS16_LE(bmp_address, BME280_REGISTER_DIG_P7);
Bme280CalibrationData.dig_P8 = I2cReadS16_LE(bmp_address, BME280_REGISTER_DIG_P8);
Bme280CalibrationData.dig_P9 = I2cReadS16_LE(bmp_address, BME280_REGISTER_DIG_P9);
/*
if (BME280_CHIPID == bmp_type) {
Bme280CalibrationData.dig_H1 = I2cRead8(bmp_address, BME280_REGISTER_DIG_H1);
Bme280CalibrationData.dig_H2 = I2cReadS16_LE(bmp_address, BME280_REGISTER_DIG_H2);
@ -247,6 +249,23 @@ boolean Bmx280Calibrate()
I2cWrite8(bmp_address, BME280_REGISTER_CONTROLHUMID, 0x05); // 16x oversampling (Adafruit)
}
I2cWrite8(bmp_address, BME280_REGISTER_CONTROL, 0xB7); // 16x oversampling, normal mode (Adafruit)
*/
if (BME280_CHIPID == bmp_type) { // #1051
Bme280CalibrationData.dig_H1 = I2cRead8(bmp_address, BME280_REGISTER_DIG_H1);
Bme280CalibrationData.dig_H2 = I2cReadS16_LE(bmp_address, BME280_REGISTER_DIG_H2);
Bme280CalibrationData.dig_H3 = I2cRead8(bmp_address, BME280_REGISTER_DIG_H3);
Bme280CalibrationData.dig_H4 = (I2cRead8(bmp_address, BME280_REGISTER_DIG_H4) << 4) | (I2cRead8(bmp_address, BME280_REGISTER_DIG_H4 + 1) & 0xF);
Bme280CalibrationData.dig_H5 = (I2cRead8(bmp_address, BME280_REGISTER_DIG_H5 + 1) << 4) | (I2cRead8(bmp_address, BME280_REGISTER_DIG_H5) >> 4);
Bme280CalibrationData.dig_H6 = (int8_t)I2cRead8(bmp_address, BME280_REGISTER_DIG_H6);
I2cWrite8(bmp_address, BME280_REGISTER_CONTROL, 0x00); // sleep mode since writes to config can be ignored in normal mode (Datasheet 5.4.5/6 page 27)
// Set before CONTROL_meas (DS 5.4.3)
I2cWrite8(bmp_address, BME280_REGISTER_CONTROLHUMID, 0x01); // 1x oversampling
I2cWrite8(bmp_address, BME280_REGISTER_CONFIG, 0xA0); // 1sec standby between measurements (to limit self heating), IIR filter off
I2cWrite8(bmp_address, BME280_REGISTER_CONTROL, 0x27); // 1x oversampling, normal mode
} else {
I2cWrite8(bmp_address, BME280_REGISTER_CONTROL, 0xB7); // 16x oversampling, normal mode (Adafruit)
}
return true;
}