From d276008a70e0429d5e0b1254396e6c4bda403a53 Mon Sep 17 00:00:00 2001 From: Baconator Date: Mon, 16 Feb 2026 20:39:20 +0100 Subject: [PATCH] Add support for reading raw resistances to ENS160 Officially only sensors 1 and 4 are supported according to the datasheet, but it seems like sensor 3 is also readable. --- ENS160/ENS160.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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