1、DS18B20 介绍
1.1、 引脚定义
1.2、接线图
DS18B20的DQ口需要增加一个上拉电阻,Vcc使用3.3V
2、代码
from machine import Pin
from onewire import OneWire
from ds18x20 import DS18X20
import time, ds18x20
ow = OneWire(Pin(12)) # create a OneWire bus on GPIO12
ds = DS18X20(ow)
roms = ds.scan()
ds.convert_temp()
time.sleep_ms(750)
for rom in roms:
print(ds.read_temp(rom))