10sensors Integrated
10sensors Integrated
h>
#include "time.h"
#include <Wire.h>
#include <U8g2lib.h>
// Pin Definitions
#define BUZZER_PIN 12 // GPIO 12 (should remain LOW during boot)
#define GREEN_LIGHT 25 // Green LED
#define RED_LIGHT 26 // Red LED
// WiFi Credentials
const char* ssid = "Galaxy S22";
const char* password = "1234567890";
void setup() {
Serial.begin(115200);
pinMode(GREEN_LIGHT, OUTPUT);
pinMode(RED_LIGHT, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(BUZZER_PIN, LOW);
// Connect to WiFi
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to WiFi");
void loop() {
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
Serial.println("Failed to get time");
return;
}
// Buzzer Logic
if ((timeinfo.tm_hour == 9 && timeinfo.tm_min == 0) || //first shift end
(timeinfo.tm_hour == 14 && timeinfo.tm_min == 0) || //second shift end
(timeinfo.tm_hour == 18 && timeinfo.tm_min == 0)) { //third shift end
if (!allSensorsActive) {
Serial.println("Buzzer Activated!");
digitalWrite(BUZZER_PIN, HIGH);
delay(60000);
digitalWrite(BUZZER_PIN, LOW);
}
}
delay(1000);
}