diff --git a/ESP32-IDF_BMP280/main/bme280.h b/ESP32-IDF_BMP280/main/bme280.h index 8f67a15e..6aebaae9 100644 --- a/ESP32-IDF_BMP280/main/bme280.h +++ b/ESP32-IDF_BMP280/main/bme280.h @@ -8,9 +8,12 @@ /** GLOBAL MEMORY MAN AND REGISTERS * BME280 Data Sheet p. 26 * 0xD0 -> Chip ID -> 0x60 for BME280 or 0x56;0x58 for BMP280 + * 0xF3 -> Status -> + * 0xE0 -> Reset -> Write 0xB6 for complete power-on-reset procedure (BME280 Data Sheet p. 27) * 0xF5 -> Config -> 110 for 10ms or 111 for 20ms - * 0xF7-0xF9 -> Pressure -> 16- to 20-bit resolution - * 0xFA-0xFC -> Temperature -> 16- to 20-bit resolution + * 0xF7-0xF9 -> Pressure -> 16- to 20-bit resolution, unsigned + * 0xFA-0xFC -> Temperature -> 16- to 20-bit resolution, unsigned + * 0xFD-0xFE -> Humidity -> 16-bit resolution */ diff --git a/ESP32-IDF_BMP280/main/main.c b/ESP32-IDF_BMP280/main/main.c index 7ddebcc8..0b8ca8a2 100644 --- a/ESP32-IDF_BMP280/main/main.c +++ b/ESP32-IDF_BMP280/main/main.c @@ -44,6 +44,11 @@ static esp_err_t mpu9250_register_read(uint8_t reg_addr, uint8_t *data, size_t l return i2c_master_write_read_device(I2C_MASTER_NUM, MPU9250_SENSOR_ADDR, ®_addr, 1, data, len, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); } +static esp_err_t bme280_I2C_burst_read(uint8_t device_addr, uint8_t *data, size_t len) +{ + return i2c_master_write_read_device(I2C_MASTER_NUM, MPU9250_SENSOR_ADDR, ®_addr, 1, data, len, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); +} + /** * @brief Write a byte to a MPU9250 sensor register */ diff --git a/README.md b/README.md index 6bc4d2c9..94bbcb17 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,8 @@ The BME280 sensor board interface uses 4 pins and is 13mm by 10.5mm in size. The i2c_master_write_read_device(I2C_MASTER_NUM, 0x76, ®_addr, 1, data, len, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS); ``` +
Data readout is done by starting a burst read from 0xF7 to 0xFC (temperature and pressure) or from 0xF7 to 0xFE (temperature, pressure, and humidity). The data are rad out in an unsigned 20-bit format both for pressure and for temperature, and in an unsigned 26-bit format for humidity. After the uncompensated values for pressure, temperature, and humidity have been read, the actual humidity, pressure and temperature needs to be calculated using the compensation parameters stored in the device.
+ [^2]: https://www.bosch-sensortec.com/products/environmental-sensors/humidity-sensors-bme280/ [^3]: https://www.bosch-sensortec.com/products/environmental-sensors/pressure-sensors/bmp280/ [^4]: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme280-ds002.pdf \ No newline at end of file diff --git a/image.png b/image.png new file mode 100644 index 00000000..bf490529 Binary files /dev/null and b/image.png differ