B4J Library [Raspberry Pi] jBMP180 - Barometric Pressure/Temperature/Altitude Sensor

Library for the BMP-180 Barometric Pressure/Temperature/Altitude Sensor connected to a Raspberry Pi.

The library is wrapped from this > BMP-180 Pressure Sensor project.

Install
Copy jbmp180.jar,xml and bmp.jar to the B4J additional libraries folder.

Dependencies
On jPi4J and the pi4j jar files (core, device, gpio-extension, service) - ensure these are located in the B4J additional libraries folder.

Wiring
B4X:
BMP-180 = Raspberry Pi
3.3v = 3.3v
SDA = SDA (Physical Pin#3)
SCL = SCL (Physical Pin#5)
GND = GND

Example B4J Non-UI Program
B4X:
Sub Process_Globals
   'Define the BMP 180 device with default I2C address 0x77 - check out with sudo i2cdetect
   Private bmp As BMP180
   'Define the request timer and interval 5 secs
   Private RequestTimer As Timer
   Private RequestInterval As Long = 5000
End Sub

Sub AppStart (Args() As String)
   bmp.Initialize(1)  'use standard operating mode
   RequestTimer.Initialize("RequestTimer", RequestInterval)
   RequestTimer.Enabled = True
   StartMessageLoop
End Sub

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

Output
12:52:57
T=18.3
P=1,001.5
A=99.4
12:53:02
T=18.3
P=1,001.4
A=99

ChangeLog
20170302 v1.0
 

Attachments

  • jBMP180.zip
    7.5 KB · Views: 389
Top