Measure air pressure or height


To measure the air pressure, there are the cheap modules equipped with the BOSCH Barometric Pressure/Temperature/Altitude Sensors.

BOSCH BMP085 sensor

The data have to be read via I2C located at pins A4 and A5 on the Atmega328 (UNO, NANO or MINI).

Many of the UNO clones show some soldering pads near the ICSP header:

As the BMP module comes very small you can easily solder it to that pads.

The air pressure does not change very fast, so it is useful to log it over some time and store the data on an SD card.

There is a nice SD adapter from LC Technology with a double row of eight pins. It nearly fits into the header that contains the pins d8 to d13 (SCK=d13, MISO=d12, MOSI=d11). Unfortuntely, SCK and MISO are in the wrong order. And the pins show into the wrong direction. To make things easier, I removed all the pins, cut the connections to SCK and MISO, inserted new pins in the correct direction, and soldered two short wires that connect SCK and MISO the other way round.

The chip select pin is Arduin-Pin 10 as in many other SD card adapters. But there ist still one thing missing: the Vcc line! There is no Vcc near these pins. The Vcc from the shield goes to Arduino-Pin 9. Solution: just set this pin to OUTPUT and drive it HIGH. That's all.

The 3.3 volt goes to pin 8, better don't touch this pin.


The software will initalize the SD card and the sensor and then take samples at certain intervals. You can either read the pressure or the height. (You could also read the temperature.)

Writing to an SD card is pretty fast. Writing one megabyte takes 8 to 16 seconds (depending on the SD card class factor). Even the smallest SD cards provide plenty of space (compared the the little space the EEPROM gives you). You can have as many as 512 files in the root directory. So it's good to have an auto-increment for file names. Each time you reset or restart the Arduino a new file will be created. The file extension is set to "csv" to enable spreadsheet software to load the files without need for conversion. For countries where you have the comma as decimal separator the dot (".") will be replaced by a comma (","). Additionally, the values are sent to the Serial Monitor or even better, the Serial plotter.

Actually, the BMP-sensors tend to be a bit noisy. It is a good idea to take an average of some 100 or 1000 samples.

This diagram was taken by lifting and lowering the sensor by six foot. The left half of the diagram was recorded with no averaging, the right half with taking means of 100 samples each.

Yesterday, the Arduino took 1300 samples on my way up and down the hill.

The vertical lines prove: yes, I was using the elevator on my way up.

Can you trust the sensors?

O.k., on my recent walk, I put three arduinos in my backpack, two with BMP280 and one with the old BMP085.
The calibration is not what I expected.

Using the EEPROM rather than SD card

The 1K Arduino EEPROM enables you to store 512 int values. The more frequent you read and store samples the faster you run out of memory. This version uses an Arduino NANO with the BMP280 sensor. To select a sample rate (fast/medium/slow) you have to press the RESET button after a certain blink series of the built-in LED: So you eliminate the use of any additional hardware. Pressing after:

  • 1 flash: PLAY (send stored values to Serial terminal)
  • 2 flash: record fast
  • 3 flash: record medium
  • 4 flash: record slow
  • 5 flash: erase EEPROM
  • The source: heightlog3.ino

    contact: nji(at)