Home Elements Boards Recipes

BMP280 Element

The BMP280 Element supports the BMP280 sensor chips for air temperature and air absolute barometric pressure.

Bosch is developing advanced integrated environmental chips sind several years. Some of them are available on breakout boards and can easily be used together with the ESP CPU chips.

The have similar but not identical interfaces so each needs a special library and element to be used in the HomeDing library.

For BMP280 and BME680 no external library is required.

Interface

The physical communication is done via the I2C bus to read raw data values as well as some correction factors to calculate the temperature in celsius and pressure in pascal

This sensor element uses the base functionality of the sensor class to implement timing of taking probes and uses the WireUtil class for I2C data communication.

The calculation procedures are documented in the datasheet and taken unchanged into the BMP280Element implementation.

The sensor is very similar to the BME680 Sensor that offers 2 more sensor values.

Using the BMP280 Element

The BMP280 Element is not part of the core set of elements but it can be added to the sketch and firmware by defining the macro HOMEDING_INCLUDE_BMP280. This adds about 2100 bytes to the firmware but doesn’t need any external library.

// Use some more optional Elements.
#define HOMEDING_INCLUDE_BMP280

The Sensor recipe shows how to configure a sensor device and log an actual value to get insight on passed values using a graphical output.

A complete story about using sensors with the HomeDing library is available here: Air Quality Monitoring Story

Connecting a Sensor

The BMP280 sensor must be connected to the common i2c bus and needs 3.3V power supply.

Using the default I2C bus pins:

Signal ESP8266 ESP32 Sensor Description
GND GND GND GND Ground for I2C and Power Supply
VCC 3.3v 3.3v VCC/VDD Power Supply
SDA GPIO4(D2) IO21 SDA I2C Data Signal
SCL GPIO5(D1) IO22 SCL I2C Clock Signal

The common i2c bus is configured in the device element. For more details on using the i2c bus and specifying pins see I2C bus.

Element Configuration

The following properties are available for configuration of the element:

address – The I2C Address of the sensor. The default value is 0x76.

onTemperature – These actions are send when a new temperature value has been read. The value given in the actions is actual temperature in Celcius.

onPressure – These actions are send when a new pressure value has been read. The value given in the actions is actual pressure in hPA.

From the base Sensor Element implementation the following properties are available for configuration:

readTime – Time between 2 probes being fetched from the sensor. Default value is 1m.

resendTime – The current values of the probe are resent after this specified time even when not changing.

warmupTime – This time is waited after powering the sensor on the first start or after a reset before the first data is fetched. The default time is set to 3 seconds.

restart – This property can be set to true to enable an automated restart when the sensor was not responding data.

From the base element implementation the following properties are available for configuration:

title – Caption text for the element. Used by the element specific cards on the dash boards.

description – A line of text that gives a short description of the device used in the web UI.

room – The location of the device.

loglevel – This property holds the element specific log level. The default value is LOGGER_LEVEL_ERR == 1.

startup – This property can be used to start the element using a different initialization phase. Possible values are “sys”, “net”, “time”. See The Startup sequence.

Configuration Example

This example shows how to configure this element:

{
  "bmp280": {
    "tp": {
      "address": "0x77",
      "readTime": "30s",
      "resendTime": "2m",
      "onTemperature": "device/0?log=temp=$v",
      "onPressure": "device/0?log=pressure=$v"
    }
  }
}

State

{
  "bmp280/tp": {
    "active":"true",
    "temperature":"21.21",
    "pressure":"99784"
  }
}

See also

Tags

Element Sensor