0

TSL2561 and Raspberry Pi
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: TSL2561 and Raspberry Pi

by vannimb on Thu Jan 29, 2015 3:04 pm

Dear Oxidizer,
i modified the file as you suggested and now looks like:

# blacklist spi and i2c by default (many users don't need them)

blacklist spi-bcm2708
#blacklist i2c-bcm2708
blacklist snd-soc-pcm512x
blacklist snd-soc-wm8804

However after loading:
sudo modprobe i2c-dev
sudo modprobe i2c-bcm2708

the result is always the same:

pi@RASPBERRY-A1 ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

any other hint/idea?

Many thanks for your cooperation.

vannimb
 
Posts: 11
Joined: Thu Jan 29, 2015 4:52 am

Re: TSL2561 and Raspberry Pi

by oxidizer on Thu Jan 29, 2015 4:08 pm

That stinks. I also commented out spi in my blacklist file. I don't know if that will do it however.

Do you have another i2c device you can try? Like an LCD shield or another sensor... If you can get something else to give you an i2c number then you can rule out a software issues with i2c devices.

You might also look into pull up/pull down resistors on for the 2561. Look a the data sheet for the sensor. I think it shows a schematic for a pull-up/down resistor. Maybe that will help.

oxidizer
 
Posts: 7
Joined: Thu Nov 15, 2012 1:56 pm

Re: TSL2561 and Raspberry Pi

by vannimb on Thu Jan 29, 2015 5:07 pm

Dear Oxidizer,
even commenting the spi and rebooting no luck.
To put in place the pullup circuit described in the data sheet i do not have the capacitor.
Any suggestion of very cheap i2c device/sensor i could use for this?
Just FYI (i dont know if this has an impact or not) i currently have a display (hd44780) connected to the pi, one HC-SR04 (not working correctly anymore... i still have to figure out why... but i think i connected the wrong pin to 5 v....) and a dht22 sensor, no more than this :-)
Many thanks for your help.
Best regards

vannimb
 
Posts: 11
Joined: Thu Jan 29, 2015 4:52 am

Re: TSL2561 and Raspberry Pi

by oxidizer on Thu Jan 29, 2015 5:28 pm

According to this post it looks like the pull up resistor and cap are included in the board. So we can rule that out.
http://forums.adafruit.com/viewtopic.php?f=19&t=36070

None of those components you mentioned are i2c devices. So your best bet is to buy something. Maybe you should get a new TSL2561 just in case or try the newer TSL2591. This has the pull ups and can take 3-5 V inputs because the internal regulator. For something different, you could get BMP180 barometric pressure/temperature sensor for $10 at Adafruit. It also has pull up resistor and a level shifter built into it and can take 3-5V inputs. I have one of these running on my Pi and BeagleBoneBlack for over a year now without a problem. I've been meaning to try out the TSL2591 and see if it's better than the 2561, which I've use for a while now too.

One last thing you could try... if you have an Arduino laying around try connecting your TSL to it and see if you can get a reading.

Other than that, I'm out of ideas. Good luck and keep us posted.

oxidizer
 
Posts: 7
Joined: Thu Nov 15, 2012 1:56 pm

Re: TSL2561 and Raspberry Pi

by yz88 on Fri Jan 30, 2015 5:11 pm

that is that worked for me:

Add the following lines to /etc/modules:

Code: Select all | TOGGLE FULL SIZE
i2c-bcm2708
i2c-dev


Then reboot the system with sudo reboot

Check whether to modules are loaded

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ dmesg | grep i2c
[   15.831855] bcm2708_i2c_init_pinmode(1,2)
[   15.837658] bcm2708_i2c_init_pinmode(1,3)
[   15.847176] bcm2708_i2c bcm2708_i2c.1: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)
[   16.010398] i2c /dev entries driver
pi@raspberrypi ~ $
pi@raspberrypi ~ $ sudo lsmod | grep i2c
i2c_dev                 5769  0
regmap_i2c              1661  4 snd_soc_pcm512x,snd_soc_wm8804,snd_soc_core,snd_soc_tas5713
i2c_bcm2708             4943  0
pi@raspberrypi ~ $


The i2c-devices are listed in /dev/

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ ls -l /dev/i2c*
crw------- 1 root root 89, 1 Dez 28 22:47 /dev/i2c-1
pi@raspberrypi ~ $


change file permissions of the device file, so that pi kann access the device

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ sudo chmod o+rw /dev/i2c*
pi@raspberrypi ~ $ ls -l /dev/i2c*
crw----rw- 1 root root 89, 1 Dez 28 22:47 /dev/i2c-1
pi@raspberrypi ~ $ ls -l


Edit the /etc/modprobe.d/raspi-blacklist.conf file, insert # in front of blacklist i2c-bcm2708 and blacklist spi-bcm2708

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ sudo cat /etc/modprobe.d/raspi-blacklist.conf
# blacklist spi and i2c by default (many users don't need them)
 
#blacklist spi-bcm2708
#blacklist i2c-bcm2708
pi@raspberrypi ~ $


install i2c tools

Code: Select all | TOGGLE FULL SIZE
sudo apt-get install python-smbus
sudo apt-get install i2c-tools


check available i2c adapters

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ sudo i2cdetect -l
i2c-1   i2c             bcm2708_i2c.1                           I2C adapter
pi@raspberrypi ~ $


add pi to user group i2c

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ sudo adduser pi i2c
Füge Benutzer »pi« der Gruppe »i2c« hinzu ...
Benutzer pi wird zur Gruppe i2c hinzugefügt.
Fertig.
pi@raspberrypi ~ $


check connected i2c devices, TSL2561 sensor uses i2c address 0x39, if wired as master

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- 39 -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi ~ $

yz88
 
Posts: 3
Joined: Mon Dec 29, 2014 10:01 am

Re: TSL2561 and Raspberry Pi

by vannimb on Sat Jan 31, 2015 10:44 am

Dear xy88,
i folowed your guide step step and unfortunately same result...

pi@RASPBERRY-A1 ~ $ sudo i2cdetect -l
i2c-1 i2c bcm2708_i2c.1 I2C adapter
pi@RASPBERRY-A1 ~ $ sudo adduser pi i2c
Adding user `pi' to group `i2c' ...
Adding user pi to group i2c
Done.
pi@RASPBERRY-A1 ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@RASPBERRY-A1 ~ $


at this point i have a doubt on the wiring... i connected directly the sensor SDA pin pint to the reaspberry SDA and same for the SCL pin.
is it correct?

Best regards

vannimb
 
Posts: 11
Joined: Thu Jan 29, 2015 4:52 am

Re: TSL2561 and Raspberry Pi

by vannimb on Sat Jan 31, 2015 3:25 pm

Just one last thing.... checking the envelope the sensor has arrived it says: TSL2562 Lux 5v
Does thi means it should be powered with 5V instead of 3.3?
in the past i accidentally powered the sensor with 5v... couldthis have damaged the sensor?
Best regards
Attachments
IMG_5135.JPG
IMG_5135.JPG (525.47 KiB) Viewed 838 times

vannimb
 
Posts: 11
Joined: Thu Jan 29, 2015 4:52 am

Re: TSL2561 and Raspberry Pi

by ht96 on Sun Feb 01, 2015 7:53 am

Hello everybody,

I have bought a TSL2561 and got it online with my raspberry pi. I started gathering the light information of a room in my house and here is the result of the last 12 hours. The values are very different and I don't understand them really. Did you have similar experiments or is something wrong with my construct?

Thanks you in advance

Code: Select all | TOGGLE FULL SIZE
22:50:01
High  4.77297680005  Low  4.96868585491  Auto  4.77297680005
23:00:01
High  4.96868585491  Low  4.96868585491  Auto  4.89955487907
23:10:02
High  4.86495804954  Low  4.96868585491  Auto  4.86495804954
23:30:02
High  4.89955487907  Low  4.96868585491  Auto  4.89955487907
00:00:01
High  4.89955487907  Low  4.96868585491  Auto  4.89955487907
00:30:01
High  4.89955487907  Low  4.96868585491  Auto  4.89955487907
01:00:01
High  4.89955487907  Low  4.96868585491  Auto  4.89955487907
01:30:02
High  0.260400890578  Low  0.01248  Auto  0.260400890578
02:00:02
High  0.260400890578  Low  0.01248  Auto  0.260400890578
02:30:01
High  0.220775721495  Low  0.01248  Auto  0.220775721495
03:00:02
High  0.220775721495  Low  0.01248  Auto  0.281217370091
03:30:02
High  0.281217370091  Low  0.01248  Auto  0.281217370091
04:00:01
High  0.281217370091  Low  0.01248  Auto  0.281217370091
04:30:01
High  0.281217370091  Low  0.01248  Auto  0.281217370091
05:00:01
High  0.220775721495  Low  0.01248  Auto  0.281217370091
05:30:02
High  0.281217370091  Low  0.01248  Auto  0.281217370091
06:00:02
High  0.281217370091  Low  0.01248  Auto  0.281217370091
06:30:02
High  0.220775721495  Low  0.01248  Auto  0.281217370091
07:00:01
High  0.281217370091  Low  0.01248  Auto  0.220775721495
07:30:01
High  0.393269637179  Low  0.288944060847  Auto  0.393269637179
08:00:02
High  38.1219  Low  14.4616254641  Auto  46.1603
08:30:01
High  0  Low  8627.04729232  Auto  0
09:00:01
High  1983.4864954  Low  12761.4266972  Auto  1982.07222823
09:30:02
High  50.96182  Low  264.2848  Auto  46.96822
10:00:01
High  0  Low  2121.216  Auto  58.83124
10:30:01
High  10.78168  Low  4023.808  Auto  27.08888
11:00:01
High  325.464  Low  477.33088  Auto  0
11:30:02
High  0  Low  0  Auto  0
12:00:01
High  1463.52107896  Low  11405.1077556  Auto  0
12:30:01
High  110.1298  Low  3945.448  Auto  320.913779082

ht96
 
Posts: 2
Joined: Sun Feb 01, 2015 7:43 am

Re: TSL2561 and Raspberry Pi

by adafruit_support_mike on Sun Feb 01, 2015 11:27 pm

@vannimb: The TSL2561 can accept power at any level between 3v and 5v. Connecting it to a 5v power supply shouldn't hurt it.

@ht96: Post a photo of your hardware and connections and we'll take a look.

adafruit_support_mike
 
Posts: 55974
Joined: Thu Feb 11, 2010 2:51 pm

Re: TSL2561 and Raspberry Pi

by ht96 on Mon Feb 02, 2015 1:11 pm

Hello,
unfortunately I could not upload any images here. So the connection to my raspberry is as follow:
VIN -> GPIO 1
GND -> GPIO 6
SDA -> GPIO 3
SCL -> GPIO 5
Thank you in advance

ht96
 
Posts: 2
Joined: Sun Feb 01, 2015 7:43 am

Re: TSL2561 and Raspberry Pi

by vannimb on Mon Feb 02, 2015 3:19 pm

Dear Mike,
i made another test, i rebooted the raspberry without the sensor connected and:
Code: Select all | TOGGLE FULL SIZE
pi@RASPBERRY-A1 ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --



i guess is about a software issue more then a hardware one... any idea what i could try to make it work?
Best regards

vannimb
 
Posts: 11
Joined: Thu Jan 29, 2015 4:52 am

Re: TSL2561 and Raspberry Pi

by yz88 on Mon Feb 02, 2015 3:41 pm

Hi vannimb,

do you have soldered the connection to the sensor? At the beginning I had some connection issues because I did not had a solid connection to the circuit board of the sensor.

yz88
 
Posts: 3
Joined: Mon Dec 29, 2014 10:01 am

Re: TSL2561 and Raspberry Pi

by vannimb on Mon Feb 02, 2015 4:07 pm

Dear yz88,
here you can find the pictures of the soldering and the connections to the breadboard.
do you see any mistake?
Best regards
Attachments
IMG_5152.JPG
IMG_5152.JPG (641.93 KiB) Viewed 803 times
IMG_5151.JPG
IMG_5151.JPG (410.49 KiB) Viewed 803 times
IMG_5150.JPG
IMG_5150.JPG (429.68 KiB) Viewed 803 times

vannimb
 
Posts: 11
Joined: Thu Jan 29, 2015 4:52 am

Re: TSL2561 and Raspberry Pi

by adafruit_support_mike on Tue Feb 03, 2015 3:15 am

Those joints need some work.

Check out out Guide to Excellent Soldering for tips on how to get good connections:
https://learn.adafruit.com/adafruit-gui ... -soldering

adafruit_support_mike
 
Posts: 55974
Joined: Thu Feb 11, 2010 2:51 pm

Re: TSL2561 and Raspberry Pi

by cisko on Mon Feb 09, 2015 4:27 pm

schwabbbel wrote:Hi there,
In order to get a python library for the TSL2561 for the Raspberry Pi quickly, I tried a different approach:
I translated the Adafruit Arduino library from C++ to python. I was hoping to avoid to think too much about the logic, i2c-communication and all the bits and bytes.
The Arduino library is intended to work with the "Adafruit unified sensor driver". I didn't see an equivalent for the RPi. So I didn't translate that part and left it commented out.
Because you can't pass variables by reference in Python (At least I don't know how), I added the attributes _ir, _broadband. Also the attributes _debug and _i2c were added. Now instead of passing variables by reference the attributes get updated.

The script is still pretty rough. There is also some leftover C++ code. But it works, at least for me:
EDIT : The solution for nodeJS is that you need to edit privilege of i2c device with :
sudo chmod o+rw /dev/i2c*
sudo adduser pi i2c
For completeness: I found other solutions for the TSL2561 and RPi:
https://github.com/janheise/TSL2561
http://www.raspberrypi.org/phpBB3/viewt ... 8&p=401408
But those didn't work for me.

I hope you can use the code. I hope further that I'll find some time to clean up the script.

-Mario

Hi,
I was looking for a script in nodeJS but node package work not correctly.
I found this topic and particularly your script that permit me to test my light sensor and the wiring.

I had some problems with your python script when I set integration time or gain. After setting these timing, sensor return 0 for full or IR.
I resolve the problem by adding a sleep time at the end of the setIntegrationTime/setGain function. Sleep time is 0.8 second and work fine. I haven't try lower value.


Now, I'm going to adapt your script to find what wrong with node package. Unless somebody help me ;-)
EDIT:with i2c npm, you need to add privilege, I haven't seen that in sensor_tsl2561
sudo chmod o+rw /dev/i2c*
sudo adduser pi i2c

cisko
 
Posts: 1
Joined: Mon Feb 09, 2015 3:12 pm

Please be positive and constructive with your questions and comments.