<< Summary

Use the Adafruit BMP180 with a Raspberry PI, in Java Raspberry PI
Pressure and Altitude, Temperature

The board we are talking about here is the Barometric Pressure/Temperature/Altitude Sensor - 5V ready.

It has an I2C (pronounce I "square" C) interface, that needs to be enabled on the Raspberry PI.
I2C stands for Inter-Integrated-Circuit.
Arduino & Adafruit provide python libraries that go along with their components. The code we present here is in big part an adaptation of this code.

Enable I2C on the Raspberry PI

This step is already described in another document.
Once this is done, and the board wired, i2cdetect should produce an output like this:

  Prompt> sudo i2cdetect -y 1
       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  00:          -- -- -- -- -- -- -- -- -- -- -- -- --
  10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  70: -- -- -- -- -- -- -- 77
      
Notice the rendered address, 0x77.

Wiring

BMP180Raspberry PI
Vin2. 5.0 VDC Power
GND6. 0V (Ground)
SDA3. SDA0 (I2C)
SCL5. SCL0 (I2C)
Raspberry PI P1 Connector map Click to enlarge

Running

The class to run is I2C.SPI.AdafruitBMP180. Run it from a script like this:

 #!/bin/bash
 PI4J_HOME=/home/pi/pi4j/pi4j-distribution/target/distro-contents
 CP=./classes
 CP=$CP:$PI4J_HOME/lib/pi4j-core.jar
 sudo java -cp $CP adafruiti2c.AdafruitBMP180
      
The output would look like this:

 Temperature: 22.50 C
 Pressure   : 1019.32 hPa
 Altitude   : 00.50 m
      

And what next?

Driving the Raspberry PI, on its own cart...


Oliv did it