BMP180 Pressure Sensor Module Documentation
The BMP180 Pressure Sensor Module is a high-precision atmospheric pressure sensor module based on the BMP180 chip from Bosch Sensortec. It measures atmospheric pressure with high accuracy and can be used in various IoT applications such as weather stations, altitude tracking, and indoor navigation.
VCC: Power supply (3.3V to 5V)
GND: Ground
SCL: I2C Clock
SDA: I2C Data
XCLR: Not connected (NC)
The BMP180 Pressure Sensor Module communicates with a microcontroller using the I2C protocol.
### Example 1: Reading Pressure and Temperature using Arduino
This example demonstrates how to read the pressure and temperature values from the BMP180 sensor using an Arduino board.
#define BMP180_ADDRESS 0x77
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
int32_t pressure = 0;
int32_t temperature = 0;
// Start I2C transmission
Wire.beginTransmission(BMP180_ADDRESS);
// Send command to start measurement
Wire.write(0xF4);
Wire.write(0x2E);
// End transmission
Wire.endTransmission();
// Wait for measurement to complete
delay(5);
// Start I2C transmission
Wire.beginTransmission(BMP180_ADDRESS);
// Read pressure data
Wire.write(0xF6);
Wire.endTransmission();
Wire.requestFrom(BMP180_ADDRESS, 3);
pressure = (Wire.read() << 16) | (Wire.read() << 8) | Wire.read();
// Start I2C transmission
Wire.beginTransmission(BMP180_ADDRESS);
// Read temperature data
Wire.write(0xF7);
Wire.endTransmission();
Wire.requestFrom(BMP180_ADDRESS, 2);
temperature = (Wire.read() << 8) | Wire.read();
// Print pressure and temperature values
Serial.print("Pressure: ");
Serial.print(pressure / 100.0); // Convert to hPa
Serial.println(" hPa");
Serial.print("Temperature: ");
Serial.print(temperature / 10.0); // Convert to degrees Celsius
Serial.println(" C");
### Example 2: Reading Pressure and Temperature using Raspberry Pi (Python)
This example demonstrates how to read the pressure and temperature values from the BMP180 sensor using a Raspberry Pi and Python.
```python
import i2c
import time
# I2C address of BMP180
BMP180_ADDRESS = 0x77
# Initialize I2C bus
i2c_bus = i2c.I2CBus(1)
# Start I2C transmission
i2c_bus.write_byte(BMP180_ADDRESS, 0xF4)
i2c_bus.write_byte(BMP180_ADDRESS, 0x2E)
# Wait for measurement to complete
time.sleep(0.005)
# Read pressure data
pressure_data = i2c_bus.read_i2c_block_data(BMP180_ADDRESS, 0xF6, 3)
pressure = (pressure_data[0] << 16) | (pressure_data[1] << 8) | pressure_data[2]
# Read temperature data
temperature_data = i2c_bus.read_i2c_block_data(BMP180_ADDRESS, 0xF7, 2)
temperature = (temperature_data[0] << 8) | temperature_data[1]
# Print pressure and temperature values
print("Pressure: {:.2f} hPa".format(pressure / 100.0))
print("Temperature: {:.1f} C".format(temperature / 10.0))
# Close I2C bus
i2c_bus.close()
```
### Example 3: Reading Altitude using ESP32 (MicroPython)
This example demonstrates how to read the altitude value from the BMP180 sensor using an ESP32 board and MicroPython.
```python
import machine
import utime
# I2C address of BMP180
BMP180_ADDRESS = 0x77
# Initialize I2C bus
i2c_bus = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21))
# Start I2C transmission
i2c_bus.start()
i2c_bus.writebyte(BMP180_ADDRESS, 0xF4)
i2c_bus.writebyte(BMP180_ADDRESS, 0x2E)
# Wait for measurement to complete
utime.sleep_ms(5)
# Read pressure data
pressure_data = i2c_bus.readfrom_mem(BMP180_ADDRESS, 0xF6, 3)
pressure = (pressure_data[0] << 16) | (pressure_data[1] << 8) | pressure_data[2]
# Calculate altitude using barometric formula
altitude = 44330 (1 - (pressure / 101325) (1 / 5.255))
# Print altitude value
print("Altitude: {:.2f} meters".format(altitude))
# Close I2C bus
i2c_bus.stop()
```