Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

Using TSL2591 with FT232H
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Using TSL2591 with FT232H

by houshun on Wed Mar 25, 2020 2:07 am

Hi all,

I am trying to use the TSL2591 high dynamic range digital light sensor with the FT232H breakout, USB to SPI, I2C, so that I can access the sensor via a usb interface.

I have tested the TSL2591 on an Arduino and it read fine. Now I have it hooked up to a FT232H (old versionwith micro usb) with D1 and D2 shorted for I2C operation. I followed the instruction here: https://learn.adafruit.com/circuitpython-on-any-computer-with-ft232h for installation of the CircuitPython, and the necessary libraries on Ubuntu 18.04.
I have verifed that pyftdi was installed properly and that the FT232H can be identified.

After setting the enviorment variable BLINKA_FT232H=1 before running tsl2591_simpletest.py. However I am recieving the following error message -

Traceback (most recent call last):
File "tsl2591_simpletest.py", line 14, in <module>
sensor = adafruit_tsl2591.TSL2591(i2c)
File "/usr/local/lib/python3.6/dist-packages/adafruit_tsl2591.py", line 115, in __init__
if self._read_u8(_TSL2591_REGISTER_DEVICE_ID) != 0x29:
File "/usr/local/lib/python3.6/dist-packages/adafruit_tsl2591.py", line 128, in _read_u8
i2c.write_then_readinto(self._BUFFER, self._BUFFER, out_end=1, in_end=1)
File "/usr/local/lib/python3.6/dist-packages/adafruit_bus_device/i2c_device.py", line 156, in write_then_readinto
in_end=in_end,
File "/home/seth_poh/.local/lib/python3.6/site-packages/busio.py", line 92, in writeto_then_readfrom
in_start=in_start, in_end=in_end, stop=stop)
File "/home/seth_poh/.local/lib/python3.6/site-packages/adafruit_blinka/microcontroller/ft232h/i2c.py", line 35, in writeto_then_readfrom
relax=True)
File "/home/seth_poh/.local/lib/python3.6/site-packages/pyftdi/i2c.py", line 181, in exchange
readlen, relax=relax)
File "/home/seth_poh/.local/lib/python3.6/site-packages/pyftdi/i2c.py", line 766, in exchange
self._do_prolog(i2caddress | self.BIT0)
File "/home/seth_poh/.local/lib/python3.6/site-packages/pyftdi/i2c.py", line 1014, in _do_prolog
self._send_check_ack(cmd)
File "/home/seth_poh/.local/lib/python3.6/site-packages/pyftdi/i2c.py", line 1046, in _send_check_ack
raise I2cNackError('NACK from slave')
pyftdi.i2c.I2cNackError: NACK from slave

I tried lowing the frequency all the way to 100 but the issue remains. Have anyone here worked with the same setup and saw the same issue but have solved it?

Thank you for you help.

houshun
 
Posts: 3
Joined: Wed Mar 25, 2020 1:41 am

Re: Using TSL2591 with FT232H

by adafruit_support_carter on Wed Mar 25, 2020 2:49 pm

It might be connection related. Can you post a photo of your setup showing how everything is wired together.

Just to make sure this combo would work, I set one up and tried it out. I used the old style FT232H and ran the same simpletest. I'm also on Ubuntu. It ran OK here:
Code: Select all | TOGGLE FULL SIZE
$ python3 tsl2591_simpletest.py
Total light: 0.0lux
Infrared light: 0
Visible light: 0
Full spectrum (IR + visible) light: 46599683
Total light: 395.100672lux
Infrared light: 711
Visible light: 46598972
Full spectrum (IR + visible) light: 46861852

so it doesn't seem software related.

adafruit_support_carter
 
Posts: 14872
Joined: Tue Nov 29, 2016 2:45 pm

Re: Using TSL2591 with FT232H

by houshun on Wed Mar 25, 2020 4:04 pm

Hi there,

Here's a picture of the connection to the FT232H -

IMG_20200326_034526.jpg
IMG_20200326_034526.jpg (376.38 KiB) Viewed 39 times


where the wires are connected to

Red - Vin
Black - Gnd
Brown - SCL
Green - SDA

of the TSL2519. I can't take a photo of the other end unfortunately, the TSL2519 is already install in a housing. But I would imagine the wiring is correct, since it worked on an Arduino. It also output an error saying no I2C device found at 0x29 address if I swap the brown and green wire.

The only extra thing I did was, the FT232H came with a blank eeprom. I flashed the eeprom with the steps described here https://forums.adafruit.com/viewtopic.php?f=19&t=160809

Thank you.

houshun
 
Posts: 3
Joined: Wed Mar 25, 2020 1:41 am

Re: Using TSL2591 with FT232H

by adafruit_support_carter on Wed Mar 25, 2020 4:25 pm

Thanks for the photo. Looks like you bridged D1/D2 using solder?

Do you have any other I2C devices that could be used to troubleshoot?

adafruit_support_carter
 
Posts: 14872
Joined: Tue Nov 29, 2016 2:45 pm

Re: Using TSL2591 with FT232H

by houshun on Wed Mar 25, 2020 4:42 pm

Yes, D1 and D2 are bridged with solder for I2C operation.

I have a few SRF02 ultrasonic sensors lying around. Just need to find them first,

houshun
 
Posts: 3
Joined: Wed Mar 25, 2020 1:41 am

Re: Using TSL2591 with FT232H

by adafruit_support_carter on Thu Mar 26, 2020 10:42 am

OK, let's use one of those, assuming they are I2C. Some of those are just basic digital pulse in / out, so please double check that. The idea is to sanity check the basic I2C functionality of the FT232H. Since it sounds like your TSL2519 is already installed into a larger assembly, we want to rule out it being anything related to that. So we just want FT232H -> some I2C sensor, with nothing else going on. And the ability to see and check all wiring between the two.

adafruit_support_carter
 
Posts: 14872
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.