#2 — The ESP32 With The BMP180 Sensor

We can have an actual thermometer???

Carissa Aurelia
I learn ESP32 (and you should too).
4 min readFeb 8, 2020

--

Thermometer. Photo by Jarosław Kwoczała on Unsplash

Yep, you heard it right, folks. We can make our own thermometer. And it comes in package with a barometer and an altimeter. In this second project of the ESP32 series, I’mma show you how to do it. Prepare to be amazed as I was…

The BMP180 Barometric Sensor

The BMP180 Sensor. Source: private documentation

According to randomnerdtutorials.com’s article post, The BMP180 is one of the available digital pressure sensors. There are other sensors that can do the same job such as the BME280 and the DHT11. As you can guess by its name, the BME280 and the BMP180 chip comes from the same manufacturer which is the Bosch Sensortec. Looking at Adafruit’s website, we can see that the BME280 is an upgrade to the BMP180 that we can use with either the SPI or the I2C module, whereas with the BMP180, we can only use the I2C (hence the four pins). The BMP180 has already discontinued production on the website, but I was lucky to be able to find it with ease here.

The BMP180 measures the absolute pressure of the air around it, ranging from 300 to 1100hPa with an accuracy down to 0.02 hPa. And because temperature affects the pressure, the sensor comes with a built-in temperature sensor to give temperature-compensated pressure readings. We can also estimate the altitude based on the current pressure measurement because pressure changes with altitude.

Alright, enough the chit-chat. Let’s get amazed :)

1. The ingredients

The ingredients. Source: private documentation

As per usual, I’m going to use my laptop, my ESP32 board, my breadboard, a MicroUSB to USB cable, a few male-to-male (I bought proper jumper wires yaaay 🎉🎉) jumper wires, and the BMP180 Sensor.

Now here’s the real challenge: the BMP180 sensor that I bought comes unsoldered 😱😱. I had a very bad experience with soldering because I once ended up burning the whole PCB when I was doing an electronics project in highschool. But well, the show must go on. Forever grateful to Hollyana Puteri Haryono for lending me her soldering iron and to Kevincahyadigiri (my partner for the ESP32 project) for encouraging and helping me out :)

Soldering the hell outta this wee lil’ sensor. Source: private documentation

Now it looks good and neat from the outside and that should mean a good sign. We’ll see… *suspense music*

2. Installing the library

I need to first install the BMP180 library. Following randomnerdtutorials.com, I’ll be using the BMP_085 library by Adafruit. Head on to the GitHub site and download the whole thing in .zip format or clone the repo. If you download it in .zip format, make sure to unzip it.

Installing the Adafruit BMP085 Library. Source: private documentation

Opening the Arduino IDE, I installed the library by heading to the Sketch > Include Library > Manage Libraries. Restart the IDE afterwards.

3. Wiring it up

Wiring table. Source: https://randomnerdtutorials.com/esp32-with-bmp180-barometric-sensor/

I extracted this table from randomnerdtutorials.com and it basically shows you where to stick the ends of your jumper wires. Make sure to wire it at the right place and check it before plugging the ESP32 to power source because some misplacements may be fatal.

Code for testing the BMP180 sensor. Source: private documentation

Then I went and copied the whole code from the website. The code looks like this:

4. Final steps

Upload the code (shoutout to Adriel for letting me borrow his ASUS Zenbook Duo for uploading purposes), open the serial monitor at the right baud rates, and voila 👏👏🎉🎉💯💯

c Serial monitor readings. Source: private documentation

IT WORKS! I’m so glad I don’t mess the sensor with my poor soldering skills 😅😅

5. Lessons learnt

  1. I cannot stress this enough but always, always check. your. wirings — before plugging the power source. At first, I have the SDA pin of the BMP180 wired to the wrong GPIO pin of the ESP32 and as you can guess, the readings won’t come out. A friend of mine also has his wirings wrong and ends up with the same fate. Luckily I was able to quickly figure out what’s wrong with my circuit. It’s a really small mistake but can turn very fatal (imagine if you wire the 3.3V pin to the ground pin 😅)
  2. Soldering is a very vital part! If you’re not sure about soldering by yourself, ask your friend’s help. Because otherwise, you’ll end up burning the sensor and rendering it broken before use. Unless you want to be dauntless to try soldering by yourself. Just be careful!

--

--