BME280 I2C

This commit is contained in:
Alexander 2024-07-08 10:31:21 -04:00
parent 1a271d1a36
commit 7835cc0a2d
4 changed files with 12 additions and 2 deletions

View File

@ -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
*/

View File

@ -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, &reg_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, &reg_addr, 1, data, len, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
}
/**
* @brief Write a byte to a MPU9250 sensor register
*/

View File

@ -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, &reg_addr, 1, data, len, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
```
<p>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.</p>
[^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

BIN
image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB