出典:温湿度・気圧・ガスセンサ(BME680)をRaspberryPi4で使う
自分でも出来そうなことが、あまりに見つからないので、今更だとは思ったがラズパイにセンサーを繋いでみることに。
出典元に記載の手順に従い、ラズパイ4Bに秋月のBME680 複合センサモジュールを接続。
ピンアサイン
CN1 | 名称 | 機能 | 出荷時設定 | ラズベリ側 端子番号 |
---|---|---|---|---|
1 | VIN | 電源入力 | 2.5~6V | 4 |
2 | SCL | シリアルクロック | プルアップ抵抗未接続 | 5 |
3 | SDA | シリアルデータ | プルアップ抵抗未接続 | 3 |
4 | GND | - | 6 |
ライブラリのインストール
出典元:Getting Started with BME680 Breakout
pi@raspberrypi:~ $ git clone https://github.com/pimoroni/bme680
pi@raspberrypi:~ $ cd bme680/library
pi@raspberrypi:~ $ sudo python setup.py install
サンプルの実行
pi@raspberrypi:~ $ cd /home/pi/bme680/examples
pi@raspberrypi:~/bme680/examples $ python read-all.py
無事取得できれば次の表示
read-all.py - Displays temperature, pressure, humidity, and gas.
Press Ctrl+C to exit!
Calibration data:
par_gh1: -18
par_gh2: -5920
par_gh3: 18
par_h1: 691
par_h2: 1026
par_h3: 0
par_h4: 45
par_h5: 20
par_h6: 120
par_h7: -100
par_p1: 35732
par_p10: 30
par_p2: -10425
par_p3: 88
par_p4: 5609
par_p5: -30
par_p6: 30
par_p7: 30
par_p8: -1245
par_p9: -3172
par_t1: 26449
par_t2: 26311
par_t3: 3
range_sw_err: 1
res_heat_range: 1
res_heat_val: 48
t_fine: 109251
Initial reading:
gas_index: 0
gas_resistance: 12917167
heat_stable: False
humidity: 64.178
meas_index: 0
pressure: 1004.28
status: 32
temperature: 21.34
Polling:
21.34 C,1004.26 hPa,64.17 %RH
21.36 C,1004.26 hPa,64.16 %RH,19477 Ohms
21.40 C,1004.26 hPa,64.11 %RH,35777 Ohms
21.44 C,1004.27 hPa,64.05 %RH,47380 Ohms
21.49 C,1004.25 hPa,63.95 %RH,54755 Ohms
21.53 C,1004.23 hPa,63.84 %RH,60772 Ohms
21.57 C,1004.24 hPa,63.75 %RH,65816 Ohms
pi@raspberrypi:~/bme680/examples $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77