Projects / Barometric storm warning

Barometric storm warning

Intermediate1.5 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOBMP28022.7°C

    Test the sensor

    Print the pressure to the serial monitor.

  2. NANO

    Add the ring buffer

    Store the last 18 readings.

  3. NANO

    Compute the change

    Newest minus oldest.

  4. NANOBMP28022.7°C

    Add the display

    Show pressure and change.

  5. NANO

    Add the words

    Rising, Steady, Falling, Storm likely.

  6. NANO10.3 mA

    Add the LED

    Light it for a fall over 3 hPa.

  7. NANO

    Test quickly

    Use a short interval and cover the sensor with a plastic bag squeeze.

In short

How do you build a barometric storm warning?

A BMP280 watches air pressure, and a fall of more than 3 hPa in 3 hours lights a storm warning, as old barometers did. You need Arduino Nano, BMP280 pressure sensor, SSD1306 OLED Display, LED 5 mm red and Resistor 220 Ω. It takes 7 steps and about 90 minutes.

Level
Intermediate
Time
About 90 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
BMP280 VCC and GNDNano 3V3 and GNDPower (3.3 V)
BMP280 SDANano A4I2C data
BMP280 SCLNano A5I2C clock
OLED VCC, GND, SDA, SCLNano 5V, GND, A4, A5Shares the I2C bus
Red LED anode and 220 ΩNano D6Storm warning
Red LED cathodeNano GNDReturn

Code

Old barometers worked by the rate of change of pressure rather than its value, because the same reading can mean good or bad weather depending on where it is heading. The sketch keeps the last 18 readings in a ring buffer, which means the oldest one is overwritten by the newest, and compares the newest with the oldest. A fall of more than 3 hPa in 3 hours lights the LED. Keep the sensor out of direct sun, wind from fans and heat sources, as these distort the readings. It is a hobby indicator and not a substitute for official weather warnings, especially for cyclones; follow your national weather service. The pressure at a place changes with height, so only the change matters here. Set the interval to 10 seconds while testing. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Barometric storm warning. Libraries: Adafruit BMP280, Adafruit SSD1306, Adafruit GFX. Board: Arduino Nano.
#include <Wire.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_BMP280 bmp;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int LED = 6;
const int N = 18;                          // 18 readings, one every 10 minutes = 3 hours
float hist[N]; int count = 0, head = 0;
const unsigned long INTERVAL = 600000UL;   // 10 minutes (set to 10000 to test quickly)
unsigned long last = 0;

void sample() {
  float p = bmp.readPressure() / 100.0;     // hPa
  hist[head] = p; head = (head + 1) % N; if (count < N) count++;
}

void show() {
  float now = hist[(head + N - 1) % N];
  float oldest = hist[count < N ? 0 : head];
  float change = now - oldest;              // change over the stored period (up to 3 hours)
  const char* word = "Steady"; bool storm = false;
  if (count < 6) word = "Learning...";      // wait for about an hour of readings
  else if (change < -3.0) { word = "Storm likely"; storm = true; }
  else if (change < -1.0) word = "Falling";
  else if (change > 1.0) word = "Rising";
  digitalWrite(LED, storm);

  oled.clearDisplay(); oled.setTextColor(SSD1306_WHITE);
  oled.setTextSize(2); oled.setCursor(0, 0); oled.print(now, 1); oled.print(" hPa");
  oled.setTextSize(1); oled.setCursor(0, 24); oled.print("Change "); oled.print(change, 1); oled.print(" hPa / "); oled.print(count * 10 / 60); oled.print(" h");
  oled.setTextSize(2); oled.setCursor(0, 42); oled.print(word);
  oled.display();
}

void setup() {
  pinMode(LED, OUTPUT);
  if (!bmp.begin(0x76)) bmp.begin(0x77);
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  sample(); show(); last = millis();
}

void loop() {
  if (millis() - last >= INTERVAL) { last = millis(); sample(); show(); }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
After an hourLearning changes to Steady
Gentle weatherSteady or small rise
Fast fall in a testFalling then Storm likely and LED on
Power cycleBuffer starts again, shows Learning

If it does not work

Sensor not found

Check I2C address 0x76 or 0x77.

Readings jump

Keep the sensor away from air currents.

Never warns

Check the 3 hPa rule and the interval.

Display blank

Check the OLED address 0x3C.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the barometric storm warning?

Arduino Nano, BMP280 pressure sensor, SSD1306 OLED Display, LED 5 mm red and Resistor 220 Ω.

How long does the barometric storm warning take to build?

About 90 minutes for a intermediate maker, in 7 steps.

How do I know the barometric storm warning works?

After an hour: Learning changes to Steady. Gentle weather: Steady or small rise. Fast fall in a test: Falling then Storm likely and LED on.

Sensor not found: what should I check?

Check I2C address 0x76 or 0x77.

Readings jump: what should I check?

Keep the sensor away from air currents.

Never warns: what should I check?

Check the 3 hPa rule and the interval.

Display blank: what should I check?

Check the OLED address 0x3C.