BME680 : "module 'bme680' has no attribute 'BME680'"

Hi all,

First of all, let me introduce :
I’m quite new on Pimoroni forums, currently ending my IT studies and use Python for my graduation work with several sensors on a Raspberry Pi 4 2GB which will send everything in JSON format to a server which will store and create graphs from it.

For my graduation work, I wanted to use the BME680 from Pimoroni along with other sensors.
No problem with the others but with the BME680, I’m actually facing a little problem.
Whenever I launch my code, it states for an attribute error (module ‘bme680’ has no attribute ‘BME680’) even though it’s the exact same part of code from the given example code.

I really don’t understand why the example code works fine but mine is stuck at:

sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)

I also tried by not stating the address like the “Getting Started with BME680 Breakout” indicates but like I was thinking about the problem, it doesn’t change anything.

sensor = bme680.BME680()

Maybe someone can help me solve this? :)

What I’m currently using in my code is as follows

import bme680

sensor = bme680.BME680()



And then in my while true loop I use stuff like this for temperature.

if sensor.get_sensor_data(): 
        t = 
        t = round(t)

Really strange, you’re calling the sensor like I did and it doesn’t work in my code :/

EDIT : Here’s part of my code :

import time, datetime
import bme680

''' Calibration and initial reading '''
    sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
except IOError:
    sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)

# These calibration data can safely be commented out, if desired.
print('Calibration data:')
for name in dir(sensor.calibration_data):
    if not name.startswith('_'):
        value = getattr(sensor.calibration_data, name)
        if isinstance(value, int):
            print('{}: {}'.format(name, value))

# These oversampling settings can be tweaked to
# change the balance between accuracy and noise in
# the data.


If you only have the one BME680, and haven’t changed its i2c address via the jumper, as far as I know you don’t need all that I2C_ADDR_PRIMARY I2C_ADDR_SECONDARY stuff. Try remarking it out.
I don’t know if its an issue, but its what I would do. I don’t use it in my code with my one stock BME680.
Something else to keep in mind, no two i2c devices can have the same i2c address. If they do they won’t work. This crops up from time to time when somebody tests multiple sensors one at a time and they work, but fail when they wire them all up at once.

Thanks for your feedback.
I removed the I2C_ADDR_PRIMARY and SECONDARY stuff, not any change.

The given example code from Pimoroni is still working great but not my code. Still the issue of AttributeError.

What does your import statement for the bme680 module look like?

Currently, it looks like that:

import time, datetime
import bme680
import json
import sys
import logging, logging.handlers
import argparse

I think maybe you are using an old version of the bme680 library. I know the ltr559 library went through a transition from a module of functions to a class with constructor. Perhaps the bme680 library has done the same.

What happens if you just use this?

sensor = bme680;

With sensor = bme680;, I have an other AttributeError.
It states :

module ‘bme680’ has no attribute ‘calibration_data’

You can check on my older reply here with part of my code that I use it to calibrate data.
If I set this part in comment, it states that there is no attribute ‘set_humidity_oversample’.

Just to confirm, the Pimoroni example files run fine?
And its a BME680 not a BMP680?
And lastly, you installed the software via
curl | bash

Yes, the Pimoroni example file run fine.
The sensor is the officiel Pimoroni BME680 (I ordered it on the shop part of Pimoroni website).
Yes. I retried and it states that all requirements are present, all dependencies are up-to-date.

Are you sure there are no other assignments to bme680 after the import before you use it?

If you want, you can check my actual code (unfinished but should work):

Not other assignment before.

Hi all,

Just to let you know I’ve found the problem: I simply had to rename the python file from to

The problem was that the old name was makeing troubles with the calling of the Pimoroni module. I now understand why Adafruit are naming their modules as “adafruit-circuitpython-xxx” :P

Thanks for your help and advices,