0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Grove - Barometer Sensor (BMP280) をRaspberry Pi Zeroで使う

Posted at

やること

相対的な高さを定期的に取得する機能を実現したい。
Barometer Sensor (BMP280)をラズベリーパイZero用ベースハットに接続して動かす。

手順

残念ながらSeeedのWikiやGrovePiのサンプルにはなさそう。
更に調べたところ、このソースがそのまま使えそうなので試す。
https://github.com/pimoroni/bmp280-python

まずは、I2Cの端子に、BMP280を接続する。
その後以下を実行。

sudo pip3 install bmp280
git clone https://github.com/pimoroni/bmp280-python
cd bmp280-python/examples/
sudo python3 relative-altitude.py 

するとI2Cのアドレスが間違っている(Groveのセンサーのアドレスはデフォルト0x77なのに対して、スクリプトのデフォルトは、0x76になっている)ので、

bmp280 = BMP280(i2c_addr=0x77, i2c_dev=bus)

として再度実行すると動作した。
以下のように、センサーをもって軽く上げ下げするだけでも値の変化を確認できたので一旦満足。

Relative altitude: 01.04 metres
Relative altitude: 01.08 metres
Relative altitude: 01.23 metres
Relative altitude: 01.30 metres
Relative altitude: 01.37 metres
Relative altitude: 01.45 metres
Relative altitude: 01.53 metres
Relative altitude: 01.54 metres
Relative altitude: 01.59 metres
Relative altitude: 01.64 metres
Relative altitude: 01.67 metres
Relative altitude: 01.74 metres
Relative altitude: 01.75 metres
Relative altitude: 01.75 metres
Relative altitude: 01.50 metres
Relative altitude: 01.27 metres
Relative altitude: 01.17 metres
Relative altitude: 01.11 metres
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?