Uncategorized

BMP180/280 Pressure Sensor Notes

Asked 
Active today
Viewed 49 times
0

im currently working on a Barometer sensor on my Raspberry Pi 3. Unfortunately its not really working. My BMP180 Sensor is wired up as following:

VIN -> 3V3 (1)
GND -> GND (9)
SCL -> GPIO3 (5)
SDA -> GPIO2 (3)

The cables and connections were double checked and replaced a few times so those are not the problem. I also enabled I2C in raspi-config. If I type in i2cdetect -y 1 i get something like this, so no connections are detected:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --    

If I let an example/test code from Adafruit run when everything is connected properly and checked (~/BMP180Code/Adafruit_Python_BMP/examplessimpletest.py) I get an output like that:

Traceback (most recent call last):
    File "simpletest.py", line 37, in <module>
        sensor = BMP085.BMP085()
    File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 69, in __init__
    File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 72, in _load_calibration
    File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 202, in readS16BE
    File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 179, in readS16
    File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 166, in readU16
    File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 187, in read_word_data
IOError: [Errno 110] Connection timed out

I looked up a few solutions online, but nothing helped. I would be happy if someone of you has a solution for that. Thanks and have a good day, Leo

 New contributor

3 Answers

0

Answer (v0.3 Last update 2020feb19hkt1501)

Let me see. I assume you are using the following outdated python program. Please let me know otherwise.

(1) Adafruit /Adafruit_Python_BMP Archived (2014)

I found that following comments in lines 27~40 useful for debugging:

# For the Raspberry Pi this means you should hook up to the only exposed I2C bus
# from the main GPIO header and the library will figure out the bus number based
# on the Pi's revision.
# Optionally you can override the bus number:
# sensor = BMP085.BMP085(busnum=2)

Comments

(1) Old Rpi (2014) might use I2C0 instead of I2C1, the auto detect funtion might not be able to know Rpi3/4 and pick the wrong number not 1, but 0 or 2 (2 for BeagleBone perhaps)

(2) The python program is for BMP085 but you are using BMP180. You might like to check out any imcompatibilities and make necessary modifcations to the config functions.

(3) The error message is

"File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 187, in read_word_data, IOError: [Errno 110] Connection timed out"

Your “i2cdetec -y 1” shows no I2C device is detected, it may mean

(a) Hardware wiring is not correct (OK, so your have double checked wiring (open/short all point to point, neighbouring points etc) or

(b) Software problem such as (i) Wrong config, (ii) Wrong software library.

Either way, you might get the above “Time out, cannot connect” error message.


Troubleshooting Suggestions

(1) You may like to try and error modify the relevant bus number in the program, say

change default I2C bus number from 2 to 1.

(2) To make sure the hardware wiring, and software drivers etc are OK, (a) Remove the no detect BMP guy, (b) swap in any other I2C guy and “i2cdetect – y 1” again. If the new guy can be happily detected, then obviously the old guy is bad 😦


Discussion and Recommendation

The AdaFruit BMP180 Library the OP uses is depreciated and no longer supported.

I would suggest the OP to switch to

AdaFruit BMP280 CircuitPython Library

or

Pimoroni BMP280 Python Library

.


References

(1) Adafruit_2014 BMP085/BMP180 Python Library (Depreciated, No Longer Supported)

(2) BMP085 Datashet v2.5- Bosch 2009

(3) BMP180 Datasheet – Bosch 2009

(4) BMP280 Digital Pressure Sensor Datasheet v1.14 Bosch 2015

(5) UM10204 I2C-bus specification and user manual (referred in BMP180 Datasheet Section 5, Max clock = 3.4MHz) – 2014 NXP

(6) Adafruit BMP280 I2C or SPI Barometric Pressure & Altitude Sensor – US$10

(7) BMP280 Temperature, Pressure, & Altitude Sensor Python Library – Pimoroni 2019nov08

(8) BMP280 Pip Install – PyPi


Appendices

Appendix A – I2C wiring and Pull up resistors etc

(1) You should be using the only two I2C Clock and Data pins in the Rpi 40 pin header.

(2) The the two pins already have strong enough 1k8 pull up. There is no need to add more pull up resistor, with the risk of too strong pull up.

(3) Actually if you are putting two many I2C devices, say, more than 4, on the same bus, and the other devices have 4k7 or 10k pullups, the resultant pull up might be much less than 1k8, and overload the I2C pin current. I usually REMOVE those on device pullups to not to overload the Rpi I2C pins.

(4) Remove all other I2C devices on the same bus, for reason (3) above.

(5) Your hardware I2C connection wires CANNOT be too long, preferably less than 30cm. Longer than that might result in too high impedance (For I2C, 400pf is the usual limit).


Appendix B – Difference between BMP085 and BMP180

I skim both datasheets to compare and contrast. My quick and dirty conclusion: (a) BMP180 is successor of BMP085, (b) They are functionally the same, meaning that software programming should be the “same”.

Usually industry practice is that new hardware version is backward compatible, ie, BMP085 program can run for BMP180, but not vice versa. WARNING: I am just a friendly hobbyist. No guarantee No nothing won’t melt down or blow up! Follow the hobbyist’s suggestion at your own risk! 🙂


Appendix D – Suggestion to modify AdaFruit BMP180 Program for Rpi3/4

The main test program is actually very short.

The critical setup problem is the I2C bus number.

The program’s default is I2C Bus #2. I would suggest to change default to I2c Bus #1.

# AdaFruit BMP180 Program Author: Tony DiCola 
# https://github.com/adafruit/Adafruit_Python_BMP/blob/master/examples/simpletest.py
import Adafruit_BMP.BMP085 as BMP085
# Default constructor will pick a default I2C bus.
# For the Raspberry Pi this means you should hook up to the only exposed I2C bus
# from the main GPIO header and the library will figure out the bus number based
# on the Pi's revision.
sensor = BMP085.BMP085()
# Optionally you can override the bus number:
# sensor = BMP085.BMP085(busnum=2)  
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()))

Next is to update the class bmp085. See next Appendix E below.


Appendix E – AdaFruit BMP085 Library bmp085 Class using Eazy Steup – Tony DiCola for Adafruit

The following notice from the AdaFruit BMP085 library says the library is depreciated. AdaFruit recommends:

(a) switch to circuitpython sensor libraries in python,

(b) Switch to BMP280.

Now we have a problem. This old library uses AdaFruit EazySetup which is not longer supported and might be incoompatible to Rpi3/4.

DEPRECATED LIBRARY Adafruit Python BMP This library has been deprecated!
https://github.com/adafruit/Adafruit_Python_BMP/blob/master/README.md
the bmp085 and bmp180 are no longer made, and are replaced by the bmp280
we are now only using our circuitpython sensor libraries in python
we are leaving the code up for historical/research purposes but archiving the repository.
check out this guide for using the bmp280 with python! https://learn.adafruit.com/adafruit-bmp280-barometric-pressure-plus-temperature-sensor-breakout
Adafruit Python BMP
Python library for accessing the BMP series pressure and temperature sensors like the BMP085/BMP180 on a Raspberry Pi or Beaglebone Black.
Designed specifically to work with the Adafruit BMP085/BMP180 pressure sensors ----> https://www.adafruit.com/products/1603
To install, download the library by clicking the download zip link to the right and unzip the archive somewhere on your Raspberry Pi or Beaglebone Black. Then execute the following command in the directory of the library:~~
sudo python setup.py install
Make sure you have internet access on the device so it can download the required dependencies.

End of answer

 

0

First, if you are using Raspberrian with GUI you need to enable i2c interface on raspberry: Pi Start Menu > Preferences > Raspberry Pi Configuration and in Interface tab turn on I2C. Or if you are using terminal just: sudo raspi-config -> Interfacing Options -> I2C

My second suggestion is to check wiring once again. I2C uses open drain connection on SDL and SCL pins. As far as I know sparkfun BMP180 sensors has build in pullup resistors to hold voltage on lines. Check if you model has pull up resistors. If not you have to put in circuit some resistors.

 

  • I already had the I2C Interface enabled. I tried to add a 1k resistor but it didnt work – Leo Fleischmann 17 hours ago
  • Maybe sensor is dead. If you have another i2c device you could check if you see it. – GoRo3 29 mins ago

0

You can check this below link how to enable I2C Raspberry

Link

 

  • Thx but I already did that and it didnt help – Leo Fleischmann 17 hours ago
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – From Review – Simas Joneliunas 1 hour ago
  • @Simas Joneliunas, thanks for your help i’ll do – Mohsen 50 mins ago

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: