Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sensor not responding on repeated use #3

Merged
merged 1 commit into from
Oct 16, 2020

Conversation

Cybot101
Copy link
Contributor

@Cybot101 Cybot101 commented Oct 8, 2020

Fir for #2 and hopefully #1 as well.

Moved the call to wake to occur before the soft reset command in init. Also added a wake call into the reset function in case reset() is used in user code. This will cause 2 wake commands when initialising, but ensures consistent state. Happy to discuss?

Sensor will still be in active state (not low power) until first measurement request. Good idea?

@ladyada ladyada requested a review from siddacious October 9, 2020 03:43
@AnthonyHorton
Copy link

I've tested this, and sending the wake command before anything else does seem to be the key to reconnecting to the SHTC3.

With the version from adafruit:master I connected to the SHTC3, closed the Python session, opened a new one, and tried to connect to the SHTC3 again and got the I/O error as in #1. I then manually sent a wake command to the device, then tried again, and I was able to connect and get measurements from the SHTC3.

I then checked out @Cybot101 's Cybot101:sleepy-reset-fix branch and tried repeatably connecting to the SHTC3, and it worked every time.

@ladyada ladyada merged commit 8e0fea8 into adafruit:master Oct 16, 2020
@ladyada
Copy link
Member

ladyada commented Oct 16, 2020

thanks for testing :)

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 20, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_MAX31856 to 0.9.3 from 0.9.2:
  > Update max31856_simpletest.py

Updating https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx to 2.4.2 from 2.4.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_MCP230xx#35 from shadowclaw/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8591 to 1.0.2 from 1.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PCF8591#2 from Techwolfy/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_SHTC3 to 1.0.3 from 1.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_SHTC3#3 from Cybot101/sleepy-reset-fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.9.2 from 2.9.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#93 from eteq/add-init
@laurastephsmith
Copy link

Hi, is this fix included in the version of the SHTC3 driver in adafruit-circuitpython-bundle-6.x-mpy-20201210? I'm using it on an Unexpected Maker FeatherS2 and it isn't happy after a soft reset. I can post example code if needed?

@ladyada
Copy link
Member

ladyada commented Dec 12, 2020

yeah it was included...you could also try grabbing the .py file from this release to be absolutely sure. posting an example would help!

@laurastephsmith
Copy link

Thanks, good to know it's supposed to work! I've just tried the .py from this release, but it behaves the same.

My code:

import busio
import time

import adafruit_shtc3

i2c = busio.I2C(board.SCL, board.SDA)
sht = adafruit_shtc3.SHTC3(i2c)
while True:
    print(sht.temperature)
    time.sleep(1)

Running on this Feather:

>>> print(os.uname())
(sysname='esp32s2', nodename='esp32s2', release='6.1.0', version='6.1.0-beta.2
    on 2020-12-03', machine='FeatherS2 with ESP32S2')

Outputs this (my house isn't this hot, it's on my leg!):

25.48
25.52
25.57

I press ctrl+s and it then outputs:

Code done running. Waiting for reload.
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
  File "code.py", line 8, in <module>
  File "adafruit_shtc3.py", line 89, in __init__
ValueError: No I2C device at address: 70

I'm trying to replicate it on this Feather M0 Express:

>>> print(os.uname())
(sysname='samd21', nodename='samd21', release='6.0.0', version='6.0.0 on 2020-11-16',
    machine='Adafruit Feather M0 Express with samd21g18')

But I get:

code.py output:
Traceback (most recent call last):
  File "code.py", line 5, in <module>
  File "adafruit_shtc3.py", line 39, in <module>
MpyError: Incompatible .mpy file. Please update all .mpy files. See
    http://adafru.it/mpy-update for more info.

Which doesn't make much sense to me because the bootloader and the library are both 6.x.x. But I'm only on my first day of using CircuitPython, so I have a lot to learn!

If it's relevant, I'm using Mu 1.1.0.alpha2 on Win 10.

@laurastephsmith
Copy link

Okay, I've updated adafruit_bus_device on the M0 Express and I'm in business. The SHTC3 soft reset works on it! So the problem is specific to the FeatherS2.

@ladyada
Copy link
Member

ladyada commented Dec 13, 2020

hmm! yeah the esp32s2 is very new, can you post an issue over on the https://github.com/adafruit/circuitpython repo?

@laurastephsmith
Copy link

Will do, thanks for your help @ladyada :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants