Air Pressure

The measurement of the air pressure allows not only weather forecasts but also indirectly the determination of the height of the sensor.


Requirements

Materials

  • Air pressure sensor BMP280

Basics

BMP280 sensor

The BMP280 sensor measures both air pressure (hPa) and temperature (° C). This sensor is controlled via the I²C Protokoll, and requires an operating voltage of 3.3 to 5 volts.

I²C devices are connected to the senseBoxMCU via the I²C / Wire port and thus read out digitally (see also The serial databus). The I²C address of the BMP280 can be switched via theSDO pin: If SDO is at ground (GND) the address is 0x76, otherwise 0x77. This communication is handled by the senseBox library for us.

Height determination via the air pressure

Since the air pressure depends on the altitude above sea level, the body height of the senseBox can also be determined via the BMP280. For this purpose, a reference pressure P0 is needed whose height is known. Usually, the current air pressure is used at sea level. Since the air pressure can fluctuate greatly depending on the current weather, this "altitude measurement" but is not very accurate, and must be recalibrated again and again.

Construction

To get the sensor up and running just plug it in to the I²C / wire port!

Temperature and air pressure sensor connected via I2C port
Temperature and air pressure sensor connected via I2C port

Programming - Reading the sensor

The sensor can be controlled via the SenseBoxMCU.h library. After this has been integrated, an instance bmp of it must be created. On this object all functions of the library are called:

#include <SenseBoxMCU.h>
BMP280 bmp_sensor;

setup()-function

In the setup ()-function, the sensor must be initialized. Use the following lines

void setup(){
    bmp_sensor.begin();
}

loop()-function

Now the sensor has to be read in the loop ()-function. The variables temp and pressure then each contain the current measured values.

void loop(){
    double temp, pressure;
    pressure = bmp_sensor.getPressure();
    temp = bmp_sensor.getTemperature();
}

Exercises

Exercise 1

Connect the BMP280 sensor to the Arduino, and create an Arduino sketch, which regularly outputs air pressure and temperature on the serial monitor!

Exercise 2

You have learned that the construction height of the senseBox can be determined from the measured air pressure. Use the function bmp.altitude (...) to calculate the height and output it on the serial monitor as well.

Take a look at the example enclosed with the BMP280 library. The reference pressure P0 must be adapted to the current weather conditions: [here](https://www.meteoblue.com/en/weather/webmap/index/?variable=mslp_pressure&level=surface&lines=none) you will find the current air pressure.*

results matching ""

    No results matching ""