BME280 Sensor with WeeWX 5.1

151 views
Skip to first unread message

Judge Richter

unread,
Aug 11, 2025, 8:30:01 AMAug 11
to weewx-user
Hi,

this is my first try with WeeWX. First step should be to use the sensor bme280 on my Raspberry Pi running WeeWX. The sensor works. I see temp, pressure and humidity with this python script https://randomnerdtutorials.com/raspberry-pi-bme280-python/.

I found howtos to install the driver and use the bme280 but they don't work with WeeWX 5.1. How can i install the driver or is it better to use an older version?

Thomas

vince

unread,
Aug 11, 2025, 11:31:39 AMAug 11
to weewx-user

Mark Fraser

unread,
Aug 13, 2025, 6:27:56 PMAug 13
to weewx...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-user/f766c093-bd6d-431d-9cc9-3acd048337den%40googlegroups.com.

After visiting your page, I remembered that I'd submitted a merge request to wjcarpenter that reduced the amount it posted to syslog. My version is still at https://gitlab.com/mfraz74/bme280wx/

Judge Richter

unread,
Aug 14, 2025, 11:21:38 AMAug 14
to weewx-user
Installation of bme280 works but the weewx start failed:

I can read the data from bme280 manually with a python script.

Using configuration file /etc/weewx/weewx.conf
Extension Name    Version   Description
bme280wx          1.0       Add bme280 sensor readings to loop packet data
pi@weather:~$ sudo nano /etc/weewx/weewx.conf
pi@weather:~$ weewxd
Using configuration file /etc/weewx/weewx.conf
Traceback (most recent call last):
  File "/usr/share/weewx/weewxd.py", line 226, in <module>
    main()
  File "/usr/share/weewx/weewxd.py", line 121, in main
    engine = weewx.engine.StdEngine(config_dict)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weewx/engine.py", line 89, in __init__
    self.loadServices(config_dict)
  File "/usr/share/weewx/weewx/engine.py", line 157, in loadServices
    obj = weeutil.weeutil.get_object(svc)(self, config_dict)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weeutil/weeutil.py", line 1404, in get_object
    module = importlib.import_module(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/etc/weewx/bin/user/bme280wx.py", line 6, in <module>
    import bme280
ModuleNotFoundError: No module named 'bme280'

vince

unread,
Aug 14, 2025, 12:12:24 PMAug 14
to weewx-user
sudo apt install python3-bme280

Judge Richter

unread,
Aug 14, 2025, 1:06:36 PMAug 14
to weewx-user
now i have an other error

weectl extension install -y        https://gitlab.com/wjcarpenter/bme280wx/-/archive/master/bme280wx-master.zip
Error parsing config file: [Errno 13] Permission denied: '/etc/weewx/weewx.conf'

Traceback (most recent call last):
  File "/usr/share/weewx/weeutil/startup.py", line 86, in start_app
    config_path, config_dict = weecfg.read_config(config_option, [config_arg])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weecfg/__init__.py", line 150, in read_config
    config_dict = configobj.ConfigObj(config_path,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/configobj/__init__.py", line 1229, in __init__
    self._load(infile, configspec)
  File "/usr/lib/python3/dist-packages/configobj/__init__.py", line 1236, in _load
    with open(infile, 'rb') as h:
         ^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/etc/weewx/weewx.conf'


and when i run weectl with sudo

Using configuration file /etc/weewx/weewx.conf
Traceback (most recent call last):
  File "/usr/share/weewx/weectl.py", line 75, in <module>
    main()
  File "/usr/share/weewx/weectl.py", line 67, in main
    namespace.func(namespace)
  File "/usr/share/weewx/weectllib/__init__.py", line 80, in dispatch
    config_path, config_dict, log = weeutil.startup.start_app('weectl',
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weeutil/startup.py", line 111, in start_app
    weewx_root, user_module = initialize(config_dict)
                              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weeutil/startup.py", line 76, in initialize
    importlib.import_module('user.extensions')

  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/etc/weewx/bin/user/extensions.py", line 18, in <module>
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.11/locale.py", line 626, in setlocale
    return _setlocale(category, locale)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
locale.Error: unsupported locale setting

vince

unread,
Aug 14, 2025, 1:35:21 PMAug 14
to weewx-user
Add your user (typically pi) to group weewx so it has permission to write the config files in /etc/weewx which is group weewx.
  • sudo usermod -aG weewx pi
  • then log out as user pi, and log back in to make it take effect
  • then try the extension install which should work fine 'without' sudo
(I had a spare pi to test on and the above worked for me just now)

Once the initial weewx package is installed you shouldn't need to use sudo at all, nor should you.  Weewx v5 does not run as root.  A dpkg installation runs as user 'weewx' group 'weewx'.  You can check your group membership via the 'groups' command which should return output that looks something like:

pi@raspberrypi:~ $ groups
pi adm dialout cdrom sudo audio video plugdev games users input render netdev lpadmin weewx gpio i2c spi
Message has been deleted

Judge Richter

unread,
Aug 15, 2025, 9:14:47 AMAug 15
to weewx-user
OK, works not. I had to reboot after adding the user to the group.

But weewx doesn't recognize the sensor. In the webinterface inside temp is 17° but acually it's 26°. I have this in syslog

Aug 15 15:09:50 weather weewxd[608]: CRITICAL __main__:     ****    File "/etc/weewx/bin/user/bme280wx.py", line 58, in __init__
Aug 15 15:10:00 weather weewxd.py[608]: bme280: bme280wx configuration {'i2c_port': '1', 'i2c_address': '0x76', 'usUnits': 'US', 'temperatureKeys': 'inTemp', 'temperature_must_have': '', 'pressureKeys': 'pressure', 'pressure_must_have': 'outTemp', 'humidityKeys': 'inHumidity', 'humidity_must_have': ''}


Your driver is for waveshare bme280 but I thought it's from bosch. Is it possible we are talking about different sensors?

Judge Richter

unread,
Aug 15, 2025, 9:55:00 AMAug 15
to weewx-user

Edit to my last answer: it works NOW, it could install the driver. But i dont See anything in the Webinterface.

Judge Richter

unread,
Aug 15, 2025, 12:48:11 PMAug 15
to weewx-user
Got it. I have to do 'sudo usermod -aG i2c weewx'. I think such information should be find in the weewx user guide.

vince

unread,
Aug 15, 2025, 1:01:18 PMAug 15
to weewx-user
You need to always also check the FAQ and wiki for further information.

From the FAQ:


if you installed WeeWX using a DEB/RPM package, then the configuration files, skins, and database are owned by the user weewx. If you are not in the weewx group, you will not be able to modify those files, although you should be able to read them. If you need to edit the files or database, put yourself into the weewx group:

sudo usermod -aG weewx your-user-name

See the Wiki article understanding permissions.

Which points to https://github.com/weewx/weewx/wiki/Understanding-permissions and specifically https://github.com/weewx/weewx/wiki/Understanding-permissions#more-details-about-which-groups-can-do-what which points you right to the answer.  So it's been documented in the FAQ 'and' wiki for years.
Reply all
Reply to author
Forward
0 new messages