esp8266 micropython ds18b20
import time
import machine
import onewire
# the device is on GPIO12
dat = machine.Pin(12)
# create the onewire object
ds = onewire.DS18B20(onewire.OneWire(dat))
# scan for devices on the bus
roms = ds.scan()
print('found devices:', roms)
# loop 10 times and print all temperatures
for i in range(10):
print('temperatures:', end=' ')
ds.convert_temp()
time.sleep_ms(750)
for rom in roms:
print(ds.read_temp(rom), end=' ')
print()