How to Use Barometric Pressure Sensors on the Arduino - Ultimate Guide to the Arduino #39
Summary
TLDRIn diesem Video wird erklärt, wie man den BMP-180 Drucksensor mit einem Arduino verwendet, um atmosphärischen Druck und Temperatur zu messen. Der Sensor, der über I2C kommuniziert, kann Luftdruck und Temperatur ermitteln, was nützlich ist, um das Wetter vorherzusagen oder Höhenmessungen durchzuführen. Es wird gezeigt, wie man den Sensor anschließt, die SparkFun-Bibliothek nutzt und die Daten im seriellen Monitor anzeigt. Zusätzlich wird besprochen, wie Druckmessungen durch Höhenkorrekturen angepasst werden können, um verlässliche Vergleiche mit anderen Wetterstationen zu ermöglichen.
Takeaways
- 📡 Der BMP-180 ist ein barometrischer Drucksensor, der Luftdruck und Temperatur misst und hauptsächlich für Wetterstationen verwendet wird.
- 📊 Barometrischer Druck ist der atmosphärische Druck, der durch die Masse der Luft auf der Erdoberfläche verursacht wird.
- ⛰️ Der Druck verändert sich mit der Höhe – in den Bergen gibt es weniger Luftmasse und daher weniger Druck.
- 🌞 Ein steigender Luftdruck deutet auf sonniges, warmes Wetter hin, während ein fallender Druck auf kühles, windiges oder regnerisches Wetter hindeutet.
- 🔧 Der BMP-180-Sensor kommuniziert über I2C und kann an 3,3V oder 5V angeschlossen werden, da er einen Spannungsregler und einen I2C-Pegelwandler besitzt.
- 🌡️ Der Sensor misst auch die Temperatur, um den Luftdruck genauer zu berechnen, da kalte Luft dichter ist und mehr Druck ausübt als warme Luft.
- 🛠️ Der SparkFun BMP-180 Code berechnet den Druck und die Temperatur und zeigt diese in Hektopascal (hPa) und Grad Celsius (°C) an.
- ⏳ Die Genauigkeit des Sensors kann durch Oversampling verbessert werden, wodurch die Messzeit jedoch erhöht wird.
- 📐 Mit dem BMP-180 können Höhenmessungen durchgeführt werden, indem der Luftdruck als Basis verwendet wird.
- 📱 Die Druckwerte müssen möglicherweise für den Meeresspiegel kompensiert werden, um vergleichbare Messungen zu erhalten, was über eine Bibliothek leicht möglich ist.
Q & A
Was ist ein barometrischer Drucksensor und wofür wird er verwendet?
-Ein barometrischer Drucksensor misst den atmosphärischen Druck, der für Wettervorhersagen und Höhenmessungen verwendet wird.
Was misst der BMP-180 Sensor außer dem Luftdruck?
-Der BMP-180 misst auch die Temperatur, da diese den Luftdruck beeinflusst.
Warum muss die Temperatur bei der Druckmessung berücksichtigt werden?
-Temperatur beeinflusst die Dichte der Luft, und somit den Druck. Kalte Luft ist dichter und erzeugt mehr Druck, während warme Luft weniger Druck ausübt.
Wie wird der BMP-180 Sensor mit einem Arduino verbunden?
-Der BMP-180 wird über die I2C-Schnittstelle mit dem Arduino verbunden, wobei SDA an A4 und SCL an A5 angeschlossen werden. VCC kann an 3,3 V oder 5 V angeschlossen werden.
Was bedeutet 'Übersampling' und wie beeinflusst es die Messgenauigkeit des BMP-180?
-Übersampling bezieht sich auf die Anzahl der Proben, die der Sensor zur Berechnung des Drucks verwendet. Höheres Übersampling führt zu präziseren, aber langsameren Messungen.
Wie kann man den Druck auf Meereshöhe anpassen?
-Man kann den Druckwert um einen festgelegten Betrag korrigieren, um die Auswirkungen der Höhe zu eliminieren. Dies wird mit der 'sea level'-Funktion der SparkFun-Bibliothek durchgeführt.
Welche Einheit verwendet der BMP-180 zur Ausgabe des Drucks und warum?
-Der BMP-180 gibt den Druck in Hektopascal (hPa) aus, da dies eine praktischere Einheit ist als der sehr kleine Pascal.
Wie lange dauert es, bis der BMP-180 den Temperaturwert zurückgibt?
-Der BMP-180 benötigt etwa 4,5 Millisekunden, um eine Temperaturmessung durchzuführen.
Wie wirkt sich die Höhe auf den gemessenen Luftdruck aus?
-Mit steigender Höhe gibt es weniger Luftmasse über dem Sensor, was zu einem geringeren Luftdruck führt. Umgekehrt nimmt der Druck bei geringerer Höhe zu.
Was passiert, wenn der BMP-180-Sensor erfolgreich initialisiert wird?
-Wenn der Sensor erfolgreich initialisiert wird, gibt die 'begin'-Funktion einen Wert ungleich Null zurück, was anzeigt, dass die Kalibrierungskoeffizienten des Sensors korrekt geladen wurden.
Outlines
🧑🔬 Einführung in den BMP-180 Barometrischen Drucksensor
In diesem Abschnitt wird erklärt, wie der BMP-180 Sensor verwendet wird, um atmosphärischen Druck mit einem Arduino zu messen. Der BMP-180 ist ein piezo-resistiver Sensor, der über I2C mit dem Arduino kommuniziert und Luftdruck sowie Temperatur messen kann. Der atmosphärische Druck kann zur Wettervorhersage und Höhenmessung genutzt werden.
🌧️ Zusammenhang zwischen Luftdruck und Wetter
Dieser Abschnitt beschreibt, wie Veränderungen im Luftdruck Wetterphänomene vorhersagen können. Ein fallender Luftdruck deutet oft auf kühles, windiges oder regnerisches Wetter hin, während steigender Luftdruck auf warmes und sonniges Wetter hinweist. Dies geschieht durch das Steigen oder Fallen von Luftmassen, was den atmosphärischen Druck auf der Erdoberfläche beeinflusst.
📊 Programmierung des Arduino zur Messung von Druck und Temperatur
In diesem Teil wird die Programmierung des Arduino erklärt, um Druck- und Temperaturmessungen mit dem BMP-180 durchzuführen. Es wird der Ablauf beschrieben, wie der Sensor initialisiert, die Temperatur gemessen und anschließend der Druck anhand der Temperaturwerte korrekt berechnet wird. Verschiedene Oversampling-Raten werden vorgestellt, die die Genauigkeit und Geschwindigkeit der Messungen beeinflussen.
🏔️ Höhenkompensation für präzisere Druckmessungen
Hier wird erläutert, wie man die gemessenen Luftdruckwerte an die Meereshöhe anpasst, um genaue barometrische Druckwerte zu erhalten. Da der Luftdruck mit der Höhe variiert, müssen die Messungen kompensiert werden, um sie mit Wetterdaten aus anderen Quellen vergleichbar zu machen. Dies erfolgt durch eine Funktion, die den Druckwert auf den Wert am Meeresspiegel korrigiert.
Mindmap
Keywords
💡Barometrischer Druck
💡BMP-180 Sensor
💡Arduino
💡I2C-Kommunikation
💡Kalibrierung
💡Temperaturmessung
💡Höhenmessung
💡Überabtastung
💡SparkFun-Bibliothek
💡Serieller Monitor
Highlights
Introduction to the BMP-180 barometric pressure sensor and its uses with Arduino.
Barometric pressure, also known as atmospheric pressure, is used in weather prediction and altitude measurement.
The BMP-180 sensor, made by Bosch, is a piezoresistive sensor that measures air pressure and temperature.
The BMP-180 sensor communicates with Arduino over I2C, using SDA and SCL pins.
Explanation of atmospheric pressure and its effects on weather and altitude.
Description of how barometric pressure is measured and its units (hectopascals and Pascals).
Temperature measurements are crucial for accurate pressure readings as temperature affects air density.
Details on how the BMP-180 library adjusts pressure readings for temperature changes.
Explanation of how atmospheric pressure changes with altitude and its importance.
Description of how weather influences barometric pressure and its use in weather prediction.
Step-by-step guide on setting up the BMP-180 sensor with Arduino and taking measurements.
Introduction to the SparkFun BMP-180 library for handling calculations and reading adjustments.
Demonstration of how to connect the BMP-180 sensor to the Arduino and start taking pressure and temperature readings.
Explanation of how to compensate pressure readings for altitude to compare with standard sea level readings.
Teaser for the next video on using the BMP-180 for altitude calculation based on atmospheric pressure.
Transcripts
foreign
[Music]
we're going to learn how to use the
bmp-180 parametric pressure sensor with
the Arduino
parametric pressure sensors are standard
equipment in professional and DIY
weather stations
barometric pressure is another term for
atmospheric pressure
atmospheric pressure
is a natural force that can be used to
predict weather and even measure
altitude
in the next video we'll see how to use
the BMP 180 to measure altitude
but in this video we'll find out what
atmospheric pressure is then look at a
sketch that prints the pressure and
temperature measurements to the serial
monitor
the bmp1ab sensor I'm going to use is a
breakout board from Adafruit
the sensor itself is a bmp-180 made by
Bosch
the bmp-180 has five pins
it communicates with the Arduino over
i2c
so it has SDA and scl pins
here's the ground pin
and this is the VCC pin
it says three volts but this breakout
has a voltage regulator and an i2c level
shifter
so you can connect it to 5 volts too
pin adjust the operating voltage of the
sensor so it can be used in low voltage
projects
the bmp180 is a pzo resistive sensor
PCO resistive sensors are a type of
transducer where a physical force causes
a change in resistance of the sensor
element
in the bmp-180 that forces air pressure
the bmp-180 can measure any form of air
pressure
like the pressure inside a sealed
container
but it's mainly used to measure
barometric pressure
barometric pressure is caused by the
weight of the atmosphere pressing down
on the Earth's surface
imagine a one inch by one inch column of
air from the surface of the Earth to the
top of the atmosphere
all gases have mass including the air in
the atmosphere
and due to gravity this massive air
exerts a pressure on the Earth's surface
at the Earth's surface this one inch by
one inch column of air weighs 14.7
pounds
a common unit of pressure measurement is
the atmosphere or ATM
One ATM is defined as 14.7 pounds per
square inch
the SI unit of pressure is the Pascal
but one pascal is very small
it's about the pressure that a single
piece of paper exerts on a table top
so for more practical usage we usually
use the hectopascal which equals 100
pascals
the bmp-180 outputs pressure readings in
hectopascals
but you can convert it to any other unit
of pressure
the bmp-180 also measures temperature
since temperature affects the density of
gases like air
it also affects the pressure exerted by
that massive air
colder temperatures cause air to become
more dense so it weighs more and exerts
more pressure
warmer temperatures make the air less
dense
so it weighs less and exerts less
pressure
we can use the temperature measurements
to make the pressure readings more
accurate
actually this will be done by the
library we're going to use
atmospheric pressure also changes with
altitude
if you're up in the mountains there's
less air above you
and less air mass to create pressure
if you're at sea level there's more air
above you
which creates more atmospheric pressure
we'll look at altitude effects on
atmospheric pressure in the next video
but for now let's look at something else
that can influence atmospheric pressure
the weather
for hundreds of years barometers have
been used to predict the weather
usually a rising barometric pressure
means that warm sunny weather is coming
a following barometric pressure usually
means that cool windy or rainy weather
is coming
a following barometric pressure is
caused by a massive air rising from the
Earth's surface
the vacuum created by the rising air
mass forms a low pressure area on the
surface
as the air mass gets higher in altitude
it cools down and compresses
water vapor in the air forming rain
clouds
it usually brings wind too because the
surrounding air on the surface flows
into the low pressure area
a rising barometric pressure is caused
by a massive air in the upper atmosphere
falling to the Earth
the weight of the falling Mass presses
down on the surface increasing the air
pressure below it
the air mass gets warmer and expands as
it gets closer to the surface
this warm expanding air is usually low
in humidity which prevents cloud
formations
Rising barometric pressures usually
indicate that warm sunny weather is
coming
okay now let's set up the BMP 180 on the
Arduino and take some measurements
the bmp-180 uses i2c to communicate with
the Arduino
the Arduino Uno has the SDA pin at
Analog pin A4
and the scl pin at Analog pin A5
other arduinos have the i2c pins in
different locations
so be sure to check that before
connecting it
all you have to do is connect SDA to SDA
scl to scl
ground to ground
and VCC to either 5 volts or 3.3 volts
connecting it to 5 volts here
okay now for the library
SparkFun has a great library for the
bmp-180 called sfe bmp180
this library takes care of all the math
needed to adjust the pressure readings
for changes in temperature
it also has functions that calculate
altitude
you can download the library from GitHub
at this link
once you get that installed you're ready
to start programming
foreign
this sketch is going to Output the
barometric pressure and temperature to
the serial monitor
now as with all projects that use i2c we
need to include the built-in wire
Library
then we need to include the bmp-180
library with hash include
sfe underscore bmp180.h
next we create a BMP 180 object from the
sfe bmp-180 class
this will let us access all the
functions in the library
in the setup section we first initialize
the serial monitor
then we initialize the bmp-180 with the
begin function
the begin function downloads some
calibration coefficients from the sensor
that are needed for the pressure and
temperature calculations
it returns a non-zero value
which gets stored in a Boolean variable
called success
to check that the initialization was
successful we use an if statement with
the success variable as the condition
so if the sensor successfully
initializes and the begin function
Returns the non-zero value
the condition inside here will be true
and we enter the statement and Print
bmp180 in its success to the serial
monitor
if the initialization fails the success
variable will hold a zero value making
this false
if that's the case we won't get the
success message and we'll know something
is wrong with this sensor or the way
it's connected
in the loop section we first declare
some variables
the care variable status will hold
different values that control the flow
of the temperature and pressure
measurement process
the double variables T and P are going
to hold the temperature and pressure
values
here we set the success variable to
false
so that it doesn't have a True Value the
next time the Arduino starts up
now we start a temperature measurement
with the start temperature function
this function Returns the time in
milliseconds the Arduino needs to wait
before receiving the temperature
measurement
the sensor takes 4.5 milliseconds to
measure the temperature
perform the calculations
and return our reading
so we can't get the temperature reading
right away
now we enter into a series of nested if
statements that make sure that we read
the sensor values in the right order and
at the right time
if the start temperature function
successfully notifies the sensor to
start a temperature measurement
the status variable will hold the
non-zero value
that will make this condition true
so the program will enter the first if
statement
we only need to wait 4.5 milliseconds
before the temperature reading is ready
but we're going to wait a full second to
slow down the output and make it easier
to read
so we delay 1000 milliseconds here
now we can receive the temperature value
to do that we use the get temperature
function
this function gets the temperature
reading from the sensor and passes it to
the argument here
in this case the argument is the
variable t
so the temperature reading will be
stored in the T variable
but the function itself returns a 1 if
the temperature reading is successfully
received
and a zero if it's not
and that value will be stored in status
if the temperature reading was
successfully received the value of
status will be 1.
making the condition inside the next if
statement true
this makes sure we get a valid
temperature reading before we start the
pressure measurement
then we start a pressure measurement
with the start pressure function
the argument of the function sets the
oversampling rate of the sensor
oversampling sets how precise the
bmp-180's pressure measurements are
the value can be 0 1 2 or 3.
a zero sets it at the lowest resolution
and a 3 sets it at the highest
resolution
lower resolution means the sensor takes
fewer samples
so the measurement is performed faster
but it's also less accurate
a higher resolution means it takes more
samples
which takes longer but the reading is
more accurate
the start pressure function Returns the
number of milliseconds we need to wait
before receiving the pressure value
so if the measurement was started
successfully
status will hold a non-zero value and
the program will enter the next if
statement
the time we need to wait before
receiving the pressure measurement
depends on how your oversampling is set
if your oversampling is set to the
highest setting three
you have to wait about 26 milliseconds
but if it's set to the lower setting
zero you only need to wait about five
milliseconds
we can use the delay function with
status as an argument
to delay the exact number of
milliseconds we need to wait until the
pressure measurement is ready to read
after that we can receive the pressure
values with the get pressure function
the get pressure function takes two
arguments p and t
the temperature value measured earlier
is stored in t
which is passed to the function to
perform the pressure calculations
the result of the pressure calculation
is stored in the P variable
the get pressure function returns a 1 if
the pressure measurement was
successfully received from the sensor
and a zero if not
so if the pressure measurement was
successfully received
status will contain a 1. and the
condition of the next if statement will
be true
inside the next if statement we print
the TMP variables to the serial monitor
first we print the word pressure equals
with a space
then we print the P variable on the same
line
the pressure measurements are in
hectopascals
so after that we print HPA with the
serial print line to end the line
now we do the same thing with the
temperature
I print the word temperature
then the T variable
then serial print line a c since the
temperature measurement is in Celsius
okay let's upload this and check it out
I have my BMP 180 connected to my
Arduino
you can see the pressure and temperature
measurements starting to come through
it's pretty amazing how sensitive the
sensor is when I lift the sensor up you
can see the pressure measurement go down
and when I lower the sensor the pressure
measurement goes up
that makes sense since lifting the
sensor higher puts less air mass above
it and results in a lower atmospheric
pressure
lowering it puts more air mass above it
so the pressure gets higher
the pressure reading here is the
barometric pressure at my current
altitude
we saw earlier that the barometric
pressure is affected by altitude
this will be fine if all you want to do
is measure changes in pressure
but if you're building a weather station
you'll probably want to compare the
reading from the bmp-180 to pressure
readings reported by different news and
weather channels
but those readings might have been taken
from a different altitude than yours
so we need to adjust the pressure
reading to remove the effects of
altitude
to do that we can add a fixed amount of
pressure to our readings to make it seem
like the measurement was taken at sea
level
all weather stations do this to make the
barometric pressure readings from
stations at different altitudes
comparable
that way you'll know a low pressure
reading at one station was caused by the
weather and not due to a tire altitude
the SparkFun library has a function that
makes this easy
we only have to make a few changes to
the original sketch
first we declare an INT variable called
altitude
this will hold the altitude of your
current location in meters
if you don't know your altitude you can
look it up online or use an app on your
phone
the rest of the sketch Remains the Same
except for the last if statement
the SparkFun library has a function
called sea level
that outputs an altitude compensated
pressure reading
it takes two parameters
the pressure variable and the altitude
variable
I'm going to store the result in a local
float variable called comp for
compensated
now instead of printing the
uncompensated pressure variable p
we print the comp variable
and that's it
I won't demonstrate this sketch because
my altitude is only 5 meters above sea
level so it doesn't make a big
difference
but if you live at a higher elevation
it's definitely going to have an effect
in fact a difference in altitude of only
8 meters changes the barometric pressure
by one hectopascal
in the next video we're going to see how
to use the bmp180s atmospheric pressure
measurements to calculate your altitude
[Music]
the three in one smart car and iot
learning kit from Sun founder is a
Hands-On all included Electronics kit
that is perfect for anyone who wants to
learn how to master the Arduino
the kit comes with an Arduino 22
different sensors and modules
breadboards jumper wires and everything
else you need to build a bunch of fun
and interesting projects
learn about robotics by building a
remote controlled smart car that can be
controlled with an infrared remote
controller
or drive on its own and avoid obstacles
or fall on the line
learn about the internet of things with
a project that lets you monitor the
temperature humidity and light level of
a room from an app on your smartphone
[Music]
and build a plant monitor that tracks
the temperature humidity light intensity
and soil moisture
displays it on your smartphone so you
can keep your plants water remotely
it's a super cool kit and I have lots of
fun building all the projects in it so
click the link in the description below
to order the kit from Sun founder
Ver Más Videos Relacionados
Crashkurs für Anfänger | Canva Tutorial Deutsch
An Introduction to the BM EE - Extended Essay - IB Business Management
Facebook Pixel erstellen und installieren [2024] - Schritt-für-Schritt-Anleitung
GAUß ALGORITHMUS einfach erklärt – lineare Gleichungssysteme lösen
Forsche mit uns! Farbige Salzkristalle selber züchten - so geht's!
Frag Fred: Was sind Cookies? | Kindervideos | SRF Kids
5.0 / 5 (0 votes)