Trouble setting up Grove BME280 on weewx 4.5.1 RPi

632 views
Skip to first unread message

Elie R

unread,
Jul 17, 2021, 4:38:02 PM7/17/21
to weewx-user
Long time weewx user, had been running on a RPi3b with an AcuRite 5-in-1. Currently, I'm trying to upgrade to an AcuRite Atlas w/ lightning sensor & SDR & BME280 running weewx 4.5.1, also on a RPi3b.

weewx is running fine with Belchertown skin, SDR is working fine (except trouble getting lightning to show up in reports). But for the life of me, I can't get BME280 working with weewx. I have a Grove BME280 module.

I can see the module in i2c: port 1 0x76. I can run a bme280 test which outputs:
Chip ID     : 96
Version     : 0
Temperature :  22.77 C
Pressure :  1014.92710409 hPa
Humidity :  49.1006560524 %

but dmesg is giving me:
pi@raspberrypi:/home $ dmesg | grep i2c
[    5.337895] i2c /dev entries driver
[    8.005092] i2c i2c-11: Added multiplexed i2c bus 12
[ 1354.600579] i2c i2c-11: Added multiplexed i2c bus 12
[ 5559.721893] i2c i2c-11: Added multiplexed i2c bus 12
[ 5826.137473] i2c i2c-11: Added multiplexed i2c bus 12
[ 9343.684685] i2c i2c-11: Added multiplexed i2c bus 12
[15604.355447] i2c i2c-11: Added multiplexed i2c bus 12
[15635.005391] i2c i2c-11: Added multiplexed i2c bus 12
[16065.782200] i2c i2c-11: Added multiplexed i2c bus 12
[18043.017208] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /soc/i2c@7e804000/status

My weewx.conf:

[SDR]
    # This section is for the software-defined radio driver.

    # The driver to use
    driver = user.sdr
    log_unknown_sensors = True
    log_unmapped_sensors = True

    cmd = rtl_433 -M utc -F json
    path = /usr/local/bin
    ld_library_path = /usr/local/lib

    [[sensor_map]]
        outTemp = temperature.0039.AcuriteAtlasPacket
        outHumidity = humidity.0039.AcuriteAtlasPacket
        windSpeed = wind_speed.0039.AcuriteAtlasPacket
        windDir = wind_dir.0039.AcuriteAtlasPacket
        UV = uv.0039.AcuriteAtlasPacket
        rain_total = rain_total.0039.AcuriteAtlasPacket
        radiation = lux.0039.AcuriteAtlasPacket
        lightning_distance = strike_distance.0039.AcuriteAtlasPacket
        strikes_total = strike_count.0039.AcuriteAtlasPacket
        lux = lux.0039.AcuriteAtlasPacket

    [[deltas]]
        rain = rain_total
        Lightning_Strike_count = strikes_count

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

[BME280] # parautenbach bme280wx

      [bme280wx]
         i2c_port = 1
         i2c_address = 0x76
         usUnits = US
         temperatureKeys = inTemp
         temperature_must_have = outTemp
         pressureKeys = pressure
         pressure_must_have = outTemp
         humidityKeys = inHumidity
         humidity_must_have = outTemp

I'm ending up with additional [bme280wx] entries under weewx [engine]. So when I try to run with these settings, weewx stops:

pi@raspberrypi:~ $ sudo weewxd
Traceback (most recent call last):
  File "/usr/share/weewx/weewxd", line 264, in <module>
    main()
  File "/usr/share/weewx/weewxd", line 151, in main
    engine = weewx.engine.StdEngine(config_dict)
  File "/usr/share/weewx/weewx/engine.py", line 93, in __init__
    self.loadServices(config_dict)
  File "/usr/share/weewx/weewx/engine.py", line 161, in loadServices
    obj = weeutil.weeutil.get_object(svc)(self, config_dict)
  File "/usr/share/weewx/weeutil/weeutil.py", line 1119, in get_object
    mod = __import__(module)
  File "/usr/share/weewx/user/bme280wx.py", line 6, in <module>
    import bme280
ModuleNotFoundError: No module named 'bme280'

If I comment out the bme280wx items, weewx runs fine. I've also tried some of the adafruit bme280 modules / methods, but that also fails.

I'm wondering: does my BME280 module need something specific to being a Grove branded module?

I'm still pretty green at all this Atlas  SDR / BME280 (the old 5-in-1 was more straightforward), and would greatly appreciate any pointers.

Cheers!
   



vince

unread,
Jul 17, 2021, 9:17:45 PM7/17/21
to weewx-user
On Saturday, July 17, 2021 at 1:38:02 PM UTC-7 Elie R wrote:
  File "/usr/share/weewx/user/bme280wx.py", line 6, in <module>
    import bme280
ModuleNotFoundError: No module named 'bme280'


This one seems like you didn't install the bme280 module for the version of python (2 or 3) that weewx is using.  A quick search points to https://pypi.org/project/RPi.bme280/  for installation instructions.

You might try a couple simple tests.
  • python -c "import bme280"
  • python3 -c "import bme280"
You should get an error if that version of python does not have the module installed.



Elie R

unread,
Jul 18, 2021, 5:44:06 PM7/18/21
to weewx-user
Thanks, I did initially follow those instructions, this is the error I received  running python3 -c "import bme280":

pi@raspberrypi:~ $ python3 -c "import bme280"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/pi/bme280.py", line 162
    print "Chip ID     :", chip_id
                        ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Chip ID     :", chip_id)?

def main():

  (chip_id, chip_version) = readBME280ID()
  print "Chip ID     :", chip_id
  print "Version     :", chip_version

  temperature,pressure,humidity = readBME280All()

  print "Temperature : ", temperature, "C"
  print "Pressure : ", pressure, "hPa"
  print "Humidity : ", humidity, "%"

Added the missing parentheses, tried running it again but still received a bunch of different errors, so I decided to uninstall all instances of bme280 and RPi.bme280 (python 2 and 3) and start over using pip3 install.

I can now run bme280 sample script directly from within its own directory under python3 :

 pi@raspberrypi:~/.local/lib/python3.7/site-packages/bme280 $ python sample.py
33fd4292-66f4-4994-8b69-523d13a7c3a7
2021-07-18 17:12:20.905437
21.5680572186
1013.10937762
58.1974230463
compensated_reading(id=33fd4292-66f4-4994-8b69-523d13a7c3a7, timestamp=2021-07-18 17:12:20.905437, temp=21.568 °C, pressure=1013.11 hPa, humidity=58.20 % rH)

but it fails if I try to run it from anywhere else, and if I try running weewxd, I get:

Traceback (most recent call last):
  File "/usr/share/weewx/weewxd", line 264, in <module>
    main()
  File "/usr/share/weewx/weewxd", line 151, in main
    engine = weewx.engine.StdEngine(config_dict)
  File "/usr/share/weewx/weewx/engine.py", line 93, in __init__
    self.loadServices(config_dict)
  File "/usr/share/weewx/weewx/engine.py", line 161, in loadServices
    obj = weeutil.weeutil.get_object(svc)(self, config_dict)
  File "/usr/share/weewx/weeutil/weeutil.py", line 1119, in get_object
    mod = __import__(module)

or trying to run the example script:

Traceback (most recent call last): File "sensor.py", line 8, in <module> calibration_params = bme280.load_calibration_params(bus, address) AttributeError: 'module' object has no attribute 'load_calibration_params'

Under python3  I'm seeing:
pi@raspberrypi:~/.local/lib/python3.7/site-packages/bme280 $ ls
const.py  __init__.py  __pycache__  reader.py  sample.py

but under python2 I'm getting (no sample.py installed with this package)
pi@raspberrypi:~/.local/lib/python2.7/site-packages/bme280 $ ls
const.py  const.pyc  __init__.py  __init__.pyc  reader.py  reader.pyc

I have no problem starting everything over from scratch, but not sure if I'm missing something obvious with bme280 install? weewx, rtl-sdr, Belchertown, i2c, etc   all went quite smoothly, but bme280 isn't being as nice. 

Cheers

storm...@gmail.com

unread,
Jul 18, 2021, 6:35:43 PM7/18/21
to weewx-user
Give the following a try

https://gitlab.com/wjcarpenter/bme280wx

I ran this without any issues

Reply all
Reply to author
Forward
0 new messages