# Example 40: BMP280 Pressure Sensor

## Experiment Overview

BMP280 is a digital pressure/temperature sensor using I2C. FastBee includes the driver in the release baseline.

> **Note**: This feature requires `FASTBEE_ENABLE_I2C_SENSORS=1` and active `i2cSensors`.

## Hardware Wiring

| Board Label | GPIO Pin | Connected Device |
|-------------|----------|------------------|
| SDA | GPIO21 | BMP280 SDA |
| SCL | GPIO22 | BMP280 SCL |

> BMP280 I2C address: SDO to GND = 0x76, SDO to VCC = 0x77.

## JSON Configuration Example

```json
{
  "peripherals": [
    {
      "id": "bmp280_01",
      "name": "BMP280 Barometer",
      "type": 38,
      "enabled": false,
      "pins": [21, 22],
      "params": {
        "category": "bmp280",
        "i2cAddress": "0x76"
      }
    }
  ]
}
```

### Data Channels

| Channel | Field Name | Unit | Description |
|---------|-----------|------|-------------|
| 0 | temperature | °C | Ambient temperature |
| 1 | pressure | hPa | Atmospheric pressure |
| 2 | altitude | m | Estimated altitude (based on standard pressure) |

## Peripheral Execution Linkage

### Scenario: Pressure & Temperature Monitoring (Timer Trigger)

**Feature**: Periodically read BMP280 pressure and temperature data

#### Web UI Configuration Steps

**Step 1: Create Rule**

1. Click **Peripheral Execution** in the left menu
2. Click **<i class="fas fa-plus"></i> New Rule** button
3. Fill in basic configuration:
   * **Rule Name**: `Pressure & Temperature Monitoring`
   * **Report Data**: ✅ Enabled
   * **Enable**: ✅ Enabled

**Step 2: Configure Trigger (Timer Trigger)**

1. Click **Add Trigger** button
2. Fill in trigger configuration:

   | Field | Value | Description |
   |-------|-------|-------------|
   | **Trigger Type** | Select **Timer Trigger** | Periodic collection |
   | **Timer Mode** | Select **Fixed Interval** | Second interval |
   | **Interval** | `10` | 10 seconds |

**Step 3: Configure Action (Sensor Read)**

1. Click **Add Action** button

2. Fill in:
   * **Action Type**: Select **Sensor Read**
   * **Target Peripheral**: Select `bmp280_01`
   * **Data Field**: `pressure` (pressure)

3. Click **Save** button

### BMP280 Data Channels

| Channel | Field Name | Unit | Description |
|---------|-----------|------|-------------|
| 0 | temperature | °C | Ambient temperature |
| 1 | pressure | hPa | Atmospheric pressure (300-1100hPa) |
| 2 | altitude | m | Estimated altitude (based on standard pressure) |

## Notes

1. **Firmware State**: Confirm `i2cSensors` is compiled and active
2. **I2C Sharing**: Can share bus with other I2C devices (SDA/SCL)
3. **Altitude Accuracy**: Altitude estimation is based on standard pressure 1013.25hPa; actual calibration needed
4. **Sampling Interval**: 5-10 seconds sampling recommended
5. **BME280 Compatible**: BME280 (with humidity) uses the same address and basic protocol
