0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RPZ-IR-Sensor Rev2 再導入

Last updated at Posted at 2024-12-04

RPZ-IR-SensorRev2
71-MEhapEoL._AC_SY300_SX300_QL70_ML2.jpg

センサー制御ソフトウェア「cgsensor」をインストール

sudo python3 -m pip install -U cgsensor
cgsensor all

結果

BME280#2
  温度[C]:  22.6
  湿度[%]:   39.5
  気圧[hPa]: 1011.0
TSL2572
  明るさ[lux]:  41.7

i2c-toolsでI2Cで接続されているデバイスを確認します。

i2cdetect -y 1

python 作成 bme280_tsl2572.py

sudo vim bme280_tsl2572.py

中身は以下 Indoor Corgiさんのサイトからサンプルをマージして作成。 

#!/usr/bin/env python3
import cgsensor  # インポート
bme280 = cgsensor.BME280(i2c_addr=0x77)  # BME280制御クラスのインスタンス, i2c_addrは0x76/0x77から選択
bme280.forced()  # Forcedモードで測定を行い, 結果をtemperature, pressure, humidityに入れる
print('気温 {}°C'.format(bme280.temperature))  # 気温を取得して表示
print('湿度 {}%'.format(bme280.humidity))  # 湿度を取得して表示
print('気圧 {}hPa'.format(bme280.pressure))  # 気圧を取得して表示
tsl2572 = cgsensor.TSL2572()  # TSL2572制御クラスのインスタンス
tsl2572.single_auto_measure()  # 条件を自動で調整しながら1回測定を行い, luxに結果を入れる
print('明るさ {}lux'.format(tsl2572.illuminance))  # 明るさを取得して表示

実行

python bme280_tsl2572.py

cgsensor allと同じ内容で表示された。OK。

温度は ラズパイの熱の関係で実際の気温と異なるのでpythonを変更。

LCD接続して表示させようと考えています。

※何回か接続しなおしたりすると、接触不良なのか、エラーとなるので留意。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?