-
Notifications
You must be signed in to change notification settings - Fork 20
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
Allow setting I2C bus speed #36
Comments
The library is using Is there a data sheet that confirms it's 100kHz only, i.e. to rule out this being a transmission line or pull-up issue? |
The datasheets for the CLUE sensors permit 100kHz. I used it on my cutebot library and had no problems. Also, micro:bit devices also expect a 100kHz i2c connection and it would be nice not to have to use an edited version of the repository to get them to work. |
This raises the question about specification / "plug and play" for STEMMA. If there's no feature for an i2c host to detect/adapt the i2c speed when one slave device isn't capable of that speed then perhaps it needs to be lowest common denominator for a bus with external connectivity. Hot swapping is another factor to take into account here. |
arduino is 100khz default, im ok making circuitpython 100khz default too |
Should we make it happen at the CP level then? If so, we could close this and open a new issue over there to change current 400kHz default: |
@tannewt any reason not to change default to match arduino's 100khz? |
On a related note, would be useful to be able to query the frequency of an i2c object. It doesn't look like it's visible on
|
If the default becomes 100Hz what would be the mechanism for a user to change it to 400Hz for |
for the few that have embedded I2C() we'd have a kwarg on initialization. boot.py is not appropriate |
hmm...might need something other than a kwarg since the library creates an instance internally? Adafruit_CircuitPython_CLUE/adafruit_clue.py Line 976 in 3a29b2f
|
The busio.I2C constructor default or the speed of board.I2C()?
Libraries should only use |
both - the i2c standard is 'technically' 100khz - 400khz is 'speedy' and is not guaranteed the same way |
How does that work for libraries like this one ( |
We need to add an option i2c argument here: https://github.com/adafruit/Adafruit_CircuitPython_CLUE/blob/master/adafruit_clue.py#L203-L206 |
What's the |
Greater that 100khz is technically out of the original spec. Background here: adafruit/Adafruit_CircuitPython_CLUE#36
PR created for CircuitPython: adafruit/circuitpython#3471 |
We'll either have to remove that or not use the Clue object at all. At some point, these high level libraries aren't the right way of doing advanced things. |
Another datapoint, the Cytron Edu:bit works for a short period at 400kHz and then gives a wide range of errors in CircuitPython after an unpredictable number of i2c operations. Oddly both require a power cycle to revert to normal operation. |
A bit more peripheral information. One interesting, subtle change on the V2 micro:bit is there are two i2c buses: an internal one for onboard devices and an external one presented on the edge connector: https://tech.microbit.org/latest-revision/ |
I think maybe we can close this? The fix was implemented at the CP level. |
It struck me today that these mismatches are trivial to detect and prevent in the libraries. I posted Adafruit Forums: Checking current i2c speed in libraries against each device to discuss this. |
Currently the default of 400kHz is being used. This is fine for all the on board sensors, but some external sensors may require slower speeds. For example, the PM25:
https://github.com/adafruit/Adafruit_CircuitPython_PM25/blob/0940f715aa29f965f2b18339ae57b4cd7c03921d/examples/pm25_simpletest.py#L39
which can cause issues:
https://forums.adafruit.com/viewtopic.php?f=65&t=169662
Suggest adding a new kwarg to init to allow specifying I2C bus speed. Default it to a conservative 100kHz.
The text was updated successfully, but these errors were encountered: