Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ENS160/ENS160.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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
return binary