30,8 → 30,6 |
#define LIGHT_RANGE3 3 |
#define LIGHT_RANGE4 4 |
|
int count=0; |
|
void setup() |
{ |
Wire.begin(); // join i2c bus (address optional for master) |
160,24 → 158,18 |
{ |
float luxVIS=0; |
float luxIR=0; |
float time; |
|
char dataString[40]; |
char luxVISch[10]; |
char luxIRch[10]; |
|
set_light_sensor(SENSE_VIS); //setup sensor for visible measuring |
led_blink(); // Delay for measurement |
luxVIS=get_light_measurement(); |
|
time=millis()/1000; |
|
set_light_sensor(SENSE_IR); // setup sensor for infrared measuring |
led_blink(); // Delay for measurement |
luxIR=get_light_measurement(); |
|
ftoa(luxVISch,luxVIS,2); |
ftoa(luxIRch,luxIR,2); |
// make a string for assembling the data to log: |
sprintf(dataString,"$LUX01 %d %s %s",count, luxVISch, luxIRch); |
|
// open the file. note that only one file can be open at a time, |
// so you have to close this one before opening another. |
File dataFile = SD.open("datalog.txt", FILE_WRITE); |
184,14 → 176,21 |
|
// if the file is available, write to it: |
if (dataFile) { |
dataFile.println(dataString); |
dataFile.print("$LUX0.1 "); |
dataFile.print(time,3); |
dataFile.print(" "); |
dataFile.print(luxVIS,3); |
dataFile.print(" "); |
dataFile.println(luxIR,3); |
dataFile.close(); |
|
// print to the serial port too: |
Serial.print("$LUX0.1 "); |
Serial.print(time,3); |
Serial.print(" "); |
Serial.print(luxVIS,3); |
Serial.print(" "); |
Serial.println(luxIR,3); |
Serial.println(dataString); |
count++; |
} |
// if the file isn't open, pop up an error: |
else { |