-
Notifications
You must be signed in to change notification settings - Fork 6
Changes on the _chip_id #9
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
Conversation
Before PR:
After PR:
|
oof i feel like its risky to reset the chip when asking for the ID - the right thing to do is not let folks call _chip_id? we could remove the funciton |
@anecdata Thank you for testing :)
We already reset the sensor to get the ID number and verify that is in the I2C bus in the class constructor that is how I arrive to this proposal, but I could change the PR to remove the _chip_id function. Let me know. and thanks :) |
yeah we should just move the chip id grabber into the init code |
will do Thanks |
This is my interpretation of the requested changes. Resetting the board with the sensor still work, open the possibility to remove the red warning in the learning guide. (to be tested by the person that made that guide) Adafruit CircuitPython 6.2.0-beta.3-188-g05ed179e1 on 2021-03-15; Adafruit Feather RP2040 with rp2040
>>> import time
>>> import busio
>>> import board
>>> import adafruit_shtc3
>>>
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> sht = adafruit_shtc3.SHTC3(i2c)
>>>
>>> dir(sht)
['__class__', '__dict__', '__init__', '__module__', '__qualname__', 'i2c_device', 'reset', 'temperature', '_buffer', 'low_power', 'sleeping', '_chip_id', '_get_chip_id', '_write_command', '_cached_sleep', '_low_power', 'relative_humidity', 'measurements', '_crc8']
>>> Also tested with the simpletest Adafruit CircuitPython 6.2.0-beta.3-188-g05ed179e1 on 2021-03-15; Adafruit Feather RP2040 with rp2040
>>> import shtc3_simpletest
Temperature: 25.1 C
Humidity: 43.7 %
Temperature: 25.2 C
Humidity: 43.7 %
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "shtc3_simpletest.py", line 17, in <module>
KeyboardInterrupt:
>>> However one last thing, not getting the device id as @anecdata I am getting >>> sht._chip_id
2183 |
you are right, 🤦🏼 , I changed the logic to get the right chip identifier. Adafruit CircuitPython 6.2.0-beta.3-188-g05ed179e1 on 2021-03-15; Adafruit Feather RP2040 with rp2040
>>> import time
>>> import busio
>>> import board
>>> import adafruit_shtc3
>>>
>>> i2c = busio.I2C(board.SCL, board.SDA)
>>> sht = adafruit_shtc3.SHTC3(i2c)
>>>
>>> sht._chip_id
2055
>>> 2055 =
|
Updating https://github.com/adafruit/Adafruit_CircuitPython_PCT2075 to 1.1.9 from 1.1.8: > Merge pull request adafruit/Adafruit_CircuitPython_PCT2075#16 from jposada202020/improving_docs > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_SHTC3 to 1.1.0 from 1.0.6: > Merge pull request adafruit/Adafruit_CircuitPython_SHTC3#9 from jposada202020/using_reset Updating https://github.com/adafruit/Adafruit_CircuitPython_Thermistor to 3.3.6 from 3.3.5: > Merge pull request adafruit/Adafruit_CircuitPython_Thermistor#16 from jposada202020/improving_docs > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font to 1.4.1 from 1.4.0: > Merge pull request adafruit/Adafruit_CircuitPython_Bitmap_Font#44 from jposada202020/Including_examples_in_the_API Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Adafruit to 1.3.0 from 1.2.4: > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Adafruit#12 from dhalbert/init-entry > "Increase duplicate code check threshold " Updating https://github.com/adafruit/Adafruit_CircuitPython_LIFX to 1.10.0 from 1.9.5: > Merge pull request adafruit/Adafruit_CircuitPython_LIFX#11 from todbot/master > "Increase duplicate code check threshold "
This is an attempt to solve #8.
When troubleshooting this, I found two solutions, first is removing the
@property
and using the_chip_id
as a normal function.However this solutions works better as we do not need to change the logic. I found that the problem was when trying to write .
This solve also the problem of resetting the device with the sensor connected as mention in the Adafruit earning guide.
As I cannot figure out why this work, please test, and feel free to reject this PR if this solution is not desired
I test this on