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

**URL:** <https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960>\
**Category:** Support\
**Created:** [February 6, 2020, 11:34am UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960 "2020-02-06T11:34:49Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [February 6, 2020, 11:34am UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/1 "2020-02-06T11:34:50Z")

</div>

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? :)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [February 6, 2020, 11:58am UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/2 "2020-02-06T11:58:33Z")

</div>

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

```auto
import bme680

sensor = bme680.BME680()

sensor.set_humidity_oversample(bme680.OS_2X)
sensor.set_pressure_oversample(bme680.OS_4X)
sensor.set_temperature_oversample(bme680.OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3)

sensor.set_gas_status(bme680.DISABLE_GAS_MEAS)
#sensor.set_gas_heater_temperature(320)
#sensor.set_gas_heater_duration(150)
#sensor.select_gas_heater_profile(0)

```

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

```auto
if sensor.get_sensor_data(): 
        t = sensor.data.temperature 
        t = round(t)

```

---

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [February 6, 2020, 12:08pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/3 "2020-02-06T12:08:32Z")

</div>

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 :

```python
import time, datetime
import bme680

''' Calibration and initial reading '''
try:
    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.
sensor.set_humidity_oversample(bme680.OS_2X)
sensor.set_pressure_oversample(bme680.OS_4X)
sensor.set_temperature_oversample(bme680.OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3)
sensor.set_gas_status(bme680.ENABLE_GAS_MEAS)

sensor.set_gas_heater_temperature(320)
sensor.set_gas_heater_duration(150)
sensor.select_gas_heater_profile(0)

```

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [February 6, 2020, 12:31pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/4 "2020-02-06T12:31:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [February 6, 2020, 12:34pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/5 "2020-02-06T12:34:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nophead](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nophead/32/5827_2.png) [@nophead](https://forums.pimoroni.com/u/nophead)\
**Post date:** [February 6, 2020, 12:46pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/6 "2020-02-06T12:46:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [February 6, 2020, 1:09pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/7 "2020-02-06T13:09:28Z")

</div>

Currently, it looks like that:

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

```

---

<div class="post-metadata">

**Author:** ![nophead](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nophead/32/5827_2.png) [@nophead](https://forums.pimoroni.com/u/nophead)\
**Post date:** [February 6, 2020, 1:23pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/8 "2020-02-06T13:23:35Z")

</div>

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?

```auto
sensor = bme680;

```

---

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [February 6, 2020, 1:35pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/9 "2020-02-06T13:35:44Z")

</div>

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’.

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [February 6, 2020, 1:51pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/10 "2020-02-06T13:51:40Z")

</div>

Just to confirm, the Pimoroni example files run fine?  
And its a BME680 not a BMP680?  
And lastly, you installed the software via  
`curl https://get.pimoroni.com/bme680 | bash`

---

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [February 6, 2020, 1:56pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/11 "2020-02-06T13:56:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nophead](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/nophead/32/5827_2.png) [@nophead](https://forums.pimoroni.com/u/nophead)\
**Post date:** [February 6, 2020, 1:58pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/12 "2020-02-06T13:58:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [February 6, 2020, 2:05pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/13 "2020-02-06T14:05:05Z")

</div>

If you want, you can check my actual code (unfinished but should work): [https://github.com/melvinmajor/tfe-PiSense/blob/bme680/sensors/bme680/bme680.py](https://github.com/melvinmajor/tfe-PiSense/blob/bme680/sensors/bme680/bme680.py)

Not other assignment before.

---

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [February 10, 2020, 12:17am UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/14 "2020-02-10T00:17:06Z")

</div>

Hi all,

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

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,

Melvin.

---

<div class="post-metadata">

**Author:** ![sadiq](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@sadiq](https://forums.pimoroni.com/u/sadiq)\
**Post date:** [October 20, 2020, 2:37am UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/15 "2020-10-20T02:37:15Z")

</div>

Dear Melvinmajor: can you elaborate what you mean by python file from bme680.py to bme680sensor.py  
I am not able to understand that which why I still stuck with this problem. I get exactly the same error as you did. Your help will be appreciated

---

<div class="post-metadata">

**Author:** ![melvinmajor](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@melvinmajor](https://forums.pimoroni.com/u/melvinmajor)\
**Post date:** [October 20, 2020, 6:08am UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/16 "2020-10-20T06:08:11Z")

</div>

Hi Sadiq,

Simply rename your file in order to not have the same name as the library.  
Python will then understand that import bme680 is the actual module from Pimoroni and not your code.

Kind regards,

Melvin.

---

<div class="post-metadata">

**Author:** ![sadiq](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@sadiq](https://forums.pimoroni.com/u/sadiq)\
**Post date:** [October 20, 2020, 2:43pm UTC](https://forums.pimoroni.com/t/bme680-module-bme680-has-no-attribute-bme680/12960/17 "2020-10-20T14:43:34Z")

</div>

Hey Thank you for the quick response. Did that before but I didnt realize that there as another file with the same name that was causing the error. Thanks a lot!
