BMP180

Wiring a BMP180 sensor to an ESP32 microcontroller

Like with every sensor, use the PINOUT diagram of ESP32 to make sure of the microcontroller’s pins’ names.
Connect the sensor’s GND pin with the GND pin of the microcontroller, 3.3V pin with the 3.3V pin, SDA pin of the sensor with the SDA pin of the microcontroller
(on the PINOUT diagram marked as the 21), and finally the sensor’s SCL pin with the microcontroller’s SCL pin (marked as the 22).

Wiring diagram of BMP180

Testing BMP180 sensor

Download the BMP180 library for the sensor. Before uploading the library to the microcontroller, take a look at line 55 of the library.

1self._bmp_addr = 119  # fix

119 is the sensor’s address on the microcontroller. This address is very important, as it allows the microcontroller to communicate specifically with that sensor, which is key when you need to read data from the sensor or send him commands on how to behave.

Your sensor’s address on your microcontroller can differ from this one, so do the following to check the address:

  • Using MobaXTerm, connect to the microcontroller.
  • In the command prompt that appears after the connection, run the following commands, one by one:
    • import machine
    • bmp180 = machine.SoftI2C(sda=machine.Pin(21), scl=machine.Pin(22))
    • bmp180.scan()

After the last command is run, in the next line you should see “[”the sensor’s address”]”.

Tip

The address of my sensor is 119, just like in the library. If your sensor's address is different, replace 119 with this address and save the change.
Address of BMP180 sensor

Now upload the library to the microcontroller, just like the other libraries, using ampy.

BMP180 library

To test if sensor is working, connect to the microcontroller again and run the following commands in the terminal:

1from bmp085 import BMP180 
2from machine import SoftI2C, Pin 
3i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
4bmp = BMP180(i2c)
5bmp.oversample = 2
6bmp.sealevel = 101325 
7bmp.blocking_read()
8bmp.temperature #in the next line, you should see the measured temperature
9bmp.pressure #in the next line, you should see the measured pressure
10bmp.altitude #in the next line, you should see the measured altitude
BMP180 testing code

According to the documentation, the temperature is expressed in degrees C, the pressure in hPa, and the altitude in meters.