Reset on Init fails when sensor in low-power state
Cybot101 opened this issue · 1 comments
Using an SAMD21 (Sparkfun Redboard Turbo) with SHTC3 via Quick/StemmaQT.
CP 6.0 beta.
shtc3_simpletest.py
example works initially, but subsequent runs after soft-reboot will fail during SHTC3 init. Throws an OS Input/Output error from I2C write. Power cycle works again, until a soft-reset. Rinse, repeat. Possibly related to #1 (though not on rPi)?
Looking at the bus on a scope I can see the soft reset command 0x805D being NAK'd. The SHT address is ACK (so device is okay) but the write to registers is NAK.
I believe it is due to the sensor being put into low-power state after a read. When the soft-reset occurs the device is still asleep and ignores the request.
I have added a call to wake sensor before the soft reset and that appears to stop the error.
Can anyone else confirm similar behaviour? Maybe I'm missing something obvious? Can PR a fix if I'm on the right track.
simpletest.py
code for reference
# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import time
import busio
import board
import adafruit_shtc3
i2c = busio.I2C(board.SCL, board.SDA)
sht = adafruit_shtc3.SHTC3(i2c)
while True:
temperature, relative_humidity = sht.measurements
print("Temperature: %0.1f C" % temperature)
print("Humidity: %0.1f %%" % relative_humidity)
print("")
time.sleep(1)