Projects / Altimeter and vertical speed logger

Altimeter and vertical speed logger

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANO15.8 mASSD1306

    Wire the sensor and OLED

    Check both on I2C.

  2. NANOMS5611

    Read pressure in the serial monitor

    About 1000 hPa at low altitude.

  3. NANO

    Add the altitude formula

    Test by lifting it a metre.

  4. NANOMICROSSANDIS

    Add the SD card

    Format FAT32.

  5. NANO

    Log a walk upstairs

    Plot the CSV.

  6. NANOMS5611

    Set the sea-level pressure

    From a forecast.

  7. NANO

    Take it on a hike

    Keep it out of sun and wind.

In short

How do you build an altimeter and vertical speed logger?

A pressure sensor logs altitude and climb rate for hikes and lifts. You need Arduino Nano, MS5611 barometric pressure sensor, MicroSD Card Module, SanDisk microSD card 32 GB (A1, Class 10) and SSD1306 OLED Display. It takes 7 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
5

Parts list

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

Wiring

FromToWhy
MS5611 SDA and SCLNano A4 and A5I2C (address 0x77 or 0x76)
MS5611 VCC and GNDNano 3V3 and GNDPower (many modules also accept 5 V; check yours)
OLED SDA and SCLNano A4 and A5Same I2C bus
OLED VCC and GNDNano 5V and GNDPower
SD module CS, MOSI, MISO, SCKNano D10, D11, D12, D13Logging
SD module VCC and GNDNano 5V and GNDPower

Code

Air pressure falls as you climb, about 12 pascals for every metre near sea level, and the MS5611 can resolve about 10 centimetres of height, so it can show a climb of one step on a staircase. The formula turns the pressure into a height above the sea-level pressure you give it; real altitude therefore depends on the day's weather, and a storm front can move the reading by tens of metres over hours. For hikes, zero the altitude at your start point or enter the pressure at sea level from a local forecast. The sketch smooths readings and works out the vertical speed over one second, then logs them to a CSV on the SD card, flushed once a second so the card is safe to pull. Keep the sensor out of direct sun and wind, since temperature changes and gusts move the reading, and do not breathe on the module. It is a logging tool and not an aviation instrument, so never rely on it for flying or safety decisions. The OLED text library is used because a full graphics buffer would use too much of the Nano's memory. 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).

// Altimeter and vertical speed logger: MS5611 at 10 Hz, smoothed, shown on the OLED and logged to SD.
// Libraries: MS5611 (Rob Tillaart), U8g2 (text mode only, uses little RAM), SD (built in). Board: Arduino Nano.
#include <Wire.h>
#include <SD.h>
#include <MS5611.h>
#include <U8x8lib.h>
MS5611 baro(0x77);
U8X8_SSD1306_128X64_NONAME_HW_I2C oled(U8X8_PIN_NONE);
const float SEA_LEVEL_HPA = 1013.25;      // set today's sea-level pressure for true altitude, or zero it at your start point
float altSmooth = 0, lastAlt = 0;
bool first = true;
unsigned long lastSample = 0, lastVs = 0;
float vs = 0;
File logFile;
float altitudeFrom(float hPa) { return 44330.0 * (1.0 - pow(hPa / SEA_LEVEL_HPA, 0.1903)); }
void setup() {
  oled.begin(); oled.setFont(u8x8_font_chroma48medium8_r);
  baro.begin();
  SD.begin(10);
  logFile = SD.open("alt.csv", FILE_WRITE);
  if (logFile) logFile.println("ms,alt_m,vs_mps,temp_c");
}
void loop() {
  if (millis() - lastSample < 100) return;
  lastSample = millis();
  baro.read();
  float t = baro.getTemperature();
  float p = baro.getPressure();              // in millibar, same as hPa
  float alt = altitudeFrom(p);
  if (first) { altSmooth = alt; lastAlt = alt; first = false; }
  altSmooth += 0.2 * (alt - altSmooth);      // smoothing: lower the 0.2 for a steadier reading
  if (millis() - lastVs >= 1000) {           // vertical speed from the change over one second
    vs = altSmooth - lastAlt; lastAlt = altSmooth; lastVs = millis();
    oled.setCursor(0, 0); oled.print("Alt "); oled.print(altSmooth, 1); oled.print(" m   ");
    oled.setCursor(0, 2); oled.print("VS  "); oled.print(vs, 1); oled.print(" m/s  ");
    oled.setCursor(0, 4); oled.print("T   "); oled.print(t, 1); oled.print(" C   ");
    if (logFile) logFile.flush();
  }
  if (logFile) {
    logFile.print(millis()); logFile.print(','); logFile.print(altSmooth, 2); logFile.print(',');
    logFile.print(vs, 2); logFile.print(','); logFile.println(t, 1);
  }
}

Test checklist

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

CheckExpected
Sensor on the deskAltitude steady within about 0.5 m
Lift it 1 mAltitude rises about 1 m
Walk up a flightVertical speed positive
SD cardLines every 100 ms

If it does not work

Altitude drifts

Weather changes pressure; zero it at the start.

OLED blank

Check address and wiring.

No SD file

Check CS on D10 and the card format.

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

Ask Lark AI

Common questions

What parts do I need for the altimeter and vertical speed logger?

Arduino Nano, MS5611 barometric pressure sensor, MicroSD Card Module, SanDisk microSD card 32 GB (A1, Class 10) and SSD1306 OLED Display.

How long does the altimeter and vertical speed logger take to build?

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

How do I know the altimeter and vertical speed logger works?

Sensor on the desk: Altitude steady within about 0.5 m. Lift it 1 m: Altitude rises about 1 m. Walk up a flight: Vertical speed positive.

Altitude drifts: what should I check?

Weather changes pressure; zero it at the start.

OLED blank: what should I check?

Check address and wiring.

No SD file: what should I check?

Check CS on D10 and the card format.