Skip to content
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

Sense Hat V2 Colour/Light intensity sensor fix #126

Open
kal9001 opened this issue Nov 18, 2022 · 6 comments
Open

Sense Hat V2 Colour/Light intensity sensor fix #126

kal9001 opened this issue Nov 18, 2022 · 6 comments

Comments

@kal9001
Copy link

kal9001 commented Nov 18, 2022

The Raspberry Pi Documentation for the V2 sense hat shows they use a different sensor to the Astro Pi. Instead of the TCS34725 it uses the TCS3400 which sits at a different i2c address and with different registers for it's data.

I've seen the statement that sense hats don't have the light sensor and this is why there is a warning all the time. But I can physically see it, it's on the silk screen, and the RPi docs show it. So dug deeper and was able to confirm the different part number. It's possible that others do physically have this sensor but it won't work with the drivers as they are.

I've been able to fix this on my own machine by editing the sense hat library with the correct registers, gain options, and sensor ID, all changes are wholly within the colour.py file and it now works fine as best as I can tell.

I don't know enough about github to be able to make a code change suggestion. Also my change does not allow models with the older chip to work at all. It seems more sensible to do some kind of check to scan for the old device on i2c addr 29, or the new one at 39, but the added annoyance is that the TSC3400 does not initialise itself with a name or driver in /sys/bus/i2c/ but does appear on an i2cdetect.

For anyone interested the file with the new parameters is below.
colour.py.txt

@kal9001 kal9001 changed the title Colour/Light intensity sensor issue. Sense Hat V2 Colour/Light intensity sensor fix Nov 18, 2022
@bsimmo
Copy link

bsimmo commented Nov 18, 2022 via email

@G3zz
Copy link
Contributor

G3zz commented Nov 18, 2022

Thanks for creating the issue and sharing your fix.
To summarise the current situation:

  • V1 Sense Hat does not have a colour sensor
  • V2 Sense Hat (used in the Astro Pi challenge for several years) uses TCS34725.

Because of supply issues for the TCS34725, the "V2" sense hat available to buy uses the TSC3400. Arguably this is a different version entirely, but that's the situation!

As you suggest, the next steps are updating this library to detect which version of the light sensor is present 👍

**EDIT: this post has been edited because I originally said that the v1 HAT had a colour sensor - this is incorrect! **

@bsimmo
Copy link

bsimmo commented Nov 18, 2022 via email

@kal9001
Copy link
Author

kal9001 commented Nov 18, 2022

@bsimmo

available for the public to buy about a week ago. I guess the change of sensor is supply? (Pihut had them)

I got mine from PiHut and i apparently the only place that offers the V2 only, and don't have the V1 listed at all. It's a shame they didn't call it the V3 perhaps to avoid confusion with the Astro Pi version. Me and a friend figured the intent was to keep the same sensor and so the same name.

@G3zz

the next steps are updating this library to detect which version of the light sensor is present

I'm not sure how to do that, one easy thought is to simply change the SenseHat constructor to take an argument for which part it has, but it's more useful if the user doesn't need to know/care what chip it is.
Checking /sys/bus/i2c/1- folders with the device information, then the SenseHat driver could branch on if device 1-0029 or 1-0039 is present. However we found that the TCS3400 doesn't populate anything in this folder despite showing up on the bus. Is this some config that is missing from the i2c driver in linux/raspbian itself? If so, how and where to add this. I've tried a few searches but information seems thin on the ground.

@G3zz
Copy link
Contributor

G3zz commented Nov 23, 2022

Hi @kal9001 , I agree the user should not need to know the details of the chips in their hat - that would be too confusing.
I am in contact with RPL and they will update the i2c driver.

@tvoverbeek
Copy link
Contributor

See my PR #131 which solves this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants