Skip to content

LTR390 Fails to Init with RP2040 #11

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

Closed
jknappatdirigible opened this issue Nov 27, 2021 · 5 comments
Closed

LTR390 Fails to Init with RP2040 #11

jknappatdirigible opened this issue Nov 27, 2021 · 5 comments
Assignees

Comments

@jknappatdirigible
Copy link

I am trying to integrate the LTR390 with a Feather RP2040 but the device is failing to initialize. I am running Circuitpython 7.0.0 (adafruit-circuitpython-adafruit_feather_rp2040-en_US-7.0.0.uf2) and using the libraries from the latest Circuitpython bundle (adafruit-circuitpython-bundle-7.x-mpy-20211127).

The code I am running is as follows:

import board
import adafruit_ltr390

i2c = board.I2C()

ltr = adafruit_ltr390.LTR390(i2c)
print("UV:", ltr.uvs, "\t\tAmbient Light:", ltr.light)
print("UVI:", ltr.uvi, "\t\tLux:", ltr.lux)

And the error I'm receiving is:

code.py output:
Traceback (most recent call last):
  File "code.py", line 6, in <module>
  File "adafruit_ltr390.py", line 286, in __init__
  File "adafruit_ltr390.py", line 292, in initialize
  File "adafruit_ltr390.py", line 315, in _reset
  File "adafruit_register/i2c_bit.py", line 43, in __get__
OSError: [Errno 116] ETIMEDOUT

Code done running.

I have also attached a photo of my setup. You may notice that there are other sensors and boards connected to the Feather RP2040, but I have tried connecting the LTR390 directly to the RP2040 via STEMMA QT Cable. This didn't produce any positive change, however. Other things I have tried include:

  • Changing the cable
  • Using a spare RP2040 that was working with release 1.1.1
  • Wiring the VIN, GND, SCL, and SDA pins on the LTR390 to the appropriate pins on the RP2040
  • Using Circuitpython 7.1.0-beta.0

I have managed to get the code to execute successfully with a Feather M0 RFM95 LoRa Radio, so the problem appears to be specific to the RP2040.

Hope you can make more sense of this than I have so far. Please let me know if I can provide any additional info.

IMG_1356

@ladyada
Copy link
Member

ladyada commented Nov 27, 2021

@caternuson this is due to the LTR390 not acking the reset bit, @hathach just fixed this in arduino - most sensors don't just give up the ghost in the middle of a transaction :/
dupe of #6

@hathach
Copy link
Member

hathach commented Nov 29, 2021

from my testing with arduino after soft reset()

  • rp2040 can probably recover from 1 failure read()
  • nrf52 has permanent bus issue and requires i2c to be re-init

other mcus may/may not recover, though I think the "best-to-all" solution is just re-init I2C within the soft-reset, just to be safe. This can be done easily with arduino by calling end() then begin() https://github.com/adafruit/Adafruit_LTR390/pull/3/files#diff-2e600839f345eb79c6af9a2d512e9b212072006ae371f58f2817b6e60538a7f3R92

@caternuson
Copy link
Contributor

@hathach thanks for the input. i was thinking same here:

though I think the "best-to-all" solution is just re-init I2C within the soft-reset

I'll setup and test that on various MCU's and see how it plays.

@caternuson
Copy link
Contributor

@jknappatdirigible
Copy link
Author

This worked for me. Thank you for the quick fix, @caternuson

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

No branches or pull requests

4 participants