diff --git a/LightSensors/APDS9301_basic/readme.md b/LightSensors/APDS9301_basic/readme.md index a4368fd..a39175f 100644 --- a/LightSensors/APDS9301_basic/readme.md +++ b/LightSensors/APDS9301_basic/readme.md @@ -6,4 +6,14 @@ Sparkfun has a decent[ APDS9301 library](https://github.com/sparkfun/APDS-9301_B 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). -If you change the gain settings, you should also see a change in the CH0 and CH1 readings, but not the overall lux reading. \ No newline at end of file +If you change the gain settings, you should also see a change in the CH0 and CH1 readings, but not the overall lux reading. + +The datasheet details the calculation of lux value based on the channel 0 and 1 levels, as follows (p. 4): + +| CH1/CH0| Sensor Lux Formula| +|-----|-----| +| 0 < CH1/CH0 ≤ 0.50 | Sensor Lux = (0.0304 x CH0) – (0.062 x CH0 x ((CH1/CH0)1.4)) | +0.50 < CH1/CH0 ≤ 0.61 | Sensor Lux = (0.0224 x CH0) – (0.031 x CH1)| +0.61 < CH1/CH0 ≤ 0.80 | Sensor Lux = (0.0128 x CH0) – (0.0153 x CH1)| +0.80 < CH1/CH0 ≤ 1.30 | Sensor Lux = (0.00146 x CH0) – (0.00112 x CH1)| +CH1/CH0>1.30| Sensor Lux = 0| diff --git a/LightSensors/TCS34725_RGBSensor/TCS34725_RGBSensor.ino b/LightSensors/TCS34725_RGBSensor/TCS34725_RGBSensor.ino index ff930b5..6bdf512 100644 --- a/LightSensors/TCS34725_RGBSensor/TCS34725_RGBSensor.ino +++ b/LightSensors/TCS34725_RGBSensor/TCS34725_RGBSensor.ino @@ -17,6 +17,8 @@ Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS347 void setup(void) { Serial.begin(9600); + pinMode(7, OUTPUT); + digitalWrite(7, LOW); // start sensor: while (!tcs.begin()) { Serial.println("Looking for sensor..."); @@ -25,7 +27,7 @@ void setup(void) { } void loop(void) { - // every 2 seconds, read sensor: + // every 2 seconds, read sensor: if (millis() % 2000 < 2) { uint16_t r, g, b, c, colorTemp, lux; tcs.getRawData(&r, &g, &b, &c); @@ -33,9 +35,9 @@ void loop(void) { lux = tcs.calculateLux(r, g, b); String reading = "CT: "; reading += String(colorTemp); - reading += "\nLux: "; + reading += " Lux: "; reading += lux; - reading += "R: " + String(r); + reading += " R: " + String(r); reading += " G: " + String(g); reading += " B: " + String(b); Serial.println(reading);