@@ -24,6 +24,15 @@ struct DeviceConfig {
2424 // Cloud sensor parameters
2525 float cloud_threshold; // Temperature difference threshold for cloud detection (°C)
2626
27+ // Alert/trigger output configuration
28+ bool alert_enabled; // Enable/disable alert output
29+ uint8_t alert_pin; // GPIO pin for alert output (default: TRIGGER_OUT_LED)
30+ bool alert_on_cloud; // Trigger alert on cloud detection
31+ float alert_cloud_temp_threshold; // Cloud temperature threshold (°C)
32+ bool alert_on_light; // Trigger alert on high light (dawn/lights)
33+ float alert_light_threshold; // Light threshold in lux for alert
34+ bool alert_active_high; // true = alert HIGH when triggered, false = alert LOW
35+
2736 // Measurement intervals (milliseconds)
2837 uint16_t measurement_interval; // Default: 2000 ms
2938
@@ -61,6 +70,15 @@ class ConfigManager {
6170 // Cloud sensor defaults
6271 config.cloud_threshold = 5.0 ; // 5°C difference
6372
73+ // Alert defaults
74+ config.alert_enabled = false ;
75+ config.alert_pin = 27 ; // TRIGGER_OUT_LED pin
76+ config.alert_on_cloud = true ;
77+ config.alert_cloud_temp_threshold = -10.0 ; // Alert if sky temp < -10°C (clouds)
78+ config.alert_on_light = true ;
79+ config.alert_light_threshold = 10.0 ; // Alert if light > 10 lux (dawn/lights)
80+ config.alert_active_high = true ; // HIGH = alert active
81+
6482 // Timing defaults
6583 config.measurement_interval = 2000 ;
6684
@@ -118,6 +136,13 @@ class ConfigManager {
118136 float getSqmMultiplier () { return config.sqm_multiplier ; }
119137 float getSqmDarkCap () { return config.sqm_dark_cap ; }
120138 float getCloudThreshold () { return config.cloud_threshold ; }
139+ bool isAlertEnabled () { return config.alert_enabled ; }
140+ uint8_t getAlertPin () { return config.alert_pin ; }
141+ bool isAlertOnCloud () { return config.alert_on_cloud ; }
142+ float getAlertCloudTempThreshold () { return config.alert_cloud_temp_threshold ; }
143+ bool isAlertOnLight () { return config.alert_on_light ; }
144+ float getAlertLightThreshold () { return config.alert_light_threshold ; }
145+ bool isAlertActiveHigh () { return config.alert_active_high ; }
121146 uint16_t getMeasurementInterval () { return config.measurement_interval ; }
122147 const char * getDeviceLabel () { return config.device_label ; }
123148
@@ -126,6 +151,13 @@ class ConfigManager {
126151 void setSqmMultiplier (float value) { config.sqm_multiplier = value; }
127152 void setSqmDarkCap (float value) { config.sqm_dark_cap = value; }
128153 void setCloudThreshold (float value) { config.cloud_threshold = value; }
154+ void setAlertEnabled (bool value) { config.alert_enabled = value; }
155+ void setAlertPin (uint8_t value) { config.alert_pin = value; }
156+ void setAlertOnCloud (bool value) { config.alert_on_cloud = value; }
157+ void setAlertCloudTempThreshold (float value) { config.alert_cloud_temp_threshold = value; }
158+ void setAlertOnLight (bool value) { config.alert_on_light = value; }
159+ void setAlertLightThreshold (float value) { config.alert_light_threshold = value; }
160+ void setAlertActiveHigh (bool value) { config.alert_active_high = value; }
129161 void setMeasurementInterval (uint16_t value) { config.measurement_interval = value; }
130162 void setDeviceLabel (const char * label) {
131163 strncpy (config.device_label , label, sizeof (config.device_label ) - 1 );
@@ -139,6 +171,13 @@ class ConfigManager {
139171 Serial.print (" # SQM Multiplier: " ); Serial.println (config.sqm_multiplier , 4 );
140172 Serial.print (" # SQM Dark Cap: " ); Serial.println (config.sqm_dark_cap , 2 );
141173 Serial.print (" # Cloud Threshold: " ); Serial.println (config.cloud_threshold , 2 );
174+ Serial.print (" # Alert Enabled: " ); Serial.println (config.alert_enabled ? " YES" : " NO" );
175+ Serial.print (" # Alert Pin: GPIO" ); Serial.println (config.alert_pin );
176+ Serial.print (" # Alert on Cloud: " ); Serial.println (config.alert_on_cloud ? " YES" : " NO" );
177+ Serial.print (" # Alert Cloud Temp Threshold: " ); Serial.print (config.alert_cloud_temp_threshold , 2 ); Serial.println (" °C" );
178+ Serial.print (" # Alert on Light: " ); Serial.println (config.alert_on_light ? " YES" : " NO" );
179+ Serial.print (" # Alert Light Threshold: " ); Serial.print (config.alert_light_threshold , 2 ); Serial.println (" lux" );
180+ Serial.print (" # Alert Active High: " ); Serial.println (config.alert_active_high ? " YES" : " NO" );
142181 Serial.print (" # Measurement Interval: " ); Serial.print (config.measurement_interval ); Serial.println (" ms" );
143182 Serial.print (" # Device Label: " ); Serial.println (config.device_label );
144183 Serial.println (" # ============================" );
0 commit comments