Commit 83adb52f authored by joker's avatar joker
Browse files

updated datalogger code incl. header and comment on rtc.adjust

parent 9e567cd5
/* Andreas Pack for Digitale Techniken, 2021-12
* Weather station incl.
* brightness
* air temperature
* humidity
* rtc clock
* CO2 sensor (type MHZ19B): Messwerterfassung durch PWM-Signal, Quelle: https://www.blikk.it
* logging to sd card with nicely formatted data output and creation of new files for each measurement
* incl. update after student reported bug (2021-21-23)
* incl. commented rtc.adjust (2022-01-13)
*/
#include "RTClib.h"; // For clock module
#include "Wire.h"; // For communication with clock & T,h sensor via I2C communication
#include "Adafruit_Si7021.h"; // For the T and h sensor
......@@ -55,9 +67,17 @@ void setup() {
Serial.println("-> SD card is now correctly initialized.");
// Start clock
rtc.begin();
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
/* set the RTC to the date and time of compilation on your laptop with rtc.adjust
but only once (when connected to laptop via serial port)!
you then have to comment this line and recompile
else, everytime the weatherstation is connected to power and starts a measurement, the RTC will be adjusted to the time of compilation
*/
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// Start T and h sensor module
sensor.begin();
// Create the filename
DateTime now = rtc.now();
year = now.year();
......@@ -90,7 +110,7 @@ void setup() {
// filename = "hallo.txt";
// Now write the header
File datafile = SD.open(filename, FILE_WRITE);
// If file does not exists, a new with the given filename is created
// If file does not exist, a new file with the given filename is created
if (datafile) // Check if the file exists
{
Serial.print("-> A file with filename ");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment