Add "Software" chapter, move to minted
This commit is contained in:
@ -1,23 +1,25 @@
|
||||
/*
|
||||
Copyright (C) 2012 Nathanaël Restori
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use, copy,
|
||||
modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
@ -48,7 +50,7 @@ void setup() {
|
||||
if (!SD.begin(4)) {
|
||||
Serial.println("FAILED");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Serial.println("DONE");
|
||||
|
||||
//----- Sensors
|
||||
@ -59,22 +61,20 @@ void setup() {
|
||||
dht.begin();
|
||||
tsl.begin();
|
||||
|
||||
// You can change the gain on the fly, to adapt to brighter/dimmer light situations
|
||||
//tsl.setGain(TSL2561_GAIN_0X); // set no gain (for bright situtations)
|
||||
tsl.setGain(TSL2561_GAIN_16X); // set 16x gain (for dim situations)
|
||||
//tsl.setGain(TSL2561_GAIN_0X); // bright situtations
|
||||
tsl.setGain(TSL2561_GAIN_16X); // dim situations
|
||||
|
||||
// Changing the integration time gives you a longer time over which to sense light
|
||||
// longer timelines are slower, but are good in very low light situtations!
|
||||
tsl.setTiming(TSL2561_INTEGRATIONTIME_13MS); // shortest integration time (bright light)
|
||||
//tsl.setTiming(TSL2561_INTEGRATIONTIME_101MS); // medium integration time (medium light)
|
||||
//tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS); // longest integration time (dim light)
|
||||
tsl.setTiming(TSL2561_INTEGRATIONTIME_13MS); // bright light
|
||||
//tsl.setTiming(TSL2561_INTEGRATIONTIME_101MS); // medium light
|
||||
//tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS); // dim light
|
||||
|
||||
if (!SD.exists("data.tsv")) {
|
||||
file = SD.open("data.tsv", FILE_WRITE);
|
||||
|
||||
if (file) {
|
||||
Serial.print("Creating data.tsv");
|
||||
file.println("#Time\t\tT [°C]\tP [Pa]\tAlt [m]\tHr [%]\tLx [lux]");
|
||||
file.println("#Time\t\tT [°C]\tP [Pa]\tAlt [m]\tHr [%]\tLx \
|
||||
[lux]");
|
||||
file.close();
|
||||
Serial.println("DONE");
|
||||
} else {
|
||||
@ -100,17 +100,23 @@ void loop() {
|
||||
|
||||
if (file) {
|
||||
Serial.print("Writing to data.tsv...");
|
||||
file.print(time.year()); file.print("-"); file.print(time.month()); file.print("-"); file.print(time.day()); file.print(" "); file.print(time.hour()); file.print(":"); file.print(time.minute()); file.print(":"); file.print(time.second()); file.print("\t");
|
||||
file.print(time.year()); file.print("-");
|
||||
file.print(time.month()); file.print("-");
|
||||
file.print(time.day()); file.print(" ");
|
||||
file.print(time.hour()); file.print(":");
|
||||
file.print(time.minute()); file.print(":");
|
||||
file.print(time.second()); file.print("\t");
|
||||
|
||||
file.print(temperature); file.print("\t");
|
||||
file.print(pressure); file.print("\t");
|
||||
file.print(altitude); file.print("\t");
|
||||
file.print(humidity); file.print("\t");
|
||||
file.println(tsl.calculateLux(lightFull, lightIr));
|
||||
file.close();
|
||||
Serial.println("DONE");
|
||||
Serial.println("DONE");
|
||||
} else {
|
||||
Serial.println("Error opening data.tsv");
|
||||
}
|
||||
|
||||
|
||||
delay(TIMING);
|
||||
}
|
||||
|
Reference in New Issue
Block a user