秋月の温湿度・気圧センサモジュールAE-BME280で、温度・湿度・気圧を取得する(1/2)
お手伝いしている会社の勉強会のために、秋月の温湿度・気圧センサモジュールAE-BME280で、温度・湿度・大気圧を得る手順をまとめました。
最近、smbus2が必要になったようです。
(1)モジュール接続
割愛
(2)I2C有効化
[Preferences]-[Raspberry Pi Configuration]
[Interfaces」->「I2C」「Enable」
再起動
[YES]
(3)i2cパッケージのインストール
sudo apt-get install i2c-tools
sudo apt-get python-smbus
検出
sudo i2cdetect -y 1
中身を取り出す
sudo i2cdump -y 1 0x76
(4)スイッチサイエンス社のライブラリをダウンロード
wget https://github.com/SWITCHSCIENCE/BME280/archive/master.zip
unzip master.zip
cp -p ./BME280-master/Python27/bme280_sample.py .
python ./bme280_sample.py
----
Traceback (most recent call last):
File "/home/pi/bme280_sample.py", line 3, in
from smbus2 import SMBus
ImportError: No module named smbus2
----
エラーになる。
cd /BME280-master/Python27
cat requirements.txt
----
smbus2>=0.1.3
----
smbus2が必要なようだ。
(5)smbus2のインストール
wget https://github.com/kplindegaard/smbus2/archive/master.zip
unzip master.zip.1
----
Archive: master.zip.1
a115a850ed7c8ecc7438fff0d5c40e230eaf6579
creating: smbus2-master/
inflating: smbus2-master/.travis.yml
inflating: smbus2-master/LICENSE
inflating: smbus2-master/README.md
inflating: smbus2-master/README.rst
inflating: smbus2-master/setup.py
creating: smbus2-master/smbus2/
inflating: smbus2-master/smbus2/__init__.py
inflating: smbus2-master/smbus2/smbus2.py
creating: smbus2-master/tests/
inflating: smbus2-master/tests/test_datatypes.py
inflating: smbus2-master/tests/test_smbus2.py
----
cd smbus2-master
sudo pip install smbus2
----
Downloading/unpacking smbus2
Downloading smbus2-0.1.4.tar.gz
Running setup.py (path:/tmp/pip-build-Eqrjt6/smbus2/setup.py) egg_info for package smbus2
Installing collected packages: smbus2
Running setup.py install for smbus2
Successfully installed smbus2
Cleaning up...
----
(6)動作確認
python ./bme280_sample.py
----
temp : 24.13 ℃
pressure : 1011.14 hPa
hum : 67.66 %
----
以上
« ipset作成メモ(日本のIPv4アドレス一覧) | トップページ | 秋月の温湿度・気圧センサモジュールAE-BME280で、温度・湿度・気圧を取得する(2/2) »
この記事へのコメントは終了しました。
« ipset作成メモ(日本のIPv4アドレス一覧) | トップページ | 秋月の温湿度・気圧センサモジュールAE-BME280で、温度・湿度・気圧を取得する(2/2) »
コメント