0
0

More than 1 year has passed since last update.

Raspberry Pi で Grove の 温湿度モジュールを使う

Last updated at Posted at 2021-09-30

次のページを参考にしました。
Grove - Temperature&Humidity Sensor Pro(DHT22)

実行時の様子
IMG_20210930_155528.jpg

必要なライブラリーのインストール

curl -sL https://github.com/Seeed-Studio/grove.py/raw/master/install.sh | sudo bash -s -

プログラム

dht_simpleread.py
#! /usr/bin/python3
import time
import seeed_dht

sensor = seeed_dht.DHT("22", 16)

while True:
    humi, temp = sensor.read()
    if not humi is None:
        print('DHT{0}, humidity {1:.1f}%, temperature {2:.1f}*'.format(s
ensor.dht_type, humi, temp))
    else:
        print('DHT{0}, humidity & temperature: {1}'.format(sensor.dht_ty
pe, temp))
    time.sleep(2)
#

実行結果

$ ./dht_simpleread.py 
DHT22, humidity 68.3%, temperature 26.6*
DHT22, humidity 68.3%, temperature 26.6*
DHT22, humidity 70.1%, temperature 26.6*
DHT22, humidity 83.5%, temperature 26.8*
DHT22, humidity 85.0%, temperature 26.8*
DHT22, humidity 89.1%, temperature 27.0*
DHT22, humidity 88.6%, temperature 27.1*
DHT22, humidity 77.7%, temperature 27.2*
DHT22, humidity 76.6%, temperature 27.3*
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