Simple test
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: Copyright (c) 2024 Liz Clark for Adafruit Industries
2#
3# SPDX-License-Identifier: MIT
4
5"""Adafruit DS248x DS18B20 Example"""
6
7import time
8import board
9from adafruit_ds248x import Adafruit_DS248x
10
11# Initialize I2C bus and DS248x
12i2c = board.I2C()
13ds248x = Adafruit_DS248x(i2c)
14
15rom = bytearray(8)
16if not ds248x.onewire_search(rom):
17 print("No more devices found\n\n")
18
19print("Found device ROM: ", end="")
20for byte in rom:
21 print(f"{byte:02X} ", end="")
22print()
23while True:
24 temperature = ds248x.ds18b20_temperature(rom)
25 print(f"Temperature: {temperature:.2f} °C")
26
27 time.sleep(1)
DS2482S-800 8-Channel example
Read all 8 channels from the DS2482S-800
1# SPDX-FileCopyrightText: Copyright (c) 2024 Liz Clark for Adafruit Industries
2#
3# SPDX-License-Identifier: MIT
4
5"""Adafruit DS2482S-800 8-Channel DS18B20 Example"""
6
7import time
8import board
9from adafruit_ds248x import Adafruit_DS248x
10
11# Initialize I2C bus and DS248x
12i2c = board.STEMMA_I2C()
13ds248x = Adafruit_DS248x(i2c)
14
15while True:
16 for i in range(8):
17 ds248x.channel = i
18 print(f"Reading channel {ds248x.channel}")
19 temperature = ds248x.ds18b20_temperature()
20 print(f"Temperature: {temperature:.2f} °C")
21 print()
22 time.sleep(1)