Friday, 19 September 2014

Banana Pi: I2C Barometric Sensor BMP085


Wiring

---> 3.3 volts - to vcc on board
---> ground - to gnd on board
---> SDA - to sda on board
---> SLC - to scl on board


Banana Pi - I2C Barometer BMP085
Wiring, BMP085

Locating the sensor

root@lemaker:~# ls -l /dev/i2c*
crw-rw---T 1 root i2c 89, 0 Sep 19 14:43 /dev/i2c-0
crw-rw---T 1 root i2c 89, 1 Sep 19 14:43 /dev/i2c-1
crw-rw---T 1 root i2c 89, 2 Sep 19 14:43 /dev/i2c-2
crw-rw---T 1 root i2c 89, 3 Sep 19 14:43 /dev/i2c-3
crw-rw---T 1 root i2c 89, 4 Sep 19 14:43 /dev/i2c-4
As you can see there are 5 I2C buses. With the i2cdetect tool we are looking for the 0x77 address, which is the BMP085.
# -y 0, -y 1 etc
sudo i2cdetect -y 2
We are using the  Adafruit BMP Python Library to access the sensor.
sudo apt-get install git build-essential python-dev python-smbus
git clone https://github.com/adafruit/Adafruit_Python_BMP.git
cd Adafruit_Python_BMP
sudo python setup.py install
There are some example scripts in the examples folder.
cd examples

# we need to change the bus number
nano simpletest.py
#uncomment sensor = BMP085.BMP085(busnum=2)
#and comment #sensor = BMP085.BMP085()

#run code
sudo python simpletest.py

#sample output
Temp = 23.00 *C
Pressure = 97607.00 Pa
Altitude = 313.47 m
Sealevel Pressure = 97607.00 Pa

0 comments:

Post a Comment