Skip to main content

bme280

High-precision environmental sensor for temperature, humidity, and barometric pressure via I2C.

Overview

The bme280 node reads temperature, humidity, and barometric pressure from the Bosch BME280 sensor via I2C. This high-precision sensor is ideal for weather stations, indoor climate monitoring, altitude calculation, and professional environmental monitoring applications.

±0.5°C
Temp Accuracy
±3% RH
Humidity Accuracy
±1 hPa
Pressure Accuracy
I2C
Interface

Wiring (I2C)

Connection

VCC/VIN → 3.3V

GND → GND

SDA → GPIO 2 (Pin 3)

SCL → GPIO 3 (Pin 5)

Default address: 0x76 (SDO→GND) or 0x77 (SDO→VCC)

Enable I2C

sudo raspi-config
# Interface Options → I2C → Enable

# Verify sensor detected:
i2cdetect -y 1
# Should show 76 or 77

Properties

Property Type Default Description
address number 0x76 I2C address (0x76 or 0x77)
interval number 5 Reading interval in seconds
tempUnit string "C" Temperature unit: "C" or "F"
pressureUnit string "hPa" "hPa", "mbar", "mmHg", or "inHg"
seaLevelPressure number 1013.25 Reference pressure for altitude calculation

Output

{
  "payload": {
    "temperature": 22.5,
    "humidity": 45.2,
    "pressure": 1013.25,
    "altitude": 125.3
  },
  "temperature": 22.5,
  "humidity": 45.2,
  "pressure": 1013.25,
  "altitude": 125.3,
  "timestamp": 1640000000000
}

Altitude Calculation

Altitude is calculated using the barometric formula. For accurate readings, set the sea level pressure for your location (check local weather station).

// Barometric formula:
altitude = 44330 * (1 - (pressure / seaLevelPressure)^0.1903)

// Example: 1013.25 hPa at sea level, 900 hPa measured
// altitude ≈ 988 meters

Example: Weather Station

Complete weather station with trend analysis and forecasting.

// Function node: Pressure trend analysis
var pressure = msg.pressure;
var history = flow.get('pressureHistory') || [];

history.push({
    pressure: pressure,
    time: Date.now()
});

// Keep last 3 hours of readings
var threeHoursAgo = Date.now() - (3 * 60 * 60 * 1000);
history = history.filter(r => r.time > threeHoursAgo);
flow.set('pressureHistory', history);

// Calculate trend
var trend = "stable";
if (history.length > 1) {
    var oldest = history[0].pressure;
    var change = pressure - oldest;

    if (change > 1) trend = "rising";
    else if (change < -1) trend = "falling";
}

// Simple forecast
var forecast = "No change expected";
if (trend === "rising") forecast = "Weather improving";
if (trend === "falling") forecast = "Weather deteriorating";

msg.payload = {
    ...msg.payload,
    trend: trend,
    forecast: forecast
};

return msg;

Related Nodes