Skip to content

Commit 5e2a86e

Browse files
committed
updates to light sensors
1 parent 4deb7b8 commit 5e2a86e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

LightSensors/APDS9301_basic/readme.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,14 @@ Sparkfun has a decent[ APDS9301 library](https://github.com/sparkfun/APDS-9301_B
66

77
If you change the integration time setting the sketch will change the delay for when it reads the sensor accordingly. Changing the integration time will change the values you get on channels 0 and 1, but it shouldn't make a huge difference in the overall lux reading. That reading is based on the ratio of CH0 to CH1, as described on page 4 of the [APS9301 datasheet](https://cdn.sparkfun.com/assets/3/2/c/0/8/AV02-2315EN0.pdf).
88

9-
If you change the gain settings, you should also see a change in the CH0 and CH1 readings, but not the overall lux reading.
9+
If you change the gain settings, you should also see a change in the CH0 and CH1 readings, but not the overall lux reading.
10+
11+
The datasheet details the calculation of lux value based on the channel 0 and 1 levels, as follows (p. 4):
12+
13+
| CH1/CH0| Sensor Lux Formula|
14+
|-----|-----|
15+
| 0 < CH1/CH0 ≤ 0.50 | Sensor Lux = (0.0304 x CH0) – (0.062 x CH0 x ((CH1/CH0)<sup>1.4</sup>)) |
16+
0.50 < CH1/CH0 ≤ 0.61 | Sensor Lux = (0.0224 x CH0) – (0.031 x CH1)|
17+
0.61 < CH1/CH0 ≤ 0.80 | Sensor Lux = (0.0128 x CH0) – (0.0153 x CH1)|
18+
0.80 < CH1/CH0 ≤ 1.30 | Sensor Lux = (0.00146 x CH0) – (0.00112 x CH1)|
19+
CH1/CH0>1.30| Sensor Lux = 0|

LightSensors/TCS34725_RGBSensor/TCS34725_RGBSensor.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS347
1717

1818
void setup(void) {
1919
Serial.begin(9600);
20+
pinMode(7, OUTPUT);
21+
digitalWrite(7, LOW);
2022
// start sensor:
2123
while (!tcs.begin()) {
2224
Serial.println("Looking for sensor...");
@@ -25,17 +27,17 @@ void setup(void) {
2527
}
2628

2729
void loop(void) {
28-
// every 2 seconds, read sensor:
30+
// every 2 seconds, read sensor:
2931
if (millis() % 2000 < 2) {
3032
uint16_t r, g, b, c, colorTemp, lux;
3133
tcs.getRawData(&r, &g, &b, &c);
3234
colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
3335
lux = tcs.calculateLux(r, g, b);
3436
String reading = "CT: ";
3537
reading += String(colorTemp);
36-
reading += "\nLux: ";
38+
reading += " Lux: ";
3739
reading += lux;
38-
reading += "R: " + String(r);
40+
reading += " R: " + String(r);
3941
reading += " G: " + String(g);
4042
reading += " B: " + String(b);
4143
Serial.println(reading);

0 commit comments

Comments
 (0)