A few days ago I have received my Grovepi+, which is connected to a Raspberry pi, model B+. The sensor is connected to I2C-2.
When I run the included Python script named grove_i2c_digital_light_sensor.py, it looks likes it s reporting random values.
Debug is off and see below for the results:
Can someone tell me what I do wrong?
sudo python grove_i2c_digital_light_sensor.py
Power ON
There is light:
ambient = 41549
IR = 6936
_ambient = 41549
_IR = 6936
Light = 1107.79945921 lux.
Power OFF
There is light:
ambient = 14413
IR = 56087
_ambient = 14413
_IR = 56087
Light = 0 lux.
Power OFF
There is light:
ambient = 59468
IR = 42519
_ambient = 59468
_IR = 42519
Light = 168.3056 lux.
Power OFF
There is light:
ambient = 24396
IR = 26391
_ambient = 24396
_IR = 26391
Light = 13.84188 lux.
Power OFF
There is light:
ambient = 16204
IR = 21015
_ambient = 16204
_IR = 21015
Light = 0.13052 lux.
Power OFF
There is light:
ambient = 37196
IR = 27927
_ambient = 37196
_IR = 27927
Light = 81.2912 lux.
Power OFF
There is light:
ambient = 9293
IR = 43031
_ambient = 9293
_IR = 43031
Light = 0 lux.
Power OFF
There is light:
ambient = 29005
IR = 54551
_ambient = 29005
_IR = 54551
Light = 0 lux.
Power OFF
Hey,
Looks like you are indeed using the I2C sensor rather than the normal digital light sensor. Currently GrovePi does not support it because we don’t have a library for it and this is the first time we have heard about that sensor too.
You can tell it’s an I2C sensor using two methods:
Check the pin labels - look for “SCL,SDA,VCC,GND”
SIG,NC,VCC,GND is a digital or analog module. (NC=not connected)
SCL,SDA,VCC,GND is an I2C module.
TX,RX,VCC,GND is a serial module.
DCKI,DI,VCC,GND is a digital module
Run the i2ctools command: i2cdetect -y 1
if you have an older pi, replace 1 with 0 for the older bus i2cdetect -y 0
Dear all,
I try to modify the GrovePi firmware in order to be able to read Lux value from this sensor. My trouble is how to send back value from GrovePi to the RaspberryPi. I found the example with the float for the DHT sensor.
The returned value is a long => 4 bytes. Then I was planned to use the code bellow in the GrovePi firmware:
signed long luxValue= TSL2561.readVisibleLux();
byte *b1=(byte*)&luxValue;
for(j=0;j<4;j++)
{
b[j+1]=b1[j];
}
But how to construct back in the python code in the raspberry pi.
Hey,
The Digital light sensor is an IC2C sensor and can be directly accessed from the Raspberry PI by writing a Python program. You don;t need to modify the firmware and can directly access the sensor.
Dear Karan,
Thank you for your answer. I know the digital light sensor could be dirctly interface from the raspberry pi. But in my project it would be better for me to integrate inside the grovepi firmware. By the way I found the solution.