IOT

How to Interface BMP180 with ESP32?

This guide will show you how to connect a BMP180 to an ESP32 DevKit Development Board. BMP180 is one of the most affordable options if you want to develop a Web-based Pressure and Temperature Monitoring System with ESP32 (there are definitely better sensors than BMP180, like BME280 for example). 

To show the pressure and temperature data on an LCD, set up the Arduino IDE, and discover how the ESP32 BMP180 Pressure and Temperature Sensor Interface functions. A straightforward ESP32 Web Server that continuously shows the pressure and temperature from a BMP180 Sensor is also a possibility.

ESP32-BMP180-Image-2

BMP180 Sensor

BMP180 Sensor was previously covered in the Arduino BMP180 Tutorial. However, let’s review some crucial information regarding the sensor. The digital barometric pressure sensor from Bosch is called the BMP180. It is a piezoresistive MEMS-based ultra-low power device. It is capable of measuring air pressure between 300 and 1100 hPa.

The BMP180 Sensor can monitor the temperature in the range of 00C to 650C in addition to pressure. Since BMP180 detects atmospheric pressure, it is simple to determine the point’s height (as they both are related).

BMP180-Module-Front

The real BMP180 Sensor is a tiny device with measurements of 3.6mm x 3.8mm. It can be purchased in a 7-pin LGA package and interfaces with microcontrollers via either I2C or SPI (only one is possible in the final sensor).

The calibration of sensors is a significant consideration. To give findings that are acceptable, a sensor needs to be calibrated correctly. The Bosch BMP180 Barometric Pressure Sensors are fortunately all factory calibrated and ready to use.

Numerous independent module and sensor producers used the tiny BMP180 Sensor to create a compact Module that is ideal for Arduino and other DIY Projects. Today’s modules mostly make advantage of I2C communication. [Projects for Novice ESP32 Users]

Pin Diagram of BMP180

The Pins of the BMP180 Sensor are depicted in the next image. The pins on the back of the module are labelled.

BMP180-Module-Back

As you can see, there are four pins on the BMP180 Module:

  • VIN
  • GND
  • SCL
  • SDA

ESP32 BMP180 Interface

After learning a little bit more about the BMP180 Pressure and Temperature Sensor, let’s move on to learning how to connect the BMP180 to the ESP32. You must first keep in mind that BMP180 is a digital sensor.

Next, keep in mind that the BMP180 Sensor communicates with a microcontroller using the I2C interface. If you recall the ESP32 pinout, GPIO 21 (SDA) and GPIO 22 are the device’s default I­2C pins (SCL). The ESP32 DevKit Development Board refers to them as D21 and D22, respectively.

So, in order to communicate with the BMP180 Sensor, we must use these pins.

Components Required

  • ESP32 DevKit Development Board
  • BMP180 Pressure and Temperature Sensor (Module)
  • 16×2 LCD
  • PCF8574 I2C LCD Module
  • Breadboard
  • Connecting Wires
  • Micro USB Cable

Circuit Diagram

The connections between the ESP32 and the BMP180 are depicted in the next image. The BMP180 Module includes a 3.3V regulator on board. So, you can use 5V to power the board. Connect the ESP32 board’s VIN to the BMP180’s VIN. Additionally, join any ESP32 GND pin with the GND pin of the BMP180.

Now, moving on to the I2C pins, attach SDA to the ESP32’s GPIO 21 (labelled D21 on the board), and SCL to GPIO 22. (which is marked as D22). After that, all connections are complete.

ESP32-BMP180-Circuit

Preparing Arduino IDE

To ensure that ESP32 and the BMP180 Sensor can interact effectively, you must download one library related to the sensor. In the Arduino IDE, select Tools -> Manage Libraries…

BMP180-Library-1

Enter “bmp180” in the search box and install “Adafruit BMP085 Library” from Adafruit.

BMP180-Library-2

Displaying Pressure and Temperature on Serial Monitor

We will now examine how to read the Pressure and Temperature data from the BMP180 Sensor using the ESP32 and display the result on the Serial Monitor after creating the right connections and installing the required libraries as indicated before.

Code

I2C bus is used by the BMP180 Sensor to communicate with the microcontroller. I created some straightforward code that would setup the BMP180 Sensor and read its data for Pressure and Temperature.

I just printed the temperature and pressure numbers in degrees Celsius and hPa on the serial monitor to see the outcome.

  #include <Adafruit_BMP085.h>
   
  Adafruit_BMP085 bmp;;
  void setup()
  {
  Serial.begin(115200);
  if (!bmp.begin())
  {
    Serial.println(“BMP180 Sensor not found ! ! !”);
    while (1)
    {
    
    }
  }
  }
   
  void loop()
  {
  Serial.print(“Pressure = “);
  Serial.print(bmp.readPressure());
  Serial.print(” hPa”);
  Serial.print(”  Temp = “);
  Serial.print(bmp.readTemperature());
  Serial.println(“ºC”);
  delay(3000);
  }
ESP32-BMP180-Image-3

The Serial Monitor, which continuously prints the pressure and temperature readings every three seconds, is screenshotted in the following image.

ESP32 BMP180 with I2C LCD

The BMP180 Sensor’s pressure and temperature data can be shown on a serial monitor for checking the connections and the code itself. You must need a display module of some kind (OLED, 162 Character LCD, Nokia 5110 LCD, graphical LCD, etc.) to view the pressure and temperature measurements in order to create a useful “Embedded System” application.

To display the pressure and temperature information from the ESP32 BMP180 Sensor Interface, I combined a normal 162 Character LCD Display Module with a PCF8574 I2C LCD Module.

I created a specific guide on using an I2C LCD with the ESP32. For further details, see that tutorial. In that lesson, I also covered the required libraries that you must download in order to effectively connect an I2C LCD to an ESP32.

NOTE: In that tutorial, I also covered how to find the I2C LCD module’s slave address. This action is crucial.

Circuit Diagram

Two further parts are needed: a 16*2 LCD display and an I2C LCD module (based on PCF8574). Connect the I2C LCD Module to the 16*2 LCD Display’s back. Only four connections are necessary for the I2C LCD Module (two of them are for power and two are for data).

The accompanying circuit diagram shows every connection that must be made between the ESP32 and the I2C LCD Module and between the ESP32 and the BMP180 Pressure and Temperature Sensor.

Code

The ESP32 BMP180 Sensor Interface with I2C LCD code is fairly straightforward. The sensor’s initialization phase resembles the earlier code. The only additional code is for the LCD.

  #include <Adafruit_BMP085.h>
  #include <Wire.h>
  #include <LiquidCrystal_I2C.h>
  /Adafruit_BMP085 bmp;
  LiquidCrystal_I2C lcd(0x3F, 16, 2);
   
  byte degree_symbol[8] =
              {
                0b00111,
                0b00101,
                0b00111,
                0b00000,
                0b00000,
                0b00000,
                0b00000,
                0b00000
              };
  void setup()
  {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print(”  BMP180  with “);
  lcd.setCursor(0,1);
  lcd.print(”  ESP32 DevKit “);
  lcd.createChar(0, degree_symbol);
  if (!bmp.begin())
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(” BMP180 Sensor  “);
    lcd.setCursor(0,1);
    lcd.print(” not found ! ! !”);
    while (1)
    {
    
    }
  }
  delay(2000);
  lcd.clear();
  }
   
  void loop()
  {
  lcd.setCursor(0,0);
  lcd.print(“Pressure=”);
  lcd.setCursor(9,0);
  lcd.print(bmp.readPressure());
  lcd.setCursor(13,0);
  lcd.print(“hPa”);
   
  lcd.setCursor(0,1);
  lcd.print(”  Temp = “);
  lcd.setCursor(9,1);
  lcd.print(bmp.readTemperature());
  lcd.write(0);
  lcd.print(“C”);
  delay(1000);
  }
ESP32-BMP180-Image-1

Conclusion

Hope this blog helps you to understand How to Interface BMP180 with ESP32? We, MATHA ELECTRONICS  will come back with more informative blogs.

Leave a Reply

Your email address will not be published. Required fields are marked *