https://github.com/xtacocorex/Adafruit_Python_GPIO
https://github.com/adafruit/Adafruit_Python_BMP
I was using multiple samples but still following errors were occuring:
I was using multiple samples but still following errors were occuring:
pi@raspberrypi:~/pi $ python BMP180.py
Traceback (most recent call last):
File "BMP180.py", line 3, in <module>
sensor = BMP085.BMP085(busnum=2)
File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 67, in __init__
File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 65, in get_i2c_device
File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 98, in __init__
File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 97, in __init__
File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 122, in open
IOError: [Errno 2] No such file or directory: '/dev/i2c-2'
Or:
Traceback (most recent call last):
File "B180.py", line 24, in <module>
print('Pressure = {0:0.2f} Pa'.format(sensor.read_pressure()))
File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 152, in read_pressure
File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 129, in read_raw_pressure
File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 149, in readU8
File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 155, in read_byte_data
Or this:
pi@raspberrypi:~/pi $ python bMP180.py
File "B180.py", line 24, in <module>
print('Pressure = {0:0.2f} Pa'.format(sensor.read_pressure()))
File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 152, in read_pressure
File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 129, in read_raw_pressure
File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 149, in readU8
File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 155, in read_byte_data
Or this:
pi@raspberrypi:~/pi $ python bMP180.py
Traceback (most recent call last):
File "bMP180.py", line 1, in <module>
from tentacle_pi.BMP180 import BMP180
ImportError: /usr/local/lib/python2.7/dist-packages/tentacle_pi/BMP180.so: undefined symbol: i2c_smbus_write_byte_data
I finally figured out that in sensor definition brackets were required. So below code is working now.
import Adafruit_BMP.BMP085 as BMP085
sensor = BMP085.BMP085()
print('Temp = {0:0.2f} *C'.format(sensor.read_temperature()))
print('Pressure = {0:0.2f} Pa'.format(sensor.read_pressure()))
print('Altitude = {0:0.2f} m'.format(sensor.read_altitude()))
print('Sealevel Pressure = {0:0.2f} Pa'.format(sensor.read_sealevel_pressure()))
Adding brackets fixed code of every other sample that I used before.
No comments:
Post a Comment