ESP32 and BMP085 example

This sensor is obsolete now and has been replaced by newer ones but if you still have them lying about then this is how to connect them up to an ESP32

The BMP085 is a high-precision, ultra-low power barometric pressure sensor for use in advanced mobile applications. With a range of 300 hPa to 1100 hPa, an absolute accuracy of 2.5 hPa, and a noise level of down to 0.03 hPa (which is equivalent to an altitude change of merely 0.25 m) the BMP085 offers superior performance.

 

Schematics/Layout

 

esp32 and bmp085
esp32 and bmp085

Code

Install the Adafruit BMP085 library via the Arduino IDE


#include
#include

/***************************************************
This is an example for the BMP085 Barometric Pressure & Temp Sensor

Designed specifically to work with the Adafruit BMP085 Breakout
—-> https://www.adafruit.com/products/391

These displays use I2C to communicate, 2 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/

// 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() {
Serial.begin(9600);
if (!bmp.begin()) {
Serial.println(“Could not find a valid BMP085 sensor, check wiring!”);
while (1) {}
}
}

void loop() {
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();
delay(500);
}
[/cpp}

Output

Open the serial monitor and you should see something like this

Temperature = 24.00 *C
Pressure = 101779 Pa
Altitude = -37.32 meters
Pressure at sealevel (calculated) = 101776 Pa

Temperature = 25.00 *C
Pressure = 101772 Pa
Altitude = -37.32 meters
Pressure at sealevel (calculated) = 101774 Pa

 

Link

SHARE
Previous articleESP32 performing a software reset
Next articleESP32 and Bargraph display example