LTR390, OSError: [Errno 116] ETIMEDOUT

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mousethief
 
Posts: 17
Joined: Mon Mar 08, 2021 12:20 pm

LTR390, OSError: [Errno 116] ETIMEDOUT

Post by mousethief »

On a QT Py 2040 with CPy 7.0 I get this error:

Code: Select all

Traceback (most recent call last):                                                            
  File "code.py", line 36, 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                                                                
With this code:

Code: Select all

# Let's see what we have here

import board
import busio
import time

#Stemma QT port on QTPy 2040
#i2c_stemma_bus = busio.I2C(board.SCL1, board.SDA1)

#I2C pins on QTPy 2040, single I2C port on other boards
info_i2c_port = 0
try:
	i2c_stemma_bus = busio.I2C(board.SCL, board.SDA)
except RuntimeError:
	i2c_stemma_bus = busio.I2C(board.SCL1, board.SDA1)
	info_i2c_port = 1

print("Using i2c port ", info_i2c_port)

# Using to check the i2c wiring, since I'm using these two sensors
# together anyway.

import adafruit_htu31d
temp_light = 0
try:
	temp_light = adafruit_htu31d.HTU31D(i2c_stemma_bus, 0x40)
except ValueError:
	print("HTU31D sensor on 0x40 not attached.")

if(temp_light):
	print("HTU31D sensor on 0x40 found.")

import adafruit_ltr390
light_sens = 0
try:
	light_sens = adafruit_ltr390.LTR390(i2c_stemma_bus)
except ValueError:
	print("LTR390 sensor not attached.")

if(light_sens):
	print("LTR390 sensor found.")

while True:
	if(temp_light):
		print("HTU31D temperature: %0.1f C" % temp_light.temperature,
			"HTU31D humidity: %0.1f %%" % temp_light.relative_humidity)
	if(light_sens):
		print("UV:  ", light_sens.uvs, "Ambient Light: ", light_sens.light)
	time.sleep(1)
I have done the following tests:

CPy 7.0 on NRF52840 Feather Sense: Code runs as expected
CPy 7.0 on QTPy M0 Haxpress: Memory error (as expected)
CPy 7.0 on QTPy RP2040: ETIMEOUT error
CPy 7.1b on QTPy RP2040: ETIMEOUT error
CPy 6.3 on QTPy RP2040: Code runs as expected

(Was going to ask the OP of viewtopic.php?f=60&t=178596 to try changing CPy version, but topic is locked)

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: LTR390, OSError: [Errno 116] ETIMEDOUT

Post by mikeysklar »

Do you need to uncomment this line:

Code: Select all

i2c_stemma_bus = busio.I2C(board.SCL1, board.SDA1)

User avatar
mousethief
 
Posts: 17
Joined: Mon Mar 08, 2021 12:20 pm

Re: LTR390, OSError: [Errno 116] ETIMEDOUT

Post by mousethief »

mikeysklar wrote:Do you need to uncomment this line:

Code: Select all

i2c_stemma_bus = busio.I2C(board.SCL1, board.SDA1)
No, it's there in the try/except block.
Hm. Okay, so my error checking isn't the best. The code is checking for a 'no pullup' condition, which on an RP2040 would imply the modules are connected to the second bus.

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: LTR390, OSError: [Errno 116] ETIMEDOUT

Post by adafruit2 »

this isnt a good idea and could be making it hard for you to debug you setup!

User avatar
mousethief
 
Posts: 17
Joined: Mon Mar 08, 2021 12:20 pm

Re: LTR390, OSError: [Errno 116] ETIMEDOUT

Post by mousethief »

adafruit2 wrote:this isnt a good idea and could be making it hard for you to debug you setup!
Sorry, confused. What isn't a good idea? ('this' is ambiguous)
Error checking?
Using the STEMMA port on a QTPy 2040?
Writing portable code? (I could understand if I'm Doing It Wrong)
Something else?

User avatar
adafruit2
 
Posts: 22148
Joined: Fri Mar 11, 2005 7:36 pm

Re: LTR390, OSError: [Errno 116] ETIMEDOUT

Post by adafruit2 »

using a try/except to determine which port to use. you should use os.uname!
https://github.com/adafruit/Adafruit_Ci ... t__.py#L11

User avatar
mousethief
 
Posts: 17
Joined: Mon Mar 08, 2021 12:20 pm

Re: LTR390, OSError: [Errno 116] ETIMEDOUT

Post by mousethief »

Whilst working on coding idiom I shall report that the Feather RP2040 behaves the same as the QT Py RP2040, that is the LTR390 sensor produces an ETIMEDOUT with CPy 7.x but works as expected on CPy 6.3

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: LTR390, OSError: [Errno 116] ETIMEDOUT

Post by mikeysklar »

@mousethief,

Your finding that about ETIMEOUT occuring with 7.x and not 6.3 is relevant. Would you mind opening an issue with the github repo?

https://github.com/adafruit/Adafruit_LT ... is%3Aissue

Please submit the example code and if possible confirm that the same behavior is in the 7.1.0 beta0 plus latest 7.x library drop.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”