micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
mnvk52
Posts: 11
Joined: Sat Sep 05, 2020 5:31 pm

micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by mnvk52 » Sat Sep 05, 2020 6:10 pm

I have a TSL2561 sensor connected to an ESP32.
Trying to read it with: https://github.com/adafruit/micropython ... it-tsl2561

My simple readout script is

Code: Select all

import tsl2561
from machine import I2C, Pin
i2c = I2C(scl=Pin(22), sda=Pin(21))
sensor = tsl2561.TSL2561(i2c)
print(sensor.read())
The result is

Code: Select all

%Run sensor_tls2561.py
Traceback (most recent call last):
  File "/home/sensor_tls2561.py", line 5, in <module>
  File "tsl2561.py", line 47, in __init__
  File "tsl2561.py", line 104, in sensor_id
  File "tsl2561.py", line 66, in _register8
OSError: [Errno 19] ENODEV
I don't know what's wrong?

Online
User avatar
Roberthh
Posts: 2441
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by Roberthh » Sat Sep 05, 2020 8:03 pm

The code cannot access the device. Typical reasons:
a) wrong device address. The default here is 0x39 or 57 decimal. According to the data sheet, alternative address values are 41 decimal or 73 decimal. What is the result of i2c.scan()? If i2c.scan() fails, it is a ....
b) Problem with wiring. Does you sensor have built-in pull-up resistors. If not, you have to add them to both sda and scl. Values between 2.2kOhm and 10 kOhm are fine.

mnvk52
Posts: 11
Joined: Sat Sep 05, 2020 5:31 pm

Re: micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by mnvk52 » Sat Sep 05, 2020 8:41 pm

i2c.scan shows

Code: Select all

i2c.scan()
[41]

Online
User avatar
Roberthh
Posts: 2441
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by Roberthh » Sun Sep 06, 2020 5:54 am

In that case you have to use that address:

Code: Select all

import tsl2561
from machine import I2C, Pin
i2c = I2C(scl=Pin(22), sda=Pin(21))
sensor = tsl2561.TSL2561(i2c, i2c_address=41)
print(sensor.read())

mnvk52
Posts: 11
Joined: Sat Sep 05, 2020 5:31 pm

Re: micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by mnvk52 » Sun Sep 06, 2020 8:17 am

Now I have a new error message

Code: Select all

%Run sensor_tls2561.py
Traceback (most recent call last):
  File "/home/sensor_tls2561.py", line 4, in <module>
TypeError: unexpected keyword argument 'i2c_address'

Online
User avatar
Roberthh
Posts: 2441
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by Roberthh » Sun Sep 06, 2020 8:28 am

OK. I should have looked into the code. it's

sensor = tsl2561.TSL2561(i2c, address=41)

mnvk52
Posts: 11
Joined: Sat Sep 05, 2020 5:31 pm

Re: micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by mnvk52 » Sun Sep 06, 2020 8:37 am

Thank you :)

Code: Select all

%Run sensor_tls2561.py
164.9236

mnvk52
Posts: 11
Joined: Sat Sep 05, 2020 5:31 pm

Re: micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by mnvk52 » Sun Sep 06, 2020 9:40 am

I just saw that micropython-adafruit-tsl2561 library is not supported anymore.
Now there is a circuitpython driver: https://github.com/adafruit/Adafruit_Ci ... on_TSL2561

Would you recommend to use that one instead?
I'm using a https://joy-it.net/en/products/SBC-NodeMCU-ESP32
I can't find a circuitpython version for that device: https://circuitpython.org/downloads
Is it possible to install circuitpython on ESP32

Online
User avatar
Roberthh
Posts: 2441
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: micropython-adafruit-tsl2561: OSError: [Errno 19] ENODEV

Post by Roberthh » Sun Sep 06, 2020 9:49 am

The circuitpython driver will not work with micropython out-of-the-box, because they changed the I2C interface. You can change that back, if you like. But if the actual drive works, you canstick with that.

There is no circuitpython support for ESP32 any more. They had a version for a while but abandoned that. Adafruit now only supports devices with a built-in USB interface, that can operate a a mass storage device. If a newer EP32 wil have that, adafruit might take it into their device set.

Post Reply