Note
Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.
Why Join?
Expert Support: Solve post-sale issues and technical challenges with help from our community and team.
Learn & Share: Exchange tips and tutorials to enhance your skills.
Exclusive Previews: Get early access to new product announcements and sneak peeks.
Special Discounts: Enjoy exclusive discounts on our newest products.
Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
👉 Ready to explore and create with us? Click [here] and join today!
BMP180
Overview
In this tutorial, we delve into the GY-87 IMU module, focusing on the BMP180 sensor for measuring temperature, pressure, and altitude. Ideal for applications like weather monitoring and altitude tracking, this lesson covers interfacing the GY-87 with an Arduino Uno and using the Adafruit BMP085 library. You’ll learn how to initialize the BMP180 sensor and read its data on the Arduino Serial Monitor, a crucial skill for projects that require environmental data.
Required Components
In this project, we need the following components.
It’s definitely convenient to buy a whole kit, here’s the link:
Name |
ITEMS IN THIS KIT |
LINK |
---|---|---|
Elite Explorer Kit |
300+ |
You can also buy them separately from the links below.
COMPONENT INTRODUCTION |
PURCHASE LINK |
---|---|
- |
|
- |
Wiring
Schematic Diagram
Code
Note
You can open the file
09-gy87_bmp180.ino
under the path ofelite-explorer-kit-main\basic_project\09-gy87_bmp180
directly.Or copy this code into Arduino IDE.
Note
To install the library, use the Arduino Library Manager and search for “Adafruit BMP085 Library” and install it.
Code Analysis
initializeBMP180()
Initialize the BMP180 sensor.
void initializeBMP180() { // Start BMP180 initialization if (!bmp.begin()) { Serial.println("Could not find a valid BMP180 sensor, check wiring!"); while (1) ; // Halt if sensor not found } Serial.println("BMP180 Found!"); }
printBMP180()
Print the values read by the BMP180 sensor.
void printBMP180() { Serial.println(); Serial.println("BMP180 ------------"); Serial.print("Temperature = "); Serial.print(bmp.readTemperature()); Serial.println(" *C"); Serial.print("Pressure = "); Serial.print(bmp.readPressure()); Serial.println(" Pa"); // Calculate altitude assuming 'standard' barometric // pressure of 1013.25 millibar = 101325 Pascal Serial.print("Altitude = "); Serial.print(bmp.readAltitude()); Serial.println(" meters"); Serial.print("Pressure at sealevel (calculated) = "); Serial.print(bmp.readSealevelPressure()); Serial.println(" Pa"); Serial.println("BMP180 ------------"); Serial.println(); }