Skip to content

BMP280 Pressure Sensor ​

Overview ​

BMP280 is a high-precision pressure/temperature sensor that communicates via I2C bus, capable of measuring atmospheric pressure, ambient temperature, and estimating altitude. Suitable for weather stations, drone altimeters, indoor navigation, and other scenarios.

Firmware Requirement: Requires FASTBEE_ENABLE_I2C_SENSORS=1 and active i2cSensors.

Supported Peripheral Types ​

Typetype ValueDescription
SENSOR38I2C sensor (BMP280)

Hardware Wiring ​

BMP280 PinESP32 GPIODescription
VCC3.3VPower supply
GNDGNDGround
SDAGPIO 21I2C data line
SCLGPIO 22I2C clock line

Most BMP280 modules have built-in pull-up resistors; no external pull-up needed.

Configuration ​

Before saving BMP280 configuration, verify I2C bus, device address, and supply voltage.

Step 1: Navigate to Peripheral Management Page ​

  1. Open a browser and navigate to the ESP32 IP address
  2. After logging in, click Peripheral Configuration in the left menu

Step 2: Add BMP280 Peripheral ​

  1. Click the Add Peripheral button

  2. Fill in the configuration:

    FieldValueDescription
    Peripheral IDbmp280_1Unique identifier
    NameBMP280 Pressure SensorDisplay name
    Peripheral TypeGeneric Sensor (type: 38)I2C sensor
    SDA Pin21I2C data pin
    SCL Pin22I2C clock pin
    Driver NameBMP280Fixed value
    I2C Address0x760x76 or 0x77
    Sampling Interval50005 seconds (≥2000ms)
  3. Click Save

Step 3: Verify Configuration ​

  1. Find the newly added peripheral in the peripheral list
  2. Click the Enable toggle
  3. Wait 5 seconds and check pressure, temperature, and altitude data

Important: Confirm i2cSensors is active before adding the peripheral.


Method 2: JSON Configuration File Import ​

Add the following configuration to the peripherals array in data/config/peripherals.json:

json
{
  "id": "bmp280_1",
  "name": "BMP280 Pressure Sensor",
  "type": 38,
  "enabled": false,
  "pins": [21, 22],
  "params": {
    "driver": "BMP280",
    "i2cAddress": "0x76",
    "interval": 5000
  }
}

Parameter Description ​

ParameterDescription
driverDriver name, fixed to "BMP280"
i2cAddressI2C address, usually 0x76 (SDO to GND) or 0x77 (SDO to VCC)
intervalSampling interval (ms), recommend ≥ 2000

pins[0] = SDA pin, pins[1] = SCL pin

Data Report Format ​

Sensor data is reported via MQTT, containing multiple measurements:

json
[
  {"id": "bmp280_1", "value": "temperature:25.3,pressure:101325,altitude:10.5"}
]
FieldDescriptionUnit
temperatureAmbient temperature°C
pressureAtmospheric pressurePa
altitudeEstimated altitudem

Driver Registration Mechanism ​

BMP280 uses the ISensorDriver + DriverRegistry mechanism for registration:

  • Enabled at compile time via FASTBEE_ENABLE_I2C_SENSORS macro
  • Driver automatically registers to the global registry
  • The driver field in configuration is used to match the specific driver implementation

Peripheral Execution Integration ​

Web Interface Configuration Steps ​

Create Pressure Display Rule

  1. Click Peripheral Execution in the left menu
  2. Click the Add Rule button
  3. Configure timer trigger:
    • Trigger Type: Timer Trigger
    • Execution Interval: 10 seconds
  4. Add actions:
    • Action 1: Read sensor data
      • Action Type: Sensor Read
      • Target Peripheral: bmp280_1
    • Action 2: Display on OLED
      • Action Type: OLED Display
      • Target Peripheral: oled1
      • Action Value:
      #Weather Station
      P:${bmp280_1.pressure}Pa
      Alt:${bmp280_1.altitude}m
  5. Click Save

💡 Tip: Use ${peripheralID.fieldName} to reference sensor data


JSON Configuration Example ​

Temperature Threshold Alarm ​

json
{
  "name": "High Temperature Alarm",
  "enabled": true,
  "triggers": [
    {
      "triggerType": 5,
      "triggerPeriphId": "bmp280_1",
      "intervalSec": 30,
      "operatorType": 2,
      "compareValue": "35"
    }
  ],
  "actions": [
    { "actionType": 0, "targetPeriphId": "buzzer1" }
  ]
}

operatorType: 2 means “greater than”; this rule activates the buzzer above 35°C.

Pressure Display on OLED ​

json
{
  "name": "Display Pressure",
  "enabled": true,
  "triggers": [
    { "triggerType": 1, "timerMode": 0, "intervalSec": 5 }
  ],
  "actions": [
    { "actionType": 19, "targetPeriphId": "bmp280_1" },
    { "actionType": 27, "targetPeriphId": "oled1", "actionValue": "P:${bmp280_1.pressure}Pa\nAlt:${bmp280_1.altitude}m" }
  ]
}

Notes ​

  1. Firmware State: Confirm i2cSensors is compiled and active
  2. I2C Address Conflict: Cannot have two devices with the same address on the same I2C bus; multiple BMP280s need different SDO levels
  3. Altitude Accuracy: Altitude is an estimate based on standard atmospheric pressure (101325 Pa); actual use requires calibrating reference pressure
  4. Sampling Frequency: BMP280 internal conversion takes time; interval recommend ≥ 2000ms
  5. Wiring Length: I2C cable should not be too long (recommend < 50cm); reduce clock frequency or add repeater for longer runs

FastBee | fastbee.cn