// Edge Processing: Abnormal Sensor Value Detection
// Platform: ESP32 (Wokwi)
#define SENSOR_PIN 34 // Analog input (potentiometer)
#define LED_PIN 2 // LED indicator
// Thresholds tuned for ESP32 ADC range (0–4095)
#define LOW_THRESHOLD 1000
#define HIGH_THRESHOLD 3000
void setup() {
Serial.begin(115200);
delay(2000);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
}
void loop() {
Serial.println("Hello............");
int sensorValue = analogRead(SENSOR_PIN);
Serial.print("Sensor Value: ");
Serial.println(sensorValue);
// Edge-based anomaly detection
if (sensorValue < LOW_THRESHOLD) {
Serial.println("⚠️ ALERT: Sensor value TOO LOW");
digitalWrite(LED_PIN, HIGH);
}
else if (sensorValue > HIGH_THRESHOLD) {
Serial.println("⚠️ ALERT: Sensor value TOO HIGH");
digitalWrite(LED_PIN, HIGH);
}
else {
Serial.println("✅ Status: NORMAL");
digitalWrite(LED_PIN, LOW);
}
delay(1000); // Read every 1 second
}