API Reference
adafruit_hdc302x
CircuitPython driver for the Adafruit HDC302x Precision Temperature/Humidity breakout
Author(s): Liz Clark
Implementation Notes
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_hdc302x.HDC302x(i2c_bus: busio.I2C, address: int = 0x44)
Driver for the HDC302x temperature and humidity sensor.
Initialize the HDC302x sensor with the given I2C bus and address.
- Parameters:
i2c_bus – The I2C bus object.
address – The I2C address of the sensor.
- property auto_measurements: Tuple[float, float]
The measured temperature and relative humidity in auto mode, from a single readout.
Use this instead of reading
auto_temperatureandauto_relative_humidityseparately: a readout clears the latched result, so a second separate readout returns the cleared sentinel (+130 degC / +100 %RH) or NACKs mid-conversion (datasheet 7.5.7.3.2).- Returns:
A tuple of (temperature in degrees Celsius, relative humidity in percent).
- property auto_mode: int
Auto mode for measurements. Options:
“5MPS_LP0”, “5MPS_LP1”, “5MPS_LP2” “5MPS_LP3”, “1MPS_LP0”, “1MPS_LP1” “1MPS_LP2”, “1MPS_LP3”, “2MPS_LP0” “2MPS_LP1”, “2MPS_LP2”, “2MPS_LP3” “4MPS_LP0”, “4MPS_LP1”, “4MPS_LP2” “4MPS_LP3”, “10MPS_LP0”, “10MPS_LP1” “10MPS_LP2”, “10MPS_LP3”, “EXIT_AUTO_MODE”
- Returns:
The current auto mode.
- property auto_relative_humidity: float
Read relative humidity in auto mode.
Warning
An auto-mode readout returns and then clears the latched result. Reading this property together with
auto_temperatureas two separate reads consumes the sample twice: the second read returns the cleared sentinel (+130 degC / +100 %RH) or NACKs mid-conversion. Useauto_measurementsto read both at once. Reading this property on its own is fine.- Returns:
The relative humidity in percent.
- property auto_temperature: float
Read temperature in auto mode.
Warning
An auto-mode readout returns and then clears the latched result. Reading this property together with
auto_relative_humidityas two separate reads consumes the sample twice: the second read returns the cleared sentinel (+130 degC / +100 %RH) or NACKs mid-conversion. Useauto_measurementsto read both at once. Reading this property on its own is fine.- Returns:
The temperature in degrees Celsius.
- clear_high_alert(temp: float, humid: float) None
Clear the high alert thresholds for temperature and humidity.
- Parameters:
temp – The temperature threshold in degrees Celsius.
humid – The relative humidity threshold in percent.
- clear_low_alert(temp: float, humid: float) None
Clear the low alert thresholds for temperature and humidity.
- Parameters:
temp – The temperature threshold in degrees Celsius.
humid – The relative humidity threshold in percent.
- property heater: bool
Heater power. Can be set to:
“OFF”, “QUARTER_POWER”, “HALF_POWER”, “FULL_POWER”
- Returns:
True if the heater is on, False otherwise.
- property high_alert: bool
Check if the high alert is activated.
- Returns:
True if the high alert is activated, False otherwise.
- property low_alert: bool
Check if the low alert is activated.
- Returns:
True if the low alert is activated, False otherwise.
- property measurements: Tuple[float, float]
The measured temperature and relative humidity from a single trigger-on-demand read.
Prefer this over reading
temperatureandrelative_humidityseparately, which triggers two measurements.- Returns:
A tuple of (temperature in degrees Celsius, relative humidity in percent).
- property offsets: Tuple[float, float]
Set temperature and relative humidity offsets
- Returns:
The temperature and humidity offsets.
- property relative_humidity: float
The measured relative humidity in percent.
- Returns:
The relative humidity in percent.
- set_high_alert(temp: float, humid: float) None
Set the high alert thresholds for temperature and humidity.
- Parameters:
temp – The temperature threshold in degrees Celsius.
humid – The relative humidity threshold in percent.