17 | Measure altitude with the BMP280 barometric sensor

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to the next video in our series explaining how to build your own quadcopter drone today we will see how we can measure altitudes with the BMP 280 barometer as you probably already noticed this barometer is available on a breakout board and can be mounted on the back of the upper frame of the Drone a barometric sensor is a sensor that measures the atmospheric pressure the relation between the atmospheric pressure and the altitude is given through the barometric formula which assumes in its standard form a constant temperature of 15 degrees Celsius and a standard pressure at sea level of 1013.25 hectopascal of course both the temperature and pressure at sea level are not always the same but since we are only interested in the relative change of altitudes between startup and a certain position this does not matter for us when we look at the full electronic schematic of our drone we can isolate the barometer and TNC to be able to test them on a breadboard place the DC and the barometer on a breadboard as shown on the screen when making the connections pay attention that you connect the supply voltage VCC of the barometer to the 3 volt output of your TNC and not the 5 volt outputs the maximum Supply voltage for the BMP 280 is only 3.6 volts and feeding it with a higher voltage will destroy the sensor connect the TNC ground to the ground of the barometer transmission of data is done with the i2c protocol so the connections are the same as with the mpu 6050 sensor the scl pin needs to be connected to tncp 19 and the SDA pin to pin 18. now you are ready to start programming in Arduino we will use a data sheet of the bmp280 pressure sensor extensively throughout the cords because the data transfer can be done through i2c let's use a wire Library as already explained in part 4 to calibrate the sensor 12th calibration or trimming parameters are defined two parameters consist of 16-bit unsigned integers and then are defined as 16-bit signed integers Define the altitude measured by the barometer as a global variable together with the altitude at startup the rate calibration number will be used to calculate the altitude at startup now let's code the function that will read out the pressure from the sensor the i2c address for the bmp280 is 0 times 76 the pressure and temperature data is read by starting a burst read from the six registers 0 times F7 to 0 times FC the measurement of the rod temperature and pressure is spread out over three registers each request 6 bytes to read the registers the data comes in unsigned 32-bit format the three registers for the temperature and the tree for the pressure are combined to form the raw uncompensated and uncalibrated pressure adcp and temperature adct the MSB register contains bits 19 to 12 the LSB register contains bits 11 to 4 and the xlsb register contains bits 3 to 0 of the raw measurements to calculate the compensated and calibrated pressure first the fine resolution temperature defined needs to be determined from the raw temperature of values and the trimming parameters these calculations are given entirely by the manufacturer in the data sheet of the bmp280 and are therefore not further explained here the compensated and calibrated pressure p in Pascal is calculated with calculations that are once again given by the manufacturer in the data sheet and therefore just copy paste it in the codes the result of the calculation is a pressure in Pascal convert the pressure in Pascal to the pressure in hectopascal and calculate the altitude with the barometric formula seen earlier multiply the results by 100 to make the conversion between meter and centimeter at the end of the function now reuse the first set of lines from part 4 and continue with setting up the bmp280 T we will set up the bmp280 in such a way that the sensor is optimized for indoor navigation the measurement settings can be changed in measurement register F4 first configure the sensor to normal modes which corresponds to the binary representation 1 1 for indoor navigation the oversampling setting for the pressure needs to be set to the binary representation of 101 while the over sampling setting for the temperature needs to be set to the binary representation of 0 1 0 this gives you the full binary setting for measurement register F4 and corresponds to a hexadecimal value of 57 next we will set up the configuration register F5 for indoor navigation the manufacturer recommends to set the iir filter coefficient to 16 which corresponds as well with a binary representation of one zero one the SPI interface and the standby times are not necessary here so these settings can remain on their default values of zero the full binary representation for register F5 corresponds with the hexadecimal number 14. which is subsequently added as address now that the sensor is all set for indoor navigation you need to import the 12 calibration or trimming parameters from the sensors memory these are different from sensor to sensor and are put in the sensor's memory after calibration at the manufacturer itself as they are stored in two's complements you need to foresee 2 times 12 or 24 variables the I variable will be used to indicate the trimming parameters in the subsequent while loop during Imports the register address of the first streaming parameter is 0 times 88 according to the data sheet request 24 bytes such that you can pull the information from the 24 registers 0 times 88 to 0 times 9e rearrange the trimming parameters that are split in their two's complement values such that they are readable in one single parameter you need to carry out this step for all 12 parameters before you will start your quadcopter drone you need the altitude level from which you take off take the average of 200 iterations to get a steady altitude reference level now it's finally time to read the barometer in the loop Parts call the function and subtract the average startup altitudes to get the altitude variation in Flight upload the codes to your TC and open the serial plotter now move the breadboard up and down you will notice that the altitude will follow your movements but that the readings do not change very fast are not very constant over a longer time and are overall not very accurate the poor performance of the sensor readings also suggests a barometer alone is not sufficient for controlling the altitude of your drone as you have probably already guessed in the next video we will have a look at a complementary measurements in Combined boats using a Kalman filter thank you for watching this video do not forget to subscribe if you like the series and remember that you can find all tutorials on YouTube and the full code on GitHub the manual which contains all expectations is available as well on GitHub if you need some more information thanks for watching and see you next time
Info
Channel: Carbon Aeronautics
Views: 17,199
Rating: undefined out of 5
Keywords: Arduino, Teensy, Quadcopter, Drone, MPU-6050, BMP280
Id: rabWc5W84ug
Channel Id: undefined
Length: 8min 45sec (525 seconds)
Published: Fri Jan 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.