Adding a BMP180 to an ESP8266-01

esp8266-01-bmp180After I added an RTC and an OLED to the ESP8266-01 through I2C, I presumed it should not be too difficult to add a BMP180 as well, in spite of coming across some postings on Internet of people not succeeding.

My BMP180 module -from my Arduino days- was a 5 Volt module, which made me think I may need a level shifter, which would be a pity as the BMP180 is in fact a 3.3V chip.

bmp180-5-33The circuit of my BMP180 module shows that the I2C pull up resistors (4k7) are in fact connected to the 3.3 V line that is provided by a 662k voltage regulator (as was to be expected). This meant that even if I fed the module with 5 Volt, I would not need a level shifter. And as the 662K is a low drop regulator and the BMP 180 also works with voltages lower than 3.3 (1.8-3.6 in fact), I presumed I didn’t need 5 Volt whatsoever.
The connection of the BMP180 is simple Vcc to Vcc, Ground to ground, SDA to SDA and SCL to SCL. On the ESP8266 I am using GPIO0 as SDA and GPIO2 as SCL


Just some remarks on the BOM

  • ESP8266-01: If you still have to buy this, consider an ESP8266-12. it isn’t much more expensive and has more pins. Some modules like Wemos D1 even have an USB added
  • BMP180: If you still need to buy this, consider a BMP280 that is more precise and cheaper or even a BME280 that can also measure humidity. The BME280 is slightly more expensive. I have not been able to test it, but the BMP280 needs a different library and the BME280 needs a different library.
  • Adafruit BMP_085 Library: This is the ‘Old’ library. Adafruit has a newer one that I found less pleasant to work with and I seem to remember it also needed the Adafruit ‘unified sensor’ library. There is a Sparkfun library as well
  • The female and male headers and the piece of veroboard are used to make a breadboard friendly adapter for the ESP8266-01
  • If you dont have a 3.3 Volt USB-TTL adapter yet and are only planning to work with the ESP8266-01, consider this handy device.
  • The OLED is just used to display the values. Ofcourse you may use an LCD as well, or forget about the display and send it off to a website or Thingspeak

esp8266-01-bmp180-circuitThe connections couldn’t be simpler:
I used GPIO0 as SDA and GPIO2 as SCL. The BMP180 and OLED have the pin nominations clearly stamped on them so you only need to connect as follows All Vcc-s together All Grounds together BMP180 and OLED SDA pins to GPIO0 BMP180 and OLED SCL pins to GPIO2 Finally connect the CH_PD pin with Vcc Make sure you identify the proper pins. Your modules may have a pin sequence that differs from mine. As my BMP180 module already had pull up resistors, I didnt need to add those. If your module does not, add 4k7 resistors as pull up on the SDA and SCL lines.

I presume you do know how to program the ESP8266. In short:
Connect Tx<->Rx (meaning the Tx of your ESP to the Rx of your USB-TTL converter)
Connect Rx<->Tx
Connect CH_PD<->Vcc
Connect GPIO0 <->Grnd
Connect Vcc <-> Vcc (Only if you have a 3.3 volt Vcc)
Connect Grnd <-> Grnd

#include <Wire.h>
#include <Adafruit_BMP085.h>
#include "SSD1306.h"
Adafruit_BMP085 bmp;
SSD1306  display(0x3c, 0, 2);

void setup() {
  Wire.pins(0, 2);
  Wire.begin(0, 2);
  if (!bmp.begin()) {
    //   Serial.println("No BMP180 / BMP085");// we dont wait for this
    //   while (1) {}
  display.flipScreenVertically();// I turn the screen coz easier in my setup

void loop() {

  String t = "T=" + String(bmp.readTemperature()) + " *C";
  String p = "P=" + String(bmp.readPressure()) + " Pa";
  String a = "A=" + String(bmp.readAltitude(103000)) + " m";// insert pressure at sea level
  String s= "S="+ String(bmp.readSealevelpressure(30))+" Pa";// or insert your atltitude 
  display.drawString(0, 10, t);
  display.drawString(0, 24, p);
  display.drawString(0, 38, a);
  //display.drawString(0, 38, s);// if you want to calculate sealevelpressure
  // write the buffer to the display

As you can see, one of the parameters is the Altitude. This value is only correct if you supply the program with the pressure at sea level for your location. As that pressure can change, it is not of real value. On the other hand, as the altitude or elevation is much less likely to change (unless you are mobile), you could provide the known elevation for your location and then back calculate the pressure at sea level. Or… given the fact you have a WiFi processor available, read the current pressure at sea level from a web site and then calculate your altitude.

The temperature readings of the BMP180, though precise, still can be off (too high) if the sensor is mounted too close to the ESP8266. Whether this is a result of the HF radio waves or just direct heat of the processor is still being argued. I think it is the latter

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s