1 Star 0 Fork 1

Pluto/epaper_clock_4.2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
air_sensor.py 643 Bytes
一键复制 编辑 原始数据 按行查看 历史
Pluto 提交于 2020-08-19 09:23 . init
# coding: utf-8
import json
import os
import time
import Adafruit_DHT
# Set sensor type : Options are DHT11,DHT22 or AM2302
sensor = Adafruit_DHT.DHT11
# Set GPIO sensor is connected to
gpio = 4
# Use read_retry method. This will retry up to 15 times to
# get a sensor reading (waiting 2 seconds between each retry).
humidity, temperature = Adafruit_DHT.read_retry(sensor, gpio)
result = {'temp': int(temperature), 'humidity': int(
humidity), 'update': int(time.time())}
data_file = os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'home_air.json')
with open(data_file, 'w') as out_file:
json.dump(result, out_file)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/uniartisan2018/epaper_clock_4.2.git
git@gitee.com:uniartisan2018/epaper_clock_4.2.git
uniartisan2018
epaper_clock_4.2
epaper_clock_4.2
master

搜索帮助