Skip to content

Commit 98f6815

Browse files
committed
Changing chip_id function.
1 parent 79407a7 commit 98f6815

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

adafruit_shtc3.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def __init__(self, i2c_bus):
118118
self.low_power = False
119119
self.sleeping = False
120120
self.reset()
121+
self._chip_id = self._get_chip_id()
121122
if self._chip_id & 0x083F != _SHTC3_CHIP_ID:
122123
raise RuntimeError("Failed to find an SHTC3 sensor - check your wiring!")
123124

@@ -129,18 +130,12 @@ def _write_command(self, command):
129130
with self.i2c_device as i2c:
130131
i2c.write(self._buffer, start=0, end=2)
131132

132-
@property
133-
def _chip_id(self): # readCommand(SHTC3_READID, data, 3);
133+
def _get_chip_id(self): # readCommand(SHTC3_READID, data, 3);
134134
"""Determines the chip id of the sensor"""
135-
self._buffer[0] = _SHTC3_READID >> 8
136-
self._buffer[1] = _SHTC3_READID & 0xFF
137-
138-
self.reset()
139-
135+
self._write_command(_SHTC3_READID)
136+
time.sleep(0.001)
140137
with self.i2c_device as i2c:
141-
i2c.write_then_readinto(
142-
self._buffer, self._buffer, out_start=0, out_end=2, in_start=0, in_end=2
143-
)
138+
i2c.readinto(self._buffer)
144139

145140
return unpack_from(">H", self._buffer)[0]
146141

0 commit comments

Comments
 (0)