Overview
The bmp280 node reads temperature and barometric pressure from the Bosch BMP280
sensor via I2C. It also calculates altitude from the pressure reading. This sensor is widely used in weather stations,
indoor navigation, drone altitude hold, and environmental monitoring systems.
Wiring (I2C)
Connection
VCC → 3.3V
GND → GND
SDA → GPIO 2 (Pin 3)
SCL → GPIO 3 (Pin 5)
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 |
|---|---|---|---|
| bus | number | 1 | I2C bus number |
| address | number | 0x76 | I2C address (0x76 or 0x77) |
| mode | string | "normal" | "normal", "forced", or "sleep" |
| pressureOversampling | number | 16 | Oversampling: 0 (skip), 1, 2, 4, 8, 16 |
| temperatureOversampling | number | 2 | Oversampling: 0 (skip), 1, 2, 4, 8, 16 |
| interval | number | 5000 | Reading interval in milliseconds |
| seaLevelPressure | number | 1013.25 | Reference sea-level pressure for altitude (hPa) |
Output
{
"payload": {
"temperature": 22.35,
"pressure": 1012.8,
"altitude": 3.7
},
"temperature": 22.35,
"pressure": 1012.8,
"altitude": 3.7,
"timestamp": 1640000000000
} Example: Weather Station with Altitude
Build a weather station that tracks pressure trends and calculates altitude above sea level.
// Function node: Pressure trend and altitude 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.5) trend = "rising";
else if (change < -1.5) trend = "falling";
}
// Forecast based on pressure trend
var forecast = "No change expected";
if (trend === "rising") forecast = "Weather improving";
if (trend === "falling") forecast = "Possible rain ahead";
msg.payload = {
temperature: msg.temperature,
pressure: pressure,
altitude: msg.altitude,
trend: trend,
forecast: forecast
};
return msg; Example: Altitude Data Logger
Log altitude changes for hiking or drone flight recording.
// Function node: Track altitude changes
var altitude = msg.altitude;
var prev = flow.get('lastAltitude') || altitude;
var maxAlt = flow.get('maxAltitude') || altitude;
var minAlt = flow.get('minAltitude') || altitude;
maxAlt = Math.max(maxAlt, altitude);
minAlt = Math.min(minAlt, altitude);
flow.set('lastAltitude', altitude);
flow.set('maxAltitude', maxAlt);
flow.set('minAltitude', minAlt);
msg.payload = {
current: altitude.toFixed(1),
change: (altitude - prev).toFixed(2),
max: maxAlt.toFixed(1),
min: minAlt.toFixed(1),
totalClimb: (maxAlt - minAlt).toFixed(1)
};
return msg; Use Cases
Weather Station
Track pressure trends to forecast local weather changes
Altitude Tracking
Calculate elevation for drones, hiking, or floor detection
HVAC Monitoring
Combine with humidity sensors for climate control
Indoor Navigation
Detect floor changes in buildings using altitude shifts