We do not take any responsibility for possible errors in the guide or errors that you might do wiring it up. Incorrect wiring can result in damaged sensor or damaged Raspberry Pi.
This sensor can act as Barometer and it also measures temperature.
Main parameters from the sensors Data sheet:
This sensor is really small even the full brake-outboard is only size of a fingernail. The board does not come with the header pins soldered on, but with mine the header pins came with it at least so I just had to solder them on.
Pieces we use in this guide:
I2C Tools
To install the I2CTools you use the following command:
sudo apt-get install i2c-tools
You need to enable the i2c bus in the Raspberry PI settings, which you can do in the Raspberry Pi user interface.
Wiring up the board:
First we solder the header pins into the brake-out board as shown bellow. It was possible on mine to either solder the pins on front or back.
Once the board has been soldered with header pins or wires then we are ready to wire up the sensor which we do as follows:
BMP180 | Raspberry PI cobbler |
---|---|
VIN | 3.3 V |
GND | GND |
SCL | SCL (Physical pin 5) |
SDA | SDA (Physical pin 3) |
If you need more information about the GPIO headers on Raspberry Pi or other boards then click bellow.
Raspberry Pi Pin guideOrange Pi One Pin guideOrange Pi Pin guide for most H3 modelsOrange Pi Zero 3 Pin guideOrange Pi 5 Plus Pin guideRock 64 Pin guideSanity tests in console:
After you have connected everything and made sure that wiringPI, i2ctools are installed that I2C is enabled in the Raspberry PI settings, then we are ready to do sanity tests in console, or you can run the I2C example project that comes with the I2C Plugin.
If doing it in console then you would issue command like this:
sudo i2cdetect -y 1
This should show our device at 0x77. Or if you use the example project that comes with the I2C plugin then you click Get adapters and then select the adapter and then click Scan the selected adapter this should get you 119, which converted to Hex is 0x77, same as the i2cdetect returns.
The example project that comes with the I2C Plugin, which can help you scan for the device address.If you can see your sensor on address 0x77 (or 119 dec) then you are ready to start coding.
The Xojo code:
Coding against this sensor is somewhat complicated but I have made it really simple as I created a Xojo class called BMP180 (see download
link at bottom) that does all the hard work. Using the class is as very easy:
Getting the chip id to verify everything is all right:
Sub Pressed() Handles Pressed
#if TargetARM and TargetLinux
try
// We want adapter 1 and device 0x77
var bmp as new BMP180(1, &h77)
MessageBox("0x" + Hex(bmp.GetChipID()))
catch ex as I2CException
MessageBox("Error: " + ex.Message)
end try
#endif
End Sub
Read temperature:
Sub Pressed() Handles Pressed
#if TargetARM and TargetLinux
try
// We want adapter 1 and device 0x77
var bmp as new BMP180(1, &h77)
MessageBox(Format(bmp.ReadTemperature(),"#.0") + "° C")
catch ex as I2CException
MessageBox("Error: " + ex.Message)
end try
#endif
End Sub
Read pressure:
Sub Pressed() Handles Pressed
#if TargetARM and TargetLinux
try
// We want adapter 1 and device 0x77
var bmp as new BMP180(1, &h77)
MessageBox(Format(bmp.ReadPressure(BMP180.Mode.STANDARD),"#.0"))
catch ex as I2CException
MessageBox("Error: " + ex.Message)
end try
#endif
End Sub
Read pressure at sea level:
Sub Pressed() Handles Pressed
var heightOverSeaLevel as Single = Val(tbHeightOverSeaLevel.Text)
#if TargetARM and TargetLinux
try
// We want adapter 1 and device 0x77
var bmp as new BMP180(1, &h77)
MessageBox(Format(bmp.ReadPressureAtSeaLevel(BMP180.Mode.ULTRALOWPOWER,heightOverSeaLevel),"#.0"))
catch ex as I2CException
MessageBox("Error: " + ex.Message)
end try
#endif
End Sub
To get your current height above sea level then you can for example use this page here: WhatsMyElevation
When testing the example then I found I was 118 meter above sea level which I used to calculate pressure at sea level.
You can find this example code at Example code for GPIO guides.
I got this also to work on H3 based Orange Pi running Armbian.
To get things to work on H3 based Orange Pi I had to: