### Sensor Barometic Pressure

B4J Raspberry Pi Experiment - BMP180 Barometic Pressure.
Get, in regular intervals the Barometic Pressure (Pascal), Temperature (Deg C) and Altitude (m) from a BMP180 I2C sensor.
The BMP I2C sensor has default address of 0x77 - checkout with sudo i2cdetect.
Parts Needed
• 1x Raspberry Pi
• 1x BMP180
• 1x GPIO Extension Board with GPIO cable, Breadboard, several jumper wires
Wiring
BMP-180 = Raspberry Pi
3.3v = 3.3v
SDA = SDA (Physical Pin#3)
SCL = SCL (Physical Pin#5)
GND = GND
Description
Connecting the Parts
The RasPi GPIO is connected via the GPIO Extension Board (T-Cobbler) and GPIO cable to a breadboard.
On the Breadboard, connect the BMP180 according the wiring scheme.
Developing the B4J non-UI program
The B4J non-UI program uses the B4J Library jBMP180.
Dependencies: the jPi4J Library (see category Raspberry Pi Libraries > jPi4J).
The B4J pseudo code:
• Init the BMP180 device in standard operating mode
• Init the timer and start
• Start the message loop
• Log the Barometic Pressure (Pascal), Temperature (Deg C) and Altitude (m)
Running the Experiment
On the RasPi start the B4J-Bridge by login on as user Pi, open a terminal, go to folder /home/pi/b4j and run sudo java -jar b4-bridge.jar, note the MyIp address.
Open the B4J IDE and load the B4J project file, connect to the B4J-Bridge (Menu Tools > B4J Bridge > Connect > Enter IP address.
Run the application from the B4J IDE by pressing F5.
Download Source Code
Documentation on request.
Additional Libraries
jPi4J, jBMP180
Published External
No
ToDo
• Experiment is completed.
Version
20170301
B4J non-UI Example Code
`Sub Process_Globals
Private CAPPVERSION As String = "Raspberry Pi Experiment - BMP180 Temperature, Pressure, Altitude v20170302"
' Define the BMP 180 device. The I2C address used is 0x77 - check out with sudo i2cdetect
Private bmp As BMP180
'Define the request timer and interval
Private RequestTimer As Timer
Private RequestInterval As Long = 5000
End Sub`
`Sub AppStart (Args() As String)
Log(CAPPVERSION)
' Init the bmp180 device
bmp.Initialize(1)
Log("BMP180 Initialized")
'Init and start the request timer
RequestTimer.Initialize("RequestTimer", RequestInterval)
RequestTimer.Enabled = True
Log("Timer started")
'Do not forget
StartMessageLoop
End Sub`
'Handle timer
`Sub RequestTimer_Tick
Log($"${DateTime.Time(DateTime.Now)}"$)
Log($"T=${NumberFormat(bmp.ReadTemperature,0,2)}"$)
Log($"P=${NumberFormat(bmp.ReadPressure / 100,0,1)}"$)
Log($"A=${NumberFormat(bmp.ReadAltitude,0,1)}"$)
End Sub`

Changed: 2018-06-07 09:21, Category: Raspberry Pi Sample Projects, File: T6C238M1746.htm, ID: 1746