diff --git a/arduino/WeatherStationLogger/WeatherStationLogger.ino b/arduino/WeatherStationLogger/WeatherStationLogger.ino
index 936f7dc..570d5ad 100644
--- a/arduino/WeatherStationLogger/WeatherStationLogger.ino
+++ b/arduino/WeatherStationLogger/WeatherStationLogger.ino
@@ -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);
}
diff --git a/arduino/WeatherStationWeb/WeatherStationWeb.ino b/arduino/WeatherStationWeb/WeatherStationWeb.ino
index e805075..a4eebff 100644
--- a/arduino/WeatherStationWeb/WeatherStationWeb.ino
+++ b/arduino/WeatherStationWeb/WeatherStationWeb.ino
@@ -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.
*/
@@ -40,7 +42,43 @@ static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
static IPAddress ip = IPAddress(192, 168, 1, 210);
static IPAddress timeserver = IPAddress(192, 43, 244, 18);
-P(indexHtml) = "
Station Météo";
+P(indexHtml) = "Station Météo par Nathanaël Restori
";
// no-cost stream operator as described at
// http://sundial.org/arduino/?page_id=119
@@ -57,12 +95,14 @@ WebServer webserver(PREFIX, 80);
byte packetBuffer[ NTP_PACKET_SIZE];
EthernetUDP Udp;
-void defaultCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete) {
+void defaultCmd(WebServer &server, WebServer::ConnectionType type,
+ char *url_tail, bool tail_complete) {
server.httpSuccess();
server.printP(indexHtml);
}
-void sensorsJsonCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete) {
+void sensorsJsonCmd(WebServer &server, WebServer::ConnectionType type,
+ char *url_tail, bool tail_complete) {
float temperature = bmp.readTemperature();
int32_t pressure = bmp.readPressure();
float altitude = bmp.readAltitude();
@@ -78,7 +118,10 @@ void sensorsJsonCmd(WebServer &server, WebServer::ConnectionType type, char *url
server.httpSuccess("application/json");
server << "{ \"sensors\": ["
- << "{\"data\":\"" << time.hour() << ":" << time.minute() << ":" << time.second() << " " << time.day() << "/" << time.month() << "/" << time.year() << "\"},"
+ << "{\"data\":\"" << time.hour() << ":" << time.minute()
+ << ":" << time.second() << " " << time.day() << "/"
+ << time.month() << "/" << time.year() << "\"},"
+
<< "{\"data\":" << temperature << "},"
<< "{\"data\":" << pressure << "},"
<< "{\"data\":" << altitude << "},"
@@ -113,17 +156,22 @@ void sendNTPpacket() {
delay(1000);
if ( Udp.parsePacket() ) {
// We've received a packet, read the data from it
- Udp.read(packetBuffer,NTP_PACKET_SIZE); // read the packet into the buffer
+ Udp.read(packetBuffer,NTP_PACKET_SIZE); // read the packet
+ // into the buffer
- //the timestamp starts at byte 40 of the received packet and is four bytes,
- // or two words, long. First, esxtract the two words:
+ // the timestamp starts at byte 40 of the received packet and is
+ // four bytes, or two words, long. First, esxtract the two
+ // words:
- unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
- unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
+ unsigned long highWord = word(packetBuffer[40],
+ packetBuffer[41]);
+ unsigned long lowWord = word(packetBuffer[42],
+ packetBuffer[43]);
// combine the four bytes (two words) into a long integer
// this is NTP time (seconds since Jan 1 1900):
unsigned long secsSince1900 = highWord << 16 | lowWord;
- // Unix time starts on Jan 1 1970. In seconds, that's 2208988800:
+ // Unix time starts on Jan 1 1970. In seconds, that's
+ // 2208988800:
const unsigned long seventyYears = 2208988800UL;
// subtract seventy years:
unsigned long epoch = secsSince1900 - seventyYears + TIMEZONE;
@@ -153,15 +201,12 @@ void setup() {
tsl.begin();
chronodot.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
Udp.begin(8888);
sendNTPpacket();
diff --git a/arduino/WeatherStationWeb/index.html b/arduino/WeatherStationWeb/index.html
index 534deb7..9d747d0 100644
--- a/arduino/WeatherStationWeb/index.html
+++ b/arduino/WeatherStationWeb/index.html
@@ -64,10 +64,18 @@