Created
October 4, 2018 10:32
-
-
Save furushei/87b978eb2978c844109560612ada0c6c to your computer and use it in GitHub Desktop.
M5CloudでDHT12センサを扱うサンプルスクリプト。一定時間ごとに温度と湿度を液晶画面に表示する。DHT12用ライブラリ(dht12.py)が必要: https://github.com/m5stack/M5Cloud/blob/master/lib/dht12.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from m5stack import lcd | |
import dht12 | |
import utime | |
sensor = dht12.DHT12() | |
sensor.measure() | |
temperature = sensor.temperature() | |
humidity = sensor.humidity() | |
lcd.clear() | |
lcd.setCursor(0, 0) | |
while True: | |
lcd.println('Temperature: {:.1f} `C Humidity: {:.1f} %'.format(temperature, humidity)) | |
utime.sleep(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment