adafruit_ds18x20
¶
Driver for Dallas 1-Wire temperature sensor.
- Author(s): Carter Nelson
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
-
class
adafruit_ds18x20.
DS18X20
(bus, address)[source]¶ Class which provides interface to DS18X20 temperature sensor :param bus: The bus the DS18X20 is connected to :param int address: The device address.
Quickstart: Importing and using the device
Here is an example of using the
DS18X20
class. First you will need to import the libraries to use the sensorimport board from adafruit_onewire.bus import OneWireBus from adafruit_ds18x20 import DS18X20
Once this is done you can define your
adafruit_onewire.bus.OneWireBus
object and define your sensor objectow_bus = OneWireBus(board.D5) ds18 = DS18X20(ow_bus, ow_bus.scan()[0])
Now you have access to the
temperature
attributetemperature = ds18.temperature
-
read_temperature
()[source]¶ Read the temperature. No polling of the conversion busy bit (assumes that the conversion has completed).
-
resolution
¶ The programmable resolution. 9, 10, 11, or 12 bits.
-
start_temperature_read
()[source]¶ Start asynchronous conversion, returns immediately. Returns maximum conversion delay [seconds] based on resolution.
-
temperature
¶ The temperature in degrees Celsius.
-