Hi Karan,
The sensor is new. Never got a correct/stable reading at day with it!
During night, I get stable readings at 1-1.1 lux (ambient=34-35, IR=2) – this is not 0 as the Grove RGB LED’ backlight nearby provides some light.
Collected the following log this morning. Sun rises at 07:12:
[04/03/2016 06:20:06] Ambient 34/34, ir 2/2, lux 1.000000
[04/03/2016 06:21:23] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:22:41] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:23:58] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:25:15] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:26:33] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:27:50] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:29:08] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:30:25] Ambient 36/36, ir 2/2, lux 1.100000
[04/03/2016 06:31:42] Ambient 36/36, ir 2/2, lux 1.100000
[04/03/2016 06:33:00] Ambient 36/36, ir 3/3, lux 1.100000
[04/03/2016 06:34:17] Ambient 37/37, ir 3/3, lux 1.100000
[04/03/2016 06:35:38] Ambient 37/37, ir 3/3, lux 1.100000
[04/03/2016 06:36:55] Ambient 39/39, ir 3/3, lux 1.200000
[04/03/2016 06:38:13] Ambient 40/40, ir 3/3, lux 1.200000
[04/03/2016 06:39:30] Ambient 42/42, ir 4/4, lux 1.200000
[04/03/2016 06:40:47] Ambient 44/44, ir 4/4, lux 1.300000
[04/03/2016 06:42:05] Ambient 47/47, ir 5/5, lux 1.400000
[04/03/2016 06:43:22] Ambient 51/51, ir 6/6, lux 1.500000
[04/03/2016 06:44:40] Ambient 57/57, ir 7/7, lux 1.600000
[04/03/2016 06:45:57] Ambient 65/65, ir 9/9, lux 1.800000
[04/03/2016 06:47:14] Ambient 75/75, ir 12/12, lux 2.000000
[04/03/2016 06:48:32] Ambient 89/89, ir 16/16, lux 2.300000
[04/03/2016 06:49:49] Ambient 108/108, ir 22/22, lux 2.700000
[04/03/2016 06:51:07] Ambient 133/133, ir 30/30, lux 3.200000
[04/03/2016 06:52:24] Ambient 164/164, ir 40/40, lux 3.800000
[04/03/2016 06:53:41] Ambient 202/202, ir 51/51, lux 4.600000
[04/03/2016 06:54:59] Ambient 254/254, ir 67/67, lux 5.700000
[04/03/2016 06:56:16] Ambient 16129/16129, ir 86/86, lux 507.400000
[04/03/2016 06:57:33] Ambient 35585/35585, ir 107/107, lux 1120.300000
[04/03/2016 06:58:51] Ambient 58881/58881, ir 132/132, lux 1854.100000
[04/03/2016 07:00:08] Ambient 23298/23298, ir 165/165, lux 732.500000
[04/03/2016 07:01:26] Ambient 2307/2307, ir 230/230, lux 67.200000
[04/03/2016 07:02:43] Ambient 61699/61699, ir 18433/18433, lux 1269.300000
[04/03/2016 07:04:00] Ambient 51972/51972, ir 38145/38145, lux 129.400000
[04/03/2016 07:05:18] Ambient 26373/26373, ir 45057/45057, lux 0.000000
[04/03/2016 07:06:35] Ambient 64005/64005, ir 50945/50945, lux 87.900000
[04/03/2016 07:07:53] Ambient 34822/34822, ir 56577/56577, lux 0.000000
[04/03/2016 07:09:10] Ambient 58886/58886, ir 57601/57601, lux 49.300000
[04/03/2016 07:10:27] Ambient 14087/14087, ir 57857/57857, lux 0.000000
[04/03/2016 07:11:45] Ambient 52999/52999, ir 1794/1794, lux 1642.000000
[04/03/2016 07:13:02] Ambient 53512/53512, ir 26370/26370, lux 507.400000
[04/03/2016 07:14:22] Ambient 41738/41738, ir 17667/17667, lux 572.000000
[04/03/2016 07:15:40] Ambient 21260/21260, ir 61699/61699, lux 0.000000
[04/03/2016 07:16:57] Ambient 53772/53772, ir 52483/52483, lux 45.300000
[04/03/2016 07:18:14] Ambient 64525/64525, ir 5124/5124, lux 1922.200000
As you can see, as soon as enough light comes in (even before official sunrise time), readings are random.
As for i2cdetect:
# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 03 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3e --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- 62 -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
#
I took a very quick look at code provided by Seeed: https://github.com/Seeed-Studio/Grove_Digital_Light_Sensor/blob/master/Digital_Light_TSL2561.cpp
It’s a bit different than the one in your repository: https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_i2c_digital_light_sensor/grove_i2c_digital_light_sensor.py
One thing that did struck me is that they are using an integration time of 13ms, while the python version is using 402ms. I didn’t read the sensor specs to really understand what that means, but maybe some register is overflowing when using 402ms?
The Seeed version is using low gain mode only, while the python version tries both low & high. However, bad readings happen also in low gain mode.
The .cpp lib doesn’t seem complex. Might rewrite it in python if I can spare some time and see if it solves the issue.