Coder Social home page Coder Social logo

Comments (2)

othy1010 avatar othy1010 commented on July 19, 2024

Hi there,

Started playing with bme280 - I can't initialise it correctly on my RPI + Breakout Garden + BME280 (and a few others breakout)

#!/usr/bin/env python3

# std lib imports
import os
import logging
import argparse
import sys
import time

# extra imports
try:
    from smbus2 import SMBus
except ImportError:
    from smbus import SMBus

from bme280 import BME280

# Set logs
logger = logging.getLogger('bme280')
logger.setLevel(logging.INFO)
# Log format
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Console Handler
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
ch.setFormatter(formatter)
logger.addHandler(ch)


def temperature():
    # Initialise the BME280
    bus = SMBus(1)
    bme280 = BME280(i2c_dev=bus)

    temperature = bme280.get_temperature()
    pressure = bme280.get_pressure()
    humidity = bme280.get_humidity()
    print('{:05.2f}*C {:05.2f}hPa {:05.2f}%'.format(temperature, pressure, humidity))
    time.sleep(1)

def main():
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('--url', default="http://localhost", help="url")
    args = parser.parse_args()
    """

    temperature()

if __name__ == "__main__":
    main()

Leads to:

Traceback (most recent call last):
  File "/home/pi/airborne/airborne/environment.py", line 52, in <module>
    main()
  File "/home/pi/airborne/airborne/environment.py", line 49, in main
    temperature()
  File "/home/pi/airborne/airborne/environment.py", line 36, in temperature
    temperature = bme280.get_temperature()
  File "/home/pi/.local/lib/python3.9/site-packages/bme280/__init__.py", line 264, in get_temperature
    self.update_sensor()
  File "/home/pi/.local/lib/python3.9/site-packages/bme280/__init__.py", line 250, in update_sensor
    self.setup()
  File "/home/pi/.local/lib/python3.9/site-packages/bme280/__init__.py", line 228, in setup
    raise RuntimeError("Unable to find bme280 on 0x{:02x}, CHIP_ID returned {:02x}".format(self._i2c_addr, chip.id))
RuntimeError: Unable to find bme280 on 0x76, CHIP_ID returned 58

whereas it's on 0X76:

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

Any changes on the chip that should be updated in the lib ?

Thanks

hello, did you solve this problem I'm facing the same thing, Thanks

from bme280-python.

Gadgetoid avatar Gadgetoid commented on July 19, 2024

Chip ID 0x58 is for a BMP280 not a BME280, this library is not compatible with that device.

You'll need: https://github.com/pimoroni/bmp280-python

from bme280-python.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.