MicroPython HDC1080 Driver

hdc1080

MicroPython driver for the TI HDC1080 Temperature and Humidity sensor

  • Author: Jose D. Montoya

class micropython_hdc1080.hdc1080.HDC1080(i2c, address: int = 0x40)[source]

Driver for the HDC1080 Sensor connected over I2C.

Parameters:
i2c : I2C

The I2C bus the HDC1080 is connected to.

address : int

The I2C device address. Defaults to 0x40

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

Here is an example of using the HDC1080 class. First you will need to import the libraries to use the sensor

from machine import Pin, I2C
from micropython_hdc1080 import hdc1080

Once this is done you can define your machine.I2C object and define your sensor object

i2c = I2C(1, sda=Pin(2), scl=Pin(3))
hdc1080 = hdc1080.HDC1080(i2c)

Now you have access to the attributes

temp = hdc1080.temperature
property humidity_resolution : str

Sensor humidity_resolution

Mode

Value

hdc1080.HUM_RES_14BIT

0b00

hdc1080.HUM_RES_11BIT

0b01

hdc1080.HUM_RES_8BIT

0b10

property measurements : tuple[float, float]

Return Temperature in Celsius and Relative humidity in rh%

property operation_mode : str

Sensor operation_mode

Mode

Value

hdc1080.TEMP_AND_HUM

0b0

hdc1080.TEMP_OR_HUM

0b1

property relative_humidity : float

Relative Humidity in rh%

reset() None[source]

Reset the sensor

property temperature : float

Temperature in Celsius

property temperature_resolution : str

Sensor temperature_resolution

Mode

Value

hdc1080.TEMP_RES_14BIT

0b0

hdc1080.TEMP_RES_11BIT

0b1