BMP085/BMP180 digital pressure sensor

This is a small module that makes it easy to connect to a BMP085 or BMP180 digital barometric pressure sensor using I2C. Use the BMP085 (About Modules) module for it.

You can wire this up as follows:

Device Pin Espruino
1 (GND) GND
2 (VCC) (or Vin on Adafruit modules) 3.3
3 (SDA) B7
4 (SCL) B6

Note: On Adafruit modules the 3Vo pin is the output of the voltage regulator and can be left disconnected

How to use the module:

I2C1.setup({scl:B6,sda:B7});
var bmp = require("BMP085").connect(I2C1);
setInterval(function() {
  bmp.getPressure(function(d) {
    console.log("Pressure: " + d.pressure + " Pa");
    console.log("Temperature: " + d.temperature + " C");
  });
}, 1000);

Besides the I2C connection, connect() takes an optional mode argument to set the sensitivity:

I2C1.setup({scl:B6,sda:B7});
var bmp = require("BMP085").connect(I2C1, 0); // mode is a number from 0-3

List of modes are:

Mode Name Conversion time >=
0 BMP085_MODE_ULTRALOWPOWER 10 ms
1 BMP085_MODE_STANDARD 13 ms
2 BMP085_MODE_HIGHRES 19 ms
3 BMP085_MODE_ULTRAHIGHRES 31 ms

Default mode is 2. If you need to set the mode after loading the module set the bmp.oss variable.

Altitude and sea level pressure:

var sealevel = 99867; // current sea level pressure in Pa

I2C1.setup({scl:B6,sda:B7});
var bmp = require("BMP085").connect(I2C1);
bmp.getPressure(function(d) {
    var altitude = bmp.getAltitude(d.pressure, sealevel);
    console.log("Altitude: " + altitude + " m");
});
var altitude = 587; // current altitude in m

I2C1.setup({scl:B6,sda:B7});
var bmp = require("BMP085").connect(I2C1);
bmp.getPressure(function(d) {
    var sealevel = bmp.getSeaLevel(d.pressure, altitude);
    console.log("Sea level pressure: " + sealevel + " Pa");
});

Buying

BMP085/BMP180 sensors can be purchased from many places:

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.