To come in
Speech therapy portal
  • Wipers and waves, laws and formulas
  • How the brain deceives our senses
  • Secrets of the reaction of metal sodium with water
  • Nominal parts of speech, their general features
  • I do not die the soul in the cherished lyre
  • During or during the right?
  • Atmospheric pressure sensor BMP085 and ARDUINO. Arduino BMP280 Pressure Sensors, BMP180, BME280 Connecting BMP180 to Arduino

    Atmospheric pressure sensor BMP085 and ARDUINO. Arduino BMP280 Pressure Sensors, BMP180, BME280 Connecting BMP180 to Arduino

    Good day to all, well, what ... just start !!! This article is on connecting a barometric pressure sensor. BMP180 To a single block computer Arduino Uno. But it's not so simple, as I would like at first glance. Display measured and converted temperature values \u200b\u200bWe will be on the 7-segment display on the driver's database Max7219. . And they will be displayed as a running line of two transformed units of measurement - these are degrees Celsius and degrees Fahrenheit.

    Sensor BMP180 It is not only a barometric pressure sensor, but also a high-precision temperature sensor. This is a very sensitive device, an overview video will be shown at the end of the article, looking at which it will be possible to make sure how sensitive it is. Well, further, you can cite the characteristics of the sensor BMP180 :

    • 3.3 volt supply voltage
    • Current consumption 5 μA with survey frequency 1 hz
    • Connection Interface - I2C
    • Scatter of accuracy by measured pressure + -0.12 HPA (+ -1 meter in height)
    • Measurement range from -40 * with to + 85 * with
    • Pressure measurement range: from 300 to 1100 HPA

    It's time to connect the sensor to the board Arduino Uno. But since we have measured and converted values \u200b\u200bwill be displayed on the 7th segment display, then on the following scheme we will show the full connection of all devices, as well as the sensor pinout BMP180 :

    In general, there is nothing complicated in the connection scheme, everything can be seen and clear, we turn to the writing of the Sketch next step. Some important moments In implementing the visualization of measured and transformed values:

    • Display only converted temperature values \u200b\u200b(described below why)
    • Temperature values \u200b\u200bmust be implemented with tenth degrees (as seen in the preview image)
    • Implement visualization in the form of a running line
    • Be sure to have diagnostic messages about the state of the sensor when enabling and initialization
    • Use the library to work with the sensor

    Why is it all the same to remove only temperature values \u200b\u200b... Of course, I would like to cover completely all the capabilities of the sensor BMP180 But for visualization on the 7-segment display, it will take more complex characters to display in the running string messages than those that can be actually created using the visualization modules of this type. Therefore, it was decided to display only converted temperature values, but in general as a whole, usually rarely who looks at the testimony of atmospheric pressure when for example is going to walk. And yet - if someone wants to more subtly examine the work with the BMP180 sensor, then there are two examples in the plug-in library, which can explain in more detail how to receive and convert pressure and temperature using this sensor.

    As a result, this sketch was created, with the developer's comments:

    #include "sfe_bmp180.h" #include "Wire.h" #include "ledcontrol.h" // prototype functions for scrolling messages msgscrulling () void msgscrolling (byte msg, int msgsize, int dscroll); // prototype functions for processing temperature // and prepare the Void TMSGPReparation message (Double Value, Bool Degree); // Create an LDControl class object to work with the LEDControl LC \u003d LEDControl display (12, 11, 10, 8); // Create an object BMP180SENSOR class SFE_BMP180 to work with the SFE_BMP180 BMP180SENSOR sensor; // Time delaying symbols when scrolling Const int delayScrolling \u003d 300; // Message "Sensor Initialization Successful" byte msginSuccess \u003d (91, 79, 21, 91, 29, 5, 16, 21, 16, 13, 79, 91, 13, 13, 79, 91, 91); // Message "Sensor Initialization Sensor" byte msginiTFail \u003d (91, 79, 21, 91, 29, 5, 16, 219, 15, 0, 71, 119, 48, 14); // Array of numerical characters without a point byte digit \u003d (126, 48, 109, 121, 51, 91, 95, 112, 127, 123); // Array of numerical characters with a point byte pdigit \u003d (254, 176, 237, 249, 179, 219, 223, 240, 255, 251); // Symbol signs byte deg \u003d 99; // Symbol "Degree" byte c \u003d 78; // Symbol "C" - Celsius Byte F \u003d 71; // Symbol "F" - Fahrenheat Byte S \u003d 1; // Symbol "-" - a minus sign (if the measured value is below zero) void setup () (// device (7-segment display) output from sleep mode LC.Shutdown (0, false); // Install the display brightness on 8 // Total brightness modes from 0 to 15 LC.Setintensity (0, 8); // Clear LC.Cleardisplay display (0); // Sensor initialization on the I2C IF bus (BMP180Sensor.begin ()) (// Message Scroll - Initialization of the sensor is successful MSGSCROLLING (MSGinitsuccess, Sizeof (MSGinitsuccess), DelayScrolling);) ELSE (While (True) (// Scroll Message - Expert Sensor Initialization MSGinitfail, Sizeof (MSginFail), DelayScrolling);)) void loop () (char status; Double T, Tcelsius, tfahrenheit; // If the function returns 0 then the measurement process incorrectly Status \u003d BMP180Sensor.starttemperature (); if (Status! \u003d 0) (// Wait for the amount of milliseconds Delay (Status); // Get a measured and treated temperature value // in degrees Celsius, and save in a variable T // Gettemperature () function Returns 1 if its call // passed successfully, and 0 If the function could not initialize // A variable T measured by Status \u003d BMP180Sensor.Gettemperature (T); if (status! \u003d 0) (// Assigning a variable value // and processing of graduations for a Fahrenheit scale Tcelsius \u003d T; TFahrenheit \u003d (9.0 / 5.0) * T + 32.0;)) // Treatment of value and // Message Preparing - Temperature TMSGPreparation (Tcelsius, false); TMSGPreparation (TFahrenheit, True); ) // here the actual function for scrolling ready-made messages // Right - left / * * Parameters: * BYTE MSG - pointer to an array of symbolic data * int msgsize - Size of the symbolic data array * int dscroll - Scroll delay (Shift to the left) * in milliseconds * / void msgscrolling (byte msg, int msgsize, int dscroll) (for (int i \u003d 0; i< 8 + msgSize; i ++) { for(int n = i, j = 0; n >\u003d 0, j< msgSize; n --, j ++) { LC.setRow(0, n, msg[j]); LC.setRow(0, n - 1, B00000000); } delay(dScroll); } } /* * Здесь функция подготовки сообщения, прежде чем оно будет выведено * для прокрутки на дисплее. Параметры: * double value - значение температуры двойной степени точности * bool degree - флаг для определения шкалы градуирования * если false - значит градусы Цельсия * если true - значит градусы Фаренгейта */ void TmsgPreparation(double value, bool degree) { //Приводим к абсолютному значению и сохраняем в переменной T //Это унифицирует значение и сократит код функции вдвое double T = abs(value); //Здесь значение фильтруется, если есть отклонение на пол градуса //от нуля то всё равно формировать сообщение что температура равна 0 //Итак, если замеренная температура меньше 0.5 то ставим 0 if(T < 0.5) { //Резервируем символьный массив на три символа byte preMsg; //Первый символ - это естественно 0 preMsg = Digit; //Второй символ - это сгенерированный символ "градус" preMsg = deg; //Проверка флага градуировки if(degree) { //Если true - то это градусы Фаренгейта //и третий символ в массиве будет содержать //сгенерированный символ F(код 71) preMsg = F; } else { //Иначе, если true - то это градусы Цельсия //и третий символ в массиве будет содержать //сгенерированный символ С(код 78) preMsg = C; } //Отправляем указатель на проинициализированный символьный массив preMsg //в качестве первого параметра функции для прокрутки сообщений //второй параметр - это размер символьного массива preMsg //третий параметр - задержка сдвига(прокрутки влево) в миллисекундах msgScrolling(preMsg, sizeof(preMsg), delayScrolling); //После прокрутки сообщения покинуть тело функции return; } //Если больше 0.5 но меньше 1 if(T < 1) { byte preMsg; preMsg = pDigit; preMsg = Digit; preMsg = deg; if(degree) { preMsg = F; } else { preMsg = C; } //Здесь нужно знать показания температуры //Отрицательные или положительные, //если отрицательные - добавить отрисовку знака минус if(value < 0) { byte rdyMsg; //В первый байт массива символов сообщения //записываем знак rdyMsg = S; //Далее - слияние массивов в готовое сообщение for(int i = 1; i < sizeof(rdyMsg); i ++) { // rdyMsg[i] = preMsg; } msgScrolling(rdyMsg, sizeof(rdyMsg), delayScrolling); return; } else { msgScrolling(preMsg, sizeof(preMsg), delayScrolling); return; } } //Если больше 1 но меньше 10 if(T < 10) { byte preMsg; preMsg = pDigit; preMsg = Digit; preMsg = deg; if(degree) { preMsg = F; } else { preMsg = C; } if(value < 0) { byte rdyMsg; //В первый байт массива символов сообщения //записываем знак rdyMsg = S; //Далее - слияние массивов в готовое сообщение for(int i = 1; i < sizeof(rdyMsg); i ++) { // rdyMsg[i] = preMsg; } msgScrolling(rdyMsg, sizeof(rdyMsg), delayScrolling); return; } else { msgScrolling(preMsg, sizeof(preMsg), delayScrolling); return; } } //Если больше 10 но меньше 100 if(T < 100) { byte preMsg; preMsg = Digit; preMsg = pDigit; preMsg = Digit; preMsg = deg; if(degree) { preMsg = F; } else { preMsg = C; } if(value < 0) { byte rdyMsg; //В первый байт массива символов сообщения //записываем знак rdyMsg = S; //Далее - слияние массивов в готовое сообщение for(int i = 1; i < sizeof(rdyMsg); i ++) { // rdyMsg[i] = preMsg; } msgScrolling(rdyMsg, sizeof(rdyMsg), delayScrolling); return; } else { msgScrolling(preMsg, sizeof(preMsg), delayScrolling); return; } } //Если больше 100 но меньше 1000 if(T < 1000) { byte preMsg; preMsg = Digit; preMsg = Digit; preMsg = pDigit; preMsg = Digit; preMsg = deg; if(degree) { preMsg = F; } else { preMsg = C; } if(value < 0) { byte rdyMsg; //В первый байт массива символов сообщения //записываем знак rdyMsg = S; //Далее - слияние массивов в готовое сообщение for(int i = 1; i < sizeof(rdyMsg); i ++) { // rdyMsg[i] = preMsg; } msgScrolling(rdyMsg, sizeof(rdyMsg), delayScrolling); return; } else { msgScrolling(preMsg, sizeof(preMsg), delayScrolling); return; } } }

    I would also like to say that in the standard LedControl library there were no scrolling features, maybe we will be the case who will complement this library? Well, it all depends on the wishes of our visitors, comment, try, ask questions ... We are waiting for your feedback. The video of work Sketch is also attached to this article, we look at the results of the sketch:


    Please enable JavaScript to work comments.

    Arduino program with comments:

    / * SFE_BMP180 Library Example Sketch

    This Sketch Shows How to Use the SFE_BMP180 Library to Read The
    Bosch BMP180 Barometric Pressure Sensor.
    https://www.sparkfun.com/products/11824
    Like Most Pressure Sensors, The BMP180 Measures Absolute Pressure.
    This Is The Actual Ambient Pressure Seen By The Device, Which Will
    vary with Both Altitude and Weather.
    Before Taking A Pressure Reading You Must Take a TEMPARTURE READING.
    This is a done with starttemperature () and gettemperature ().
    The Result Is in Degrees C.
    Once You Have a Temperature Reading, You Can Take a Pressure Reading.
    This Is Done with Startpressure () and getpressure ().
    The Result IS in Millibar (MB) Aka Hectopascals (HPA).
    If You "LL BE Monitoring Weather Patterns, You Will Probably Want To
    remove The Effects of Altitude. This Will Produce Readings That Can
    be Compared to the Published Pressure Readings From Other Locations.
    To do this, use the sealevel () function. You Will Need To Provide
    the Known Altitude At Which The Pressure Was Measured.
    If You Want To Measure Altitude, You Will Need to Know the Pressure
    aT A Baseline Altitude. This Can Be Average Sealevel Pressure, OR
    a Previous Pressure Reading At Your Altitude, in Which Case
    subsequent Altitude Readings Will Be + Oro - The Initial Baseline.
    This Is Done with the Altitude () Function.

    Hardware Connections:
    - (GND) to GND
    + (VIN) to 5V
    You Will Also Need to Connect the i2c Pins (SCL and SDA) to your you
    Arduino. The Pins Are Different On Different Arduinos:
    ANY ARDUINO PINS LABELED: SDA SCL
    UNO, REDBOARD, PRO: A4 A5
    Mega2560, DUE: 20 21
    Leonardo: 2 3

    The SFE_BMP180 Library Use Floating-Point Equations Developed by The
    Weather Station Data Logger Project: http://wmrx00.sourceforge.net/

    V10 Mike Grusin, SparkFun Electronics 10/24/2013
    V1.1.2 UPDATES FOR ARDUINO 1.6.4 5/2015
    */

    // Your Sketch Must #Include this Library, and the Wire Library.
    // (Wire IS A Standard Library Included with Arduino.):

    #Include.
    #Include.
    #Include.

    const int rs \u003d 12, en \u003d 11, d4 \u003d 5, d5 \u003d 4, d6 \u003d 3, d7 \u003d 2;
    LiquidCrystal LCD (RS, EN, D4, D5, D6, D7);

    // You Will Need to Create An SFE_BMP180 Object, Here Called "Pressure":
    SFE_BMP180 PRESSURE;

    void setup ()
    {
    lcd.begin (16, 2);
    // initialize the sensor (IT IM IMPORTANT TO GET CALIBRATION VALUES STORED ON THE DEVICE).
    pressure.begin ();
    }

    void loop ()
    {
    Char Status;
    Double T, P, P0 \u003d 1013.0, A; // 1013.0 - Pressure in the GPA at sea level

    // You Must First Get a Temperature Measurement to Perform a Pressure Reading.
    // Start a Temperature Measurement:

    status \u003d Pressure.starttemperature ();
    if (Status! \u003d 0)
    {
    Delay (Status);

    // Retrieve The Completed Temperature Measurement:
    // Note That The Measurement Is Stored In The Variable T.

    sTATUS \u003d PRESSURE.GETTEMPERATURE (T);
    if (Status! \u003d 0)
    {
    lcd.setcursor (0, 0);
    lcd.print ("temp \u003d");
    lcd.print (t, 2);
    lcd.print ("C");
    // Start A Pressure Measurement:
    // The Parameter Is The Oversampling Setting, From 0 to 3 (Highest Res, Longest Wait).
    // If Request Is Successful, The Number of MS to Wait is Returned.
    // If Request Is Unsuccessful, 0 is Returned.

    status \u003d Pressure.startpressure (3);
    if (Status! \u003d 0)
    {
    // Wait for the Measurement to Complete:
    Delay (Status);

    // Retrieve the Completed Pressure Measurement:
    // Note That The Measurement Is Stored In The Variable P.
    // Note Also That The Function Requires The Previous Temperature Measurement (T).
    // (If Temperature is Stable, You Can Do One Temperature Measurement for a Number of Pressure Measurements.)
    // Function Returns 1 IF Successful, 0 if Failure.

    sTATUS \u003d PRESSURE.GETPRESSURE (P, T);
    if (Status! \u003d 0)
    {
    // PRINT OUT THE MEASUREMENT:
    lcd.setcursor (0, 1);
    lcd.print ("p \u003d");
    lcd.print (p / 1.333.0); // Cooph. 1.333 - Transformation of the GPU in mm.rt.st.

    // If You Want to Determine Your Altitude from the Pressure Reading
    // Use the Altitude Function Along With a Baseline Pressure (Sea-Level or Other).
    // Parameters: P \u003d Absolute Pressure in MB, P0 \u003d 1013 Baseline Pressure in MB.
    // Result: a \u003d altitude in m.

    a \u003d pressure.altitude (P, P0);
    lcd.print ("H \u003d");
    lcd.print (A, 2);
    lcd.print ("M");
    }
    else lcd.print ("Error");
    }
    else lcd.print ("Error");
    }
    else lcd.print ("Error");
    }
    else lcd.print ("Error");
    delay (5000); // Pause for 5 Seconds.

    #Include. #Include. // Let's declare a variable to access SFE_BMP180: SFE_BMP180 PRESSURE; #Define Altitude 1655.0 // Height above sea level by jokes in meters void setup () (serial.begin (9600); serial.printLN ("Reboot"); // initialization if (pressure.begin ()) serial.printLN ( "BMP180 init ok"); else (// If we are here that something did not grieve. Typically, jambs with a connection of serial.printLN ("BMP180 init fail \\ n \\ n"); while (1); // See) ) void Loop () (char status; double t, p, p0, a; // If you want to know the air pressure, corrected in the sea level, which is usually used in weather forecasts // You need to know the sea level in your area where it is conducted Measurement // It must be specified in the Altitude Constant at the beginning of the serial.println (); serial.print ("Sea level:"); serial.print (altitude, 0); serial.print ("meters,"); Serial .print (Altitude * 3.28084.0); serial.printLN ("feet"); // If you want to find out the height above sea level, and the pressure you know // you need to specify the current atmospheric pressure. How to do this is written at the end of the code . // Since the pressure depends on some sideways from temperature, you must first find out the temperature // BMP180 has a built-in thermometer. Measurement measurement takes some time. // If everything is exactly, pressure.starttemperature will return to Status the number of milicecunds, // which you need to wait for the temperature measurement // if some kind of cant with wires will return 0 status \u003d pressure.starttemperature (); if (Status! \u003d 0) (// We are waiting: delay (Status); // Take the temperature, we put it into the variable T: // the function will return 1 if everything is OK, 0 if not ok Status \u003d Pressure.gettemperature (T); If (Status! \u003d 0) (// Write a temperature: serial.print ("Temperature:"); serial.print (t, 2); serial.print ("degrees C,"); // Celsiys serial.print ((9.0 / 5.0) * T + 32.0.2); serial.printLN ("degrees F"); // in Fahrenheita // Determine atm. Pressure: // The parameter indicates the resolution, from 0 to 3 (the more resolution, The higher the accuracy, the longer to wait). // If everything is exactly, the pressure.startpressure will return to the status of the Milisecond, // which you need to wait for the measurement of the atm. Pressure // If some jamb will return 0 Status \u003d Pressure.startpressure ( 3); if (Status! \u003d 0) (// We are waiting for the end of the measurement: Delay (Status); // Now you can get the pressure into the variable P. // The function will return 1 if everything is OK, 0 if not ok. Status \u003d Pressure. GetPressure (P, T); if (Status! \u003d 0) (// Display all: seri al.print ("Absolute pressure:"); Serial.print (p, 2); Serial.print ("Millibar,"); Serial.print (P * 0. 0295333727.2); Serial.println ("inch mercury pillar"); // Sensor Returns atm. Pressure that varies depending on the height of the sensor. // If we want as in the weather forecast, you need to make dubious calculations // Parameters: P \u003d Pressure from the sensor in millibaras, Altitude \u003d Height above sea level in meters. // Result: P0 \u003d Pressure, corrected by sea level P0 \u003d pressure.sealevel (P, Altitude); Serial.print ("Pressure in the Sea level:"); Serial.print (P0,2); Serial.print ("Millibar,"); Serial.print (P0 * 0.0295333727.2); Serial.println ("inch mercury pillar"); // or if you want to do on the contrary and determine the height above sea level at known pressure, // Parameters: P \u003d pressure from the sensor in millibaras, P0 \u003d pressure, corrected in the level of the sea. // Result: A \u003d Height above sea level in meters. a \u003d pressure.altitude (P, P0); Serial.print ("Calculated height above sea level:"); Serial.print (a, 0); Serial.print ("meters,"); Serial.print (A * 3.28084.0); Serial.println ("feet"); ) else serial.println ("Error receiving pressure \\ n"); ) else serial.printLN ("Error starting pressure \\ n"); ) Else Serial.printLN ("Error of obtaining a temperature \\ n"); ) Else Serial.printLN ("Error starting a temperature \\ n"); Delay (5000); // Pause 5 seconds. )

    The barometer is a device that measures the atmospheric pressure. That is, the air pressure, which presses on us from all sides. From school, we know that the first barometer was a plate with mercury, and an inverted test tube in it. The author of this device was Evangelist Torrichelli - Italian physicist and mathematician. You can also remove the readings of the mercury barometer as simple as the readings of the alcohol thermometer: the pressure outside the flasks is larger, the higher the mercury column inside it. Mercury couples, as you know, very poisonous.

    Later, a safer device was a barometer-aneroid. In this barometer, mercury was replaced with a corrugated box of fine tin, in which the vacuum was created. Under the influence of the atmosphere, the box is compressed and the arrow turns over the lever system on the clock. This is how these two barometers look like. Left - aneroid, right - barometer Torricelli.

    Why do we need a barometer? Most often, this device is used on aircraft to determine the height of the flight. The higher the device rises above sea level, the less pressure is experiencing a side barometer. Knowing this dependence, it is easy to determine the height.


    Another common use option is a homemade weather station. In this case, we can use the known dependences of the coming weather from atmospheric pressure. In addition to the barometer, there are moisture sensors and temperature on such stations.

    Electronic barometer

    We will not be able to use such bulky barometers in robotics. We need a miniature and energy efficient device that easily connects to the same Arduino UNO. Most modern barometers are made according to MEMS technology, as well as hyrothetometers with accelerometers. MEMS barometers are based on a piezoresistive, or on a strain gauge method that use the effect of changing the resistance of the material under the action of deforming forces.

    If you open the Barometer MEMS housing, you can see the sensitive element (right), which is located right below the hole in the protective body of the device, and the control board (left), which performs primary filtering and measurement conversion.


    Sensors BMP085 and BMP180

    The most affordable pressure sensors, which are often used by flight controllers and in different kind of homemade electronic devices, can be attributed to the BOSH: BMP085 and BMP180 sensors. The second barometer is a newer, but fully compatible with the old version.


    Some important characteristics of BMP180:

    • range of measured values: from 300 GPa to 1100 GPa (from -500m from + 9000m above sea level);
    • supply voltage: from 3.3 to 5 volts;
      Current strength: 5 μA at a survey rate - 1 hertz;
    • noise level: 0.06 GPa (0.5 m) in coarse mode (Ultra Low Power Mode) and 0.02 GPa (0.17m) A Advanced Resolution Mode.

    Now connect this sensor to the controller, and try to evaluate the atmospheric pressure.

    Connect BMP180

    Both sensors have an I2C interface, so that they can be connected to any platform from the Arduino family. This is how the connection table to Arduino UNU looks like.

    BMP 180.GND.VCC.SDASCL.
    Arduino UanGND.+ 5V.A4.A5.

    Schematic scheme

    Appearance layout


    Program

    To work with the sensor, we will need a library: BMP180_Breakout_arduino_Library

    Download it from the repository, and install in Arduino IDE. Now everything is ready for writing the first program. Let's try to get raw data from the sensor, and output them into the COM port monitor.

    #Include. #Include. SFE_BMP180 PRESSURE; void setup () (serial.begin (9600); pressure.begin ();) void loop () (double p; p \u003d getpressure (); serial.println (p, 4); delay (100);) Double Getpressure () (Char status; Double T, P, P0, A; Status \u003d Pressure.starttemperature (); if (status! \u003d 0) (// Waiting for Mete Delay (Status); Status \u003d Pressure.gettemperature (T); if (status! \u003d 0) (Status \u003d Pressure.startpressure (3); if (status! \u003d 0) (// Waiting for pressure measurement Delay (Status); Status \u003d Pressure.getpressure (P, T); if (Status! \u003d 0) (Return (P);)))))

    The procedure for obtaining cherished pressure from the sensor is not such a trivial, and consists of several stages. In a simplified form, the algorithm looks like this:

    1. require a barometer readings of the built-in temperature sensor;
    2. we are waiting for time a while the sensor estimates the temperature;
    3. we get the temperature;
    4. request pressure from barometer;
    5. we are waiting for time b, while the sensor estimates the pressure;
    6. we obtain the pressure value;
    7. return the pressure value from the function.

    Time B depends on the measurement accuracy, which is specified in the function startpressure.. The only argument of this function can take values \u200b\u200bfrom 0 to 3, where 0 is the coarsest and fastest rating, 3 is the most accurate assessment of the pressure.

    We load the program on Arduino UNO, and observe the flow of measurements of atmospheric pressure. Let's try to raise the sensor over your head, and omit to the floor level. The testimony will change a little. It remains only to figure out how to convert these incomprehensible numbers in height above sea level.

    Transformation of pressure in height above sea level

    The BMP180 sensor returns the pressure in hectopascals (GPA). It is in these units to measure atmospheric pressure. 1 GPa \u003d 100 Pascals. It is known that at sea level, the pressure on average is 1013 GPa, and each additional meter above sea level will reduce this pressure of only 0.11 GPa (approximately).

    Thus, if we subtract the function getpressure. Number 1013, and split the remaining difference at 0.11, then we will get the value of the height above sea level in meters. This is how our program will change:

    Void loop () (double p, alt; p \u003d getpressure (); alt \u003d (p - 1013) /0.11; serial.println (alt, 2); delay (100);)

    In fact, the pressure depends on the height above the sea level is nonlinear, and our formula is suitable only for heights on which we usually live. Fortunately, humanity is a well-known more accurate dependence of pressure from the height, which we can apply to obtain more accurate results.

    Here P is the pressure measured at this point, P0 is the pressure on which the height is followed.

    The SFE_BMP180 library already has a function that uses the specified one already has. The formula for obtaining accurate height. We use it in our program.

    #Include. #Include. SFE_BMP180 PRESSURE; Double P0 \u003d 0; Void setup () (serial.begin (9600); Pressure.begin (); P0 \u003d pressure.getpressure ();) void loop () (double p, alt; p \u003d getpressure (); alt \u003d pressure.altitude (p , P0) serial.println (Alt, 2); Delay (100);) Double Getpressure () (...)

    I did not completely copy the GETPRESSURE function to save text readability.

    The program appeared another variable P0 is the pressure that we measure at the start of the program. In the case of an aircraft, P0 will be pressure on the take-off area, with which we start a set of height.

    Visualization

    Now let's try to display pressure tests in the program SfmonitorAnd let's see how the pressure changes when the sensor is moving to a height of 2 meters.

    Static Const Byte Packet_Size \u003d 1; static const byte value_size \u003d 2; Static Const Boolean Separate_Values \u200b\u200b\u003d True; #Include. #Include. #Include. SFE_BMP180 PRESSURE; SerialFlow RD (& Serial); Double P0 \u003d 0; Void setup () (Rd.setPacketFormat (VALUE_SIZE, PACKET_SIZE, SEPARATE_VALUES); RD.Begin (9600); Pressure.begin (); P0 \u003d getpressure ();) void loop () (double p; p \u003d getpressure (); RD.SetPacketValue (100 + int ((P - P0) * 100)); rd.sendpacket (); delay (100);) Double Getpressure () (...)

    As a result of the program, we will receive a pressure schedule in Pascals:


    Conclusion

    As we understood from the lesson, the determination of height above sea level is not such a trivial task. It is not enough that the pressure depends on the height is non-linear, so another picture spoil various external factors. For example, the pressure from us at home is constantly changing over time. Even in a few minutes, the height measured by our device may vary in the range of 0.5 - 1 meter. The temperature also strongly affects the quality of measurements, so we have to consider it when calculating pressure.

    For aircraft It is recommended to use high accuracy sensors, such as MS5611. This barometer has a measurement accuracy can reach 0.012 GPa, which is 5 times better than that of BMP180. Also, GPS coordinates are used to clarify the barometric height of the flight.

    Successes in the observation of the atmosphere! 🙂

    April 2, 2015

    The BMP180 atmospheric pressure sensor from Bosch is more economical in terms of power supply and more accurate than its predecessor.

    Sensor BMP180.

    The main characteristics of the BMP180 sensor:

    • Pressure Measurement Range: 300 - 1100HPA
    • Supply voltage: from 3.3 and 5V
    • Low power consumption: 3 μA (ultra-low power mode)
    • Accuracy: reduced power mode, resolution 0.06hpa (0.5 m)
    • High linear mode with a resolution of 0.02hpa
    • Connection: I2C communication protocol
    • The ability to measure temperature in the range -40 ... +85 ° C
    • Response Time: 5ms
    • Current in standby: 0.1 MKA

    • VCC - for connecting 5V power
    • GND - for connecting to minus (GND)
    • SCL and SDA - to connect to the I2C bus
    • 3.3 - for connecting 3.3V power

    Buy the BMP180 sensor:

    Libraries for the BMP180 sensor:

    To work with the BMP180 sensor, libraries are used that are intended for the BMP085 sensor.

    Library for working with atmospheric pressure sensor BMP085 from AdaFruit

    Library for working with Pressure sensor BMP085

    What kind of library to use to work with the sensor to solve you. BMP085 Library Overview I have earlier in the article

    For example, I will use the AdaFruit library. To begin with, start the test sketch from the library and open the port monitor ...

    As we see we have:

    • Temperature \u003d 27.40 * C - temperature in degrees Celsius
    • Pressure \u003d 97726 PA - Atmospheric Pascal Pressure
    • Altitude \u003d 303.19 Meters - Height in meters
    • Pressure at Sealevel (Calculated) \u003d 97735 PA - atmospheric pressure in Pascals (relative to the sea level (calculated))
    • Real Altitude \u003d 317.47 Meters - Real Height (Calculated)

    Setup and calibration of the BMP180 sensor

    I want to draw your attention to the fact that the calculated data is not accurate, and they are specified in the Sketch.

    Information

    We can get a more accurate measurement of the height. If we know the current pressure above sea level for our coordinates, which will vary depending on weather conditions and the like. If it is 1015 MG, then the value is 101,500 Pa.

    Now we learn our real height above sea level using Google's cards, for this, let's turn on the link. In the window with a map from Google, we find our place of stay and click the left mouse button, to set the label on the map.

    Coordinates of my location with height values

    As we see the height above the sea level of 203 m, but I am on the 3rd floor, it means you will add another 7 m and we get a height of 210 meters (approximately) and remember it. Now we move to the Sketch and the value with the display of the atmospheric pressure data in PA translate into MM.T.St (Value Delim at 133.3) and change the display "PA" to "mm".

    code.

    Arduino.

    Serial.print ("Pressure \u003d"); Serial.print (BMP.Readpressure () / 133.3); Serial.printLN ("MM");

    Serial. Print ("Pressure \u003d");

    Serial. Print (BMP. READPRESSURE () / 133.3);

    Serial. PrintLN ("MM");

    and here

    code.

    Arduino.

    Serial.print ("Pressure AT Sealevel (Calculated) \u003d"); Serial.print (BMP.ReadsealeVelpressure () / 133.3); Serial.printLN ("MM");

    Serial. Print ( "PRESSURE AT Sealevel (Calculated) \u003d") ;

    Serial. Print (BMP. READSEALEVELPRESSURE () / 133.3);

    Serial. PrintLN ("MM");

    We again load our sketch in the fee and look at us in the port monitor