# Find 1st DS18x20 Temperature sensor and print every second.
# Put a 4.7K resistor between 3.3V and signal pin
import time
import board
from adafruit_onewire.bus import OneWireBus
from adafruit_ds18x20 import DS18X20

# Initialize one-wire bus on pin D7. Avoid D5 on IB-M4 - 5 volts!
ow_bus = OneWireBus(board.D7)
devices = ow_bus.scan()
for device in devices:
    print("ROM = {} \tFamily = 0x{:02x}".format([hex(i) for i in device.rom], device.family_code))
# Get first sensor from scan
ds18 = DS18X20(ow_bus, ow_bus.scan()[0])

# Print the temperature every second
while True:
    print('Temperature: {0:0.3f}C'.format(ds18.temperature))
    time.sleep(1.0)