Issue getting BME280 Pressure Data

86 views
Skip to first unread message

Troy Roberts

unread,
Jun 22, 2020, 10:16:03 AM6/22/20
to weewx-user
Hello,

I am having some issues getting BME280 pressure data into my weewx data. I am currently capturing data from an Acurite 5n1 using SDR which is running off a raspberry pi 3. The weewx version is 4.1.1 and all my data is uploading with no issue. I wanted to added pressure data so I followed the guide at (https://gitlab.com/wjcarpenter/bme280wx), which led me to (https://pypi.org/project/RPi.bme280/) to get i2c ports up and running. After getting that setup and running the following code, I am able to read all the data from the BME280 sensor.

import smbus2
import bme280

port = 1
address = 0x76
bus = smbus2.SMBus(port)

calibration_params = bme280.load_calibration_params(bus, address)

# the sample method will take a single reading and return a
# compensated_reading object
data = bme280.sample(bus, address, calibration_params)

# the compensated_reading class has the following attributes
print(data.id)
print(data.timestamp)
print(data.temperature)
print(data.pressure)
print(data.humidity)

# there is a handy string representation too
print(data)

With the following output:
pi@raspberrypi:~/Desktop $ python BME280_Test.py
d8bceed7
-07e4-499f-a28e-c29928734eab
2020-06-22 09:55:51.107513
25.5355866359
1016.85232725
46.2092222928
compensated_reading
(id=d8bceed7-07e4-499f-a28e-c29928734eab, timestamp=2020-06-22 09:55:51.107513, temp=25.536 °C, pressure=1016.85 hPa, humidity=46.21 % rH)


After that, I've ran the wee_extension --install command to install bme280wx. I then stop weewx and then started it again and I keep getting the following error:

Jun 22 09:58:36 raspberrypi weewx[455] INFO user.sdr: startup process 'rtl_433 -M utc -F json'
Jun 22 09:58:36 raspberrypi weewxd: bme280: bme280wx configuration {u'temperature_must_have': u'', u'humidityKeys': u'inHumidity', u'pressureKeys': u'pressure', u'pressure_must_have': u'inTemp', u'i2c_port': u'1', u'humidity_must_have': u'', u'i2c_address': u'0x76', u'usUnits': u'US', u'temperatureKeys': u'inTemp'}
Jun 22 09:58:36 raspberrypi weewx[455] INFO user.sdr: shutdown process rtl_433 -M utc -F json
Jun 22 09:58:47 raspberrypi weewx[455] INFO user.sdr: timed out waiting for stderr-thread
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__: Caught unrecoverable exception:
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****  'module' object has no attribute 'load_calibration_params'
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****  Traceback (most recent call last):
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****    File "/usr/share/weewx/weewxd", line 148, in main
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****      engine = weewx.engine.StdEngine(config_dict)
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 75, in __init__
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****      self.loadServices(config_dict)
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 138, in loadServices
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****      obj = weeutil.weeutil.get_object(svc)(self,config_dict)
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****    File "/usr/share/weewx/user/bme280wx.py", line 61, in __init__
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****      self.calibration_params = bme280.load_calibration_params(self.bus, self.address)
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****  AttributeError: 'module' object has no attribute 'load_calibration_params'
Jun 22 09:58:47 raspberrypi weewx[455] CRITICAL __main__:     ****  Exiting.

I'm not sure why this is occurring because I don't get this error running the test code above which calls the 'load_calibration_params' Any ideas?

Thanks,
Troy

rich T

unread,
Jun 22, 2020, 11:46:00 AM6/22/20
to weewx-user
In your weewx.conf file, do you have the following?

##############################################################################

# Options for extension 'bme280wx'
[Bme280wx]
    temperature_must_have = ""
    humidityKeys = inHumidity
    pressureKeys = pressure
    pressure_must_have = outTemp
    i2c_port = 1
    humidity_must_have = ""
    i2c_address = 0x77
    usUnits = US
    temperatureKeys = inTemp

##############################################################################

Troy Roberts

unread,
Jun 22, 2020, 2:30:27 PM6/22/20
to weewx-user
I figured out my issue. The "Import bme280" was pulling the wrong bme280.py file. I renamed the wrong file then stop/start weewx and now all is working.
Reply all
Reply to author
Forward
0 new messages