Skip to content

Instantly share code, notes, and snippets.

@furushei
Created October 4, 2018 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furushei/87b978eb2978c844109560612ada0c6c to your computer and use it in GitHub Desktop.
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
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