diff --git a/ENS160/ENS160.py b/ENS160/ENS160.py index dac175b..d5eb195 100644 --- a/ENS160/ENS160.py +++ b/ENS160/ENS160.py @@ -104,6 +104,18 @@ def AQI(self) -> dict: else: return {"value": val, "text": "(unknown)"} + @property + def raw_resistance(self) -> tuple: + """Reads the sensor raw resistance values in Ohm. Only sensor 1 and 4 are officially supported""" + data = self.i2c.readfrom_mem(self.address, 0x48, 8) + + r1 = 2 ** ((data[0] | (data[1] << 8)) / 2048.0) + r2 = 2 ** ((data[2] | (data[3] << 8)) / 2048.0) + r3 = 2 ** ((data[4] | (data[5] << 8)) / 2048.0) + r4 = 2 ** ((data[6] | (data[7] << 8)) / 2048.0) + + return r1, r2, r3, r4 + @property def status(self) -> dict: """Reads the DATA_STATUS register and translates this single byte into each field's value.""" @@ -233,4 +245,4 @@ def _byte_to_binary(self, byte:int) -> str: for x in range(8): binary = str(byte & 1) + binary byte >>= 1 - return binary \ No newline at end of file + return binary