BME280センサーのexporter

https://github.com/ashtreefarms/bme280-exporter

CPUがrock Pi4の場合、I2Cバス番号が7なので、一部修正が必要

$ /home/mars/.pyenv/versions/3.8.10/bin/bme280_exporter -a 0x76
2021-09-30 14:07:43,226 - initializing BME280 at 0x76 filter: 0 oversampling(h: 4, p: 4, t: 4)
2021-09-30 14:07:43,259 - initializing exporter with labels None
2021-09-30 14:07:43,260 - starting exporter on port 9500
2021-09-30 14:07:43,267 - starting sampling with 2.0s interval
2021-09-30 14:07:43,295 - temp: 30.31 C   humidity: 0.00%   pressure: 998.05 hPa
2021-09-30 14:07:45,302 - temp: 30.33 C   humidity: 0.00%   pressure: 998.02 hPa
2021-09-30 14:07:47,310 - temp: 30.34 C   humidity: 0.00%   pressure: 998.01 hPa

修正箇所 Adafruit_GPIO/I2C.py

def get_default_bus():
    """Return the default bus number based on the device platform.  For a
    Raspberry Pi either bus 0 or 1 (based on the Pi revision) will be returned.
    For a Beaglebone Black the first user accessible bus, 1, will be returned.
    """
    return 7

Usage

$ bme280_exporter -h
usage: bme280_exporter [-h] [-v] [-p PORT] [-a ADDRESS] [-l LABELS]
                       [-i INTERVAL] [-f FILTER] [-ho HO] [-po PO] [-to TO]

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         increase output verbosity
  -p PORT, --port PORT  exporter port (default: 9500
  -a ADDRESS, --address ADDRESS
                        BME280 I2C address (default: 0x77)
  -l LABELS, --labels LABELS
                        JSON object of Prometheus labels to apply
  -i INTERVAL, --interval INTERVAL
                        measurement sample interval (default: 2)
  -f FILTER, --filter FILTER
                        filter value to apply (0-4, default: 0)
  -ho HO                humidity oversampling value (1-5, default: 4)
  -po PO                pressure oversampling value (1-5, default: 4)
  -to TO                temperature oversampling value (1-5, default: 4)

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です