Created
October 24, 2017 17:28
-
-
Save windymelt/6291f8b9c78ce35d46174a1a263498d6 to your computer and use it in GitHub Desktop.
BMP085/ESP-WROOM-02
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 <Adafruit_BMP085.h> | |
// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!) | |
// Connect GND to Ground | |
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5 | |
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4 | |
// EOC is not used, it signifies an end of conversion | |
// XCLR is a reset pin, also not used here | |
Adafruit_BMP085 bmp; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
Wire.begin(); | |
delay(1000); | |
if (!bmp.begin()) { | |
Serial.println("Could not find a valid BMP085 sensor, check wiring!"); | |
while (1) {} | |
} | |
} | |
void loop() { | |
Serial.print("celsius_temperature:"); | |
Serial.print(bmp.readTemperature()); | |
Serial.print("\t"); | |
Serial.print("pressure_pascal:"); | |
Serial.print(bmp.readPressure()); | |
Serial.print("\t"); | |
// Calculate altitude assuming 'standard' barometric | |
// pressure of 1013.25 millibar = 101325 Pascal | |
Serial.print("alt_meter:"); | |
Serial.print(bmp.readAltitude()); | |
Serial.print("\t"); | |
Serial.print("pressure_sealevel_pascal:"); | |
Serial.print(bmp.readSealevelPressure()); | |
Serial.print("\t"); | |
// you can get a more precise measurement of altitude | |
// if you know the current sea level pressure which will | |
// vary with weather and such. If it is 1015 millibars | |
// that is equal to 101500 Pascals. | |
// Serial.print("real_alt_meter:"); | |
// Serial.print(bmp.readAltitude(101500)); | |
// Serial.print("\t"); | |
Serial.println(); | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment