diff --git a/ampel-firmware.h b/ampel-firmware.h index 530f686c1593a9add43d9687d9d7c5429bcc6218..cd211f49ff29f4b21e11e7047a35dd677f58af6e 100644 --- a/ampel-firmware.h +++ b/ampel-firmware.h @@ -8,23 +8,25 @@ #ifndef MEASUREMENT_TIMESTEP # error Missing config.h file. Please copy config.example.h to config.h. #endif + +#ifdef CSV_WRITER +# include "csv_writer.h" +#endif #ifdef MQTT # include "mqtt.h" #endif #ifdef LORAWAN # include "lorawan.h" #endif +#ifdef HTTP +# include "web_server.h" +#endif #include "util.h" #include "wifi_util.h" #include "co2_sensor.h" -#ifdef HTTP -# include "web_server.h" -#endif - #include "led_effects.h" -#include "csv_writer.h" #if defined(ESP8266) //allows sensor to be seen as SENSOR_ID.local, from the local network. For example : espd03cc5.local diff --git a/ampel-firmware.ino b/ampel-firmware.ino index 526e5d8614c13d4a24111d483f96d210357ce39b..bdce462c9aafa172eb06fec057d22eec56293d3b 100644 --- a/ampel-firmware.ino +++ b/ampel-firmware.ino @@ -100,8 +100,9 @@ void setup() { #endif } - //TODO: Add a config to deactivate CSV logging +#ifdef CSV_WRITER csv_writer::initialize(); +#endif #if defined(LORAWAN) && defined(ESP32) lorawan::initialize(); diff --git a/co2_sensor.cpp b/co2_sensor.cpp index 86fd8b448717c5459940ecbf34311011a54eba2f..6e3dec3a2b471d9c079e515e9a47cde5e80f5d24 100644 --- a/co2_sensor.cpp +++ b/co2_sensor.cpp @@ -178,7 +178,10 @@ namespace sensor { logToSerial(); //TODO: Move the 3 back to ampel-firmware.ino and remove headers from co2_sensor.h + +#ifdef CSV_WRITER csv_writer::logIfTimeHasCome(timestamp, co2, temperature, humidity); +#endif #ifdef MQTT mqtt::publishIfTimeHasCome(timestamp, co2, temperature, humidity); diff --git a/config.public.h b/config.public.h index 861375cbd5f90a024a14e9ba51bbfead36dac4e6..d3c9c507a631b6f36a1fb38e8044d24e05dda9bc 100644 --- a/config.public.h +++ b/config.public.h @@ -26,6 +26,9 @@ // # define MQTT_SENDING_INTERVAL MEASUREMENT_TIMESTEP * 5 // [s] # define MQTT_SENDING_INTERVAL 300 // [s] +// Should data be written to the sensor Flash memory? Writing too often might damage the ESP memory +# define CSV_WRITER // Comment or remove this line if you want to disable CSV logging. + // How often should measurements be appended to CSV ? // Probably a good idea to use a multiple of MEASUREMENT_TIMESTEP, so that averages can be calculated // Set to 0 if you want to send values after each measurement diff --git a/web_server.cpp b/web_server.cpp index d2458f5da29f8929bb83764685a45a4369b5008a..48906281e153971b1e50fb4df881a84817f5da5a 100644 --- a/web_server.cpp +++ b/web_server.cpp @@ -57,11 +57,13 @@ namespace web_server { "