1 Star 2 Fork 3

py2012/esp32c3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main_ds18b20.py 739 Bytes
一键复制 编辑 原始数据 按行查看 历史
py2012 提交于 2023-08-17 10:13 +08:00 . 基于DS18B20的湿度计
import time
import ds18b20
from ds18b20 import ds
time.sleep(1)
sensor=ds(2,'c',12) #creates sensor object set to default pin 2, units in Celcius, resolution 12 bit
#sensor.addr, sensor.pin, sensor.unit, and sensor.res values are now available
#you can change the object parameters by the following:
#pin number - sensor.pin=[number]
#unit - sensor.unit=['c'|'f']
#resolution - sensor.res=[9|10|11|12]
while True:
temp=ds18b20.read(sensor) # a time.sleep is builtin to the function to allow time to take the reading
#the builtin time.sleep is currently set to 1 second for all resolutions but will eventually
#take less time for the lower resolutions once it has been added to the library
print (temp)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/py2012/esp32c3.git
git@gitee.com:py2012/esp32c3.git
py2012
esp32c3
esp32c3
master

搜索帮助