Jump to content

read bme280 i2c sensor


hryst

Recommended Posts

Hello!
please let me know how to run properly bme280 i2c sensor
I install
https://github.com/adafruit/Adafruit_Python_BME280
but orange pi pi + and banana pi displays bugs:

python bme280.py
Traceback (most recent call last):
  File "bme280.py", line 5, in <module>
    sensor = BME280(mode=BME280_OSAMPLE_8)
  File "/var/www/nettemp/modules/sensors/i2c/BME280/Adafruit_BME280.py", line 90, in __init__
    self._load_calibration()
  File "/var/www/nettemp/modules/sensors/i2c/BME280/Adafruit_BME280.py", line 96, in _load_calibration
    self.dig_T1 = self._device.readU16LE(BME280_REGISTER_DIG_T1)
  File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 185, in readU16LE
  File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 164, in readU16
  File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 173, in read_word_data
IOError: [Errno 70] Communication error on send

Regards

 

Link to comment
Share on other sites

there are many breadboard compatible boards made with BME280 :

 

Most of mine are more complex than yours : https://fr.aliexpress.com/item/GY-BME280-BME280-I2C-SPI-Num-rique-Capteur-Module-Breakout-Temp-rature-Humidit-Pression-Barom-trique/32840435761.html?spm=a2g0w.search0104.3.112.5bANYG&ws_ab_test=searchweb0_0%2Csearchweb201602_5_10152_10065_10151_10344_10068_10345_10342_10343_51102_10340_10341_10609_10541_5130013_5000013_10084_10083_10305_10304_10307_10306_5080013_10302_10610_5870020_10312_10059_10313_10314_10184_10534_100031_10604_10603_10103_10605_5060013_10594_10142_10107%2Csearchweb201603_25%2CppcSwitch_2&algo_expid=4383f9c8-b5ae-48a5-8fd1-e32deb3d9fb9-16&algo_pvid=4383f9c8-b5ae-48a5-8fd1-e32deb3d9fb9&rmStoreLevelAB=5

 

either way, the first after connecting is checking if the BME280 is detected on the bus :

 

root@minus:~# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --

See the 76 here, that means BME280 is detected. Here I checked i2c-1 (you may have to change that depending of how many i2c bus your board have.

 

I don't like most Adafruit libraries (find them hard to read), for BME280 I use this library : https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/bme280.py

Link to comment
Share on other sites

Thanks.

 

I usualy wired my bme280 like you (vdd/GND/SDA/SCK) my version is the same as  vlad59 with SPI, so SDO is to put to to GND or Vdd to choose the @, and I read in the datasheet p31 :

Quote

CSB must be connected to V DDIO to select I2C interface.

 

I do this and after that i can detect the device on the bus, not before.

 

IMG_20171220_150125.thumb.jpg.1853ee9119ff230f04731a638808d79a.jpg

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines