Closed caternuson closed 2 years ago
Works OK on Itsy M4:
Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_mpl3115a2
>>> sensor = adafruit_mpl3115a2.MPL3115A2(board.I2C())
>>> sensor.pressure
100641.0
>>>
I think it's an RP2040 specific error, getting the same error on a Feather RP2040
Works on circuitpython 6.2 though.
@caecilliusinhorto can you try the very latest release?
Just tried with 7.2.0. Still looking sad :(
Adafruit CircuitPython 7.2.0 on 2022-02-24; Raspberry Pi Pico with rp2040
>>> import board
>>> import busio
>>> import adafruit_mpl3115a2
>>> scldata = board.GP7
>>> sdadata = board.GP6
>>> i2c = busio.I2C(scldata, sdadata)
>>> sensor = adafruit_mpl3115a2.MPL3115A2(i2c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_mpl3115a2.py", line 144, in __init__
File "adafruit_mpl3115a2.py", line 189, in _poll_reg1
File "adafruit_mpl3115a2.py", line 166, in _read_u8
File "adafruit_mpl3115a2.py", line 162, in _read_into
OSError: [Errno 116] ETIMEDOUT
>>>
Shows up in scan at least:
Adafruit CircuitPython 7.2.0 on 2022-02-24; Raspberry Pi Pico with rp2040
>>> import board
>>> import busio
>>> i2c = busio.I2C(board.GP7, board.GP6)
>>> i2c.try_lock()
True
>>> i2c.scan()
[96]
>>> i2c.scan()
[96]
>>>
@caternuson can ya try bitbangio and also dump a saleae trace for @dhalbert
A little closer with bitbang, but still has issues:
Adafruit CircuitPython 7.2.0 on 2022-02-24; Raspberry Pi Pico with rp2040
>>> import board
>>> import bitbangio
>>> import adafruit_mpl3115a2
>>> scldata = board.GP7
>>> sdadata = board.GP6
>>> i2c = bitbangio.I2C(scldata, sdadata)
>>> sensor = adafruit_mpl3115a2.MPL3115A2(i2c)
>>> sensor.pressure
101330.0
>>> sensor.temperature
last call is frozen, probably stuck on this wait loop: https://github.com/adafruit/Adafruit_CircuitPython_MPL3115A2/blob/fcd304ec51b8bb19161f36a05875abb00f3e0fad/adafruit_mpl3115a2.py#L252-L256
Will saleae next.
Switched back to hardware I2C for saleae testing and also simplified code a bit:
Adafruit CircuitPython 7.2.0 on 2022-02-24; Raspberry Pi Pico with rp2040
>>> import board
>>> import busio
>>> import adafruit_mpl3115a2
>>> i2c = busio.I2C(board.GP7, board.GP6)
>>> sensor = adafruit_mpl3115a2.MPL3115A2(i2c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_mpl3115a2.py", line 144, in __init__
File "adafruit_mpl3115a2.py", line 189, in _poll_reg1
File "adafruit_mpl3115a2.py", line 166, in _read_u8
File "adafruit_mpl3115a2.py", line 162, in _read_into
OSError: [Errno 116] ETIMEDOUT
>>>
Seems to be having issues coming back up after the software reset. There's an intentional 10ms delay after the reset:
but the first query attempt in _poll_reg1
fails:
@caternuson what if retry it? could be we have to 'wake up' the i2c?
Quick hack change:
# Poll for the reset to finish.
try:
self._poll_reg1(_MPL3115A2_CTRL_REG1_RST)
except:
self._poll_reg1(_MPL3115A2_CTRL_REG1_RST)
It at least can init the sensor:
Adafruit CircuitPython 7.2.0 on 2022-02-24; Raspberry Pi Pico with rp2040
>>> import board
>>> import busio
>>> import adafruit_mpl3115a2
>>> i2c = busio.I2C(board.GP7, board.GP6)
>>> sensor = adafruit_mpl3115a2.MPL3115A2(i2c)
>>>
Here's the trace: Second attempt is after the long SCL low period. Zooming in there: So it at least comes back to life that way.
Can also get a pressure reading, but temperature hangs same as above with bitbang:
>>> sensor = adafruit_mpl3115a2.MPL3115A2(i2c)
>>> sensor.pressure
101482.0
>>> sensor.temperature
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/adafruit_mpl3115a2.py", line 259, in temperature
File "/lib/adafruit_mpl3115a2.py", line 169, in _read_u8
File "/lib/adafruit_mpl3115a2.py", line 165, in _read_into
KeyboardInterrupt:
>>>
Here's saleae of the temperature read: It's stuck waiting for some status that never changes. Each attempt is this:
!? and the same exact code runs on an m4?
Interesting. It does not. The previous test earlier only grabbed pressure. But even Itsy M4 is hanging on temperature.
Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> import adafruit_mpl3115a2
>>> sensor = adafruit_mpl3115a2.MPL3115A2(board.I2C())
>>> sensor.pressure
101466.0
>>> sensor.temperature
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "adafruit_mpl3115a2.py", line 256, in temperature
KeyboardInterrupt:
>>>
Same I2C traffic:
So may be multiple issues happening:
temperature
Any progress on this issue? I am a HS teacher and just ran into this same issue on a RPi Pico running circuitpython 7.3.2. We transitioned over to the Pico from the Zero for the coming year due to supply chain issues. We were using the MPL3115A2 board in the curriculum before. Any advice (should we look at other altimeter options?) would be much appreciated.
@millerm22 Possibly resolved! Got a chance to take another look at this today and might have finally found the main issue. If you know how / want to test some PR code, proposed fix is here: https://github.com/adafruit/Adafruit_CircuitPython_MPL3115A2/pull/22
@millerm22 Possibly resolved! Got a chance to take another look at this today and might have finally found the main issue. If you know how / want to test some PR code, proposed fix is here: #22
Wow yall are awesome. Thanks so much for looking into this. I'd be happy to try out the new code, but I'm not sure how the process works. Will the updated code be rolled out in tomorrow's autorelease?
OK, went ahead and made a new release: https://github.com/adafruit/Adafruit_CircuitPython_MPL3115A2/releases/tag/2.0.0 So it should be in the next autorelease bundle.
@caternuson It works perfectly!! Thanks again for all of your help.
woot! awesome. glad that fixed it. thanks for letting us know. good luck with the class!
Re this thread: https://forums.adafruit.com/viewtopic.php?f=8&t=184555
Recreated: