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: adafruit_onewire.bus.OneWireBus, address: int)[source]¶
Class which provides interface to DS18X20 temperature sensor
- Parameters:
bus – The bus the DS18X20 is connected to
address (int) – 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
- property address¶
The address of the device. Useful if there are multiple sensors on the bus.
Note: this property is read only.
- read_temperature() float [source]¶
Read the temperature. No polling of the conversion busy bit (assumes that the conversion has completed).
- start_temperature_read() float [source]¶
Start asynchronous conversion, returns immediately. Returns maximum conversion delay [seconds] based on resolution.
- property temperature¶
The temperature in degrees Celsius.