Created
September 21, 2023 08:03
-
-
Save kakopappa/7dbc54e5385d57d181377248b0e5b4ee to your computer and use it in GitHub Desktop.
BMP180
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_Sensor.h> | |
#include <Adafruit_BMP085.h> | |
Adafruit_BMP085 bmp; // Default I2C | |
void setup() { | |
Serial.begin(9600); | |
bool status = bmp.begin(); | |
if (!status) { | |
Serial.println("Could not find BMP180 sensor!"); | |
while (1); | |
} | |
} | |
void loop() { | |
Serial.print("Temperature = "); | |
Serial.print(bmp.readTemperature()); | |
Serial.println(" *C"); | |
// Convert temperature to Fahrenheit | |
/*Serial.print("Temperature = "); | |
Serial.print(1.8 * bmp.readTemperature() + 32); | |
Serial.println(" *F");*/ | |
Serial.print("Pressure = "); | |
Serial.print(bmp.readPressure() / 100.0F); | |
Serial.println(" hPa"); | |
Serial.print("Altitude (Approx) = "); | |
Serial.print(bmp.readAltitude()); | |
Serial.println(" m"); | |
Serial.print("Pressure = "); | |
Serial.print(bmp.readSealevelPressure()); | |
Serial.println(" Pa"); | |
Serial.println(); | |
delay(1000); | |
} | |
// Ref: https://github.com/adafruit/Adafruit-BMP085-Library/blob/master/examples/BMP085test/BMP085test.ino |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment