Rev 2242 Rev 2243
Line 28... Line 28...
28 #define LIGHT_RANGE1 1 28 #define LIGHT_RANGE1 1
29 #define LIGHT_RANGE2 2 29 #define LIGHT_RANGE2 2
30 #define LIGHT_RANGE3 3 30 #define LIGHT_RANGE3 3
31 #define LIGHT_RANGE4 4 31 #define LIGHT_RANGE4 4
32   32  
33 int count=0; -  
34   -  
35 void setup() 33 void setup()
36 { 34 {
37 Wire.begin(); // join i2c bus (address optional for master) 35 Wire.begin(); // join i2c bus (address optional for master)
38   36  
39 pinMode(3, OUTPUT); // LED pro blikani, aby bylo videt, ze to neco dela 37 pinMode(3, OUTPUT); // LED pro blikani, aby bylo videt, ze to neco dela
Line 158... Line 156...
158   156  
159 void loop() 157 void loop()
160 { 158 {
161 float luxVIS=0; 159 float luxVIS=0;
162 float luxIR=0; 160 float luxIR=0;
163   -  
164 char dataString[40]; 161 float time;
165 char luxVISch[10]; -  
166 char luxIRch[10]; -  
167   162  
168 set_light_sensor(SENSE_VIS); //setup sensor for visible measuring 163 set_light_sensor(SENSE_VIS); //setup sensor for visible measuring
169 led_blink(); // Delay for measurement 164 led_blink(); // Delay for measurement
170 luxVIS=get_light_measurement(); 165 luxVIS=get_light_measurement();
171   166  
-   167 time=millis()/1000;
-   168
172 set_light_sensor(SENSE_IR); // setup sensor for infrared measuring 169 set_light_sensor(SENSE_IR); // setup sensor for infrared measuring
173 led_blink(); // Delay for measurement 170 led_blink(); // Delay for measurement
174 luxIR=get_light_measurement(); 171 luxIR=get_light_measurement();
175 172
176 ftoa(luxVISch,luxVIS,2); -  
177 ftoa(luxIRch,luxIR,2); -  
178 // make a string for assembling the data to log: -  
179 sprintf(dataString,"$LUX01 %d %s %s",count, luxVISch, luxIRch); -  
180   -  
181 // open the file. note that only one file can be open at a time, 173 // open the file. note that only one file can be open at a time,
182 // so you have to close this one before opening another. 174 // so you have to close this one before opening another.
183 File dataFile = SD.open("datalog.txt", FILE_WRITE); 175 File dataFile = SD.open("datalog.txt", FILE_WRITE);
184   176  
185 // if the file is available, write to it: 177 // if the file is available, write to it:
186 if (dataFile) { 178 if (dataFile) {
-   179 dataFile.print("$LUX0.1 ");
-   180 dataFile.print(time,3);
-   181 dataFile.print(" ");
-   182 dataFile.print(luxVIS,3);
-   183 dataFile.print(" ");
187 dataFile.println(dataString); 184 dataFile.println(luxIR,3);
188 dataFile.close(); 185 dataFile.close();
-   186
189 // print to the serial port too: 187 // print to the serial port too:
-   188 Serial.print("$LUX0.1 ");
-   189 Serial.print(time,3);
-   190 Serial.print(" ");
190 Serial.print(luxVIS,3); 191 Serial.print(luxVIS,3);
191 Serial.print(" "); 192 Serial.print(" ");
192 Serial.println(luxIR,3); 193 Serial.println(luxIR,3);
193 Serial.println(dataString); -  
194 count++; -  
195 } 194 }
196 // if the file isn't open, pop up an error: 195 // if the file isn't open, pop up an error:
197 else { 196 else {
198 Serial.println("error opening datalog.txt"); 197 Serial.println("error opening datalog.txt");
199 } 198 }