i import the ds18x20.
import gc,ds18x20
import onewire
ow = onewire.OneWire(Pin("P9"))
# 实例DS18X20类
ds = ds18x20.DS18X20(ow)
# 扫描总线上的DS18B20,获取设备列表
roms = ds.scan()
def read_temperature():
ds.convert_temp()
# convert_temp后至少等待750ms
time.sleep_ms(750)
# 返回总线的上ds18b20设备的温度值
try:
for rom in roms:
#print('Device %s temperature is %d'%(bytes(rom),ds.read_temp(rom)))
t=int(ds.read_temp(rom))
return t
except Exception as e:
print('DS18B20连接错误',e)
print(str(e))
return 0
REGISTER=read_temperature()
why the color of ds18x20 and onewire is white?not blue?