-git ignore
This commit is contained in:
parent
57de082e7e
commit
2240305127
70
.gitignore
vendored
70
.gitignore
vendored
@ -1,70 +0,0 @@
|
|||||||
app/bin/
|
|
||||||
app/pde.jar
|
|
||||||
build/macosx/work/
|
|
||||||
arduino-core/bin/
|
|
||||||
arduino-core/arduino-core.jar
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Descriptors.o
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Descriptors.lst
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Caterina.sym
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Caterina.o
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Caterina.map
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Caterina.lst
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Caterina.lss
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
|
|
||||||
hardware/arduino/bootloaders/caterina_LUFA/.dep/
|
|
||||||
build/*.zip
|
|
||||||
build/*.tar.bz2
|
|
||||||
build/windows/work/
|
|
||||||
build/windows/*.zip
|
|
||||||
build/windows/*.tgz
|
|
||||||
build/windows/*.tar.bz2
|
|
||||||
build/windows/libastylej*
|
|
||||||
build/windows/liblistSerials*
|
|
||||||
build/windows/arduino-*.zip
|
|
||||||
build/windows/dist/*.tar.gz
|
|
||||||
build/windows/dist/*.tar.bz2
|
|
||||||
build/windows/launch4j-*.tgz
|
|
||||||
build/windows/launch4j-*.zip
|
|
||||||
build/windows/launcher/launch4j
|
|
||||||
build/windows/WinAVR-*.zip
|
|
||||||
build/macosx/arduino-*.zip
|
|
||||||
build/macosx/dist/*.tar.gz
|
|
||||||
build/macosx/dist/*.tar.bz2
|
|
||||||
build/macosx/*.tar.bz2
|
|
||||||
build/macosx/libastylej*
|
|
||||||
build/macosx/appbundler*.jar
|
|
||||||
build/macosx/appbundler*.zip
|
|
||||||
build/macosx/appbundler
|
|
||||||
build/macosx/appbundler-1.0ea-arduino?
|
|
||||||
build/macosx/appbundler-1.0ea-arduino*.zip
|
|
||||||
build/macosx/appbundler-1.0ea-upstream*.zip
|
|
||||||
build/linux/work/
|
|
||||||
build/linux/dist/*.tar.gz
|
|
||||||
build/linux/dist/*.tar.bz2
|
|
||||||
build/linux/*.tgz
|
|
||||||
build/linux/*.tar.xz
|
|
||||||
build/linux/*.tar.bz2
|
|
||||||
build/linux/*.zip
|
|
||||||
build/linux/libastylej*
|
|
||||||
build/linux/liblistSerials*
|
|
||||||
build/shared/arduino-examples*
|
|
||||||
build/shared/reference*.zip
|
|
||||||
build/shared/Edison*.zip
|
|
||||||
build/shared/Galileo*.zip
|
|
||||||
build/shared/WiFi101-Updater-ArduinoIDE-Plugin*.zip
|
|
||||||
test-bin
|
|
||||||
*.iml
|
|
||||||
.idea
|
|
||||||
.DS_Store
|
|
||||||
.directory
|
|
||||||
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
|
|
||||||
avr-toolchain-*.zip
|
|
||||||
/app/nbproject/private/
|
|
||||||
/arduino-core/nbproject/private/
|
|
||||||
/app/build/
|
|
||||||
/arduino-core/build/
|
|
||||||
|
|
||||||
manifest.mf
|
|
||||||
nbbuild.xml
|
|
||||||
nbproject
|
|
101
AlarmeESP32.ino
101
AlarmeESP32.ino
@ -1,30 +1,117 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
#include <Firebase_ESP_Client.h>
|
||||||
#include <ctrlLed.h>
|
#include <ctrlLed.h>
|
||||||
#include <FireBaseHandler.h>
|
|
||||||
#include <ctrlSpeaker.h>
|
#include <ctrlSpeaker.h>
|
||||||
#include <ctrlRfid.h>
|
#include <ctrlRfid.h>
|
||||||
#include <branchements.h>
|
#include <branchements.h>
|
||||||
|
|
||||||
volatile bool motionDetected = false;
|
#define WIFI_SSID "ratio"
|
||||||
|
#define WIFI_PASSWORD "123456789"
|
||||||
|
|
||||||
void IRAM_ATTR onMotionDetected() {
|
#define API_KEY "AIzaSyB8qf7aeI7F5l7d1NDhRQrNNLW8aPaOkl4"
|
||||||
motionDetected = true; // Flag à traiter dans loop()
|
#define DATABASE_URL "https://alarmeesp32-2ca19-default-rtdb.europe-west1.firebasedatabase.app"
|
||||||
|
#define USER_EMAIL "alarm@alarm.bip"
|
||||||
|
#define USER_PASSWORD "123456"
|
||||||
|
|
||||||
|
// Déclaration des objets Firebase
|
||||||
|
FirebaseData stream;
|
||||||
|
FirebaseData fbdo;
|
||||||
|
FirebaseAuth auth;
|
||||||
|
FirebaseConfig config;
|
||||||
|
|
||||||
|
// Variables de gestion de l'alarme
|
||||||
|
volatile bool motionDetected = false;
|
||||||
|
bool armed = false;
|
||||||
|
bool triggered = false;
|
||||||
|
|
||||||
|
// Stream Firebase
|
||||||
|
void streamCallback(FirebaseStream data) {
|
||||||
|
Serial.printf("Firebase Update - Path: %s, Data: %s\n",
|
||||||
|
data.dataPath().c_str(),
|
||||||
|
data.stringData().c_str());
|
||||||
|
|
||||||
|
if (data.dataPath() == "/armed") {
|
||||||
|
armed = data.boolData();
|
||||||
|
Serial.printf("🔒 Alarme armée: %s\n", armed ? "OUI" : "NON");
|
||||||
|
}
|
||||||
|
if (data.dataPath() == "/triggered") {
|
||||||
|
triggered = data.boolData();
|
||||||
|
Serial.printf("🚨 Alarme déclenchée: %s\n", triggered ? "OUI" : "NON");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void streamTimeoutCallback(bool timeout) {
|
||||||
|
if (timeout)
|
||||||
|
Serial.println("⏳ Stream timeout, reconnexion...");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Détection mouvement
|
||||||
|
void IRAM_ATTR onMotionDetected() {
|
||||||
|
motionDetected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
// Connexion WiFi
|
||||||
|
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
Serial.print(".");
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
Serial.println("\n✅ WiFi connecté ! C'est super");
|
||||||
|
|
||||||
|
// Configuration Firebase
|
||||||
|
config.api_key = API_KEY;
|
||||||
|
auth.user.email = USER_EMAIL;
|
||||||
|
auth.user.password = USER_PASSWORD;
|
||||||
|
config.database_url = DATABASE_URL;
|
||||||
|
|
||||||
|
Firebase.begin(&config, &auth);
|
||||||
|
Firebase.reconnectWiFi(true);
|
||||||
|
|
||||||
|
// Initialisation du streaming Firebase
|
||||||
|
if (!Firebase.RTDB.beginStream(&stream, "/Alarm"))
|
||||||
|
Serial.printf("🔥 Erreur de stream: %s\n", stream.errorReason().c_str());
|
||||||
|
Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback);
|
||||||
|
|
||||||
pinMode(A2, INPUT);
|
pinMode(A2, INPUT);
|
||||||
pinMode(D2, OUTPUT);
|
pinMode(D2, OUTPUT);
|
||||||
attachInterrupt(digitalPinToInterrupt(A2), onMotionDetected, RISING);
|
attachInterrupt(digitalPinToInterrupt(A2), onMotionDetected, RISING);
|
||||||
|
|
||||||
blinkSlowGreen();
|
blinkSlowGreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
Firebase.ready();
|
||||||
|
|
||||||
|
if (armed) {
|
||||||
|
blinkSlowRed();
|
||||||
if (motionDetected) {
|
if (motionDetected) {
|
||||||
Serial.println("Mouvement détecté !");
|
motionDetected = false;
|
||||||
|
Serial.println("🎯 Mouvement détecté !");
|
||||||
|
|
||||||
blinkFastRed();
|
blinkFastRed();
|
||||||
startSirene();
|
startSirene();
|
||||||
|
|
||||||
|
Firebase.RTDB.setBool(&fbdo, "/Alarm/triggered", true);
|
||||||
|
triggered = true;
|
||||||
|
|
||||||
|
String logEntry = "Mouvement détecté à " + String(millis() / 1000) + "s";
|
||||||
|
Firebase.RTDB.setString(&fbdo, "/Alarm/logs", logEntry);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!triggered) {
|
||||||
|
stopSirene();
|
||||||
|
blinkSlowGreen();
|
||||||
|
}else{
|
||||||
|
startSirene();
|
||||||
|
blinkFastRed();
|
||||||
|
}
|
||||||
|
|
||||||
updateLed();
|
updateLed();
|
||||||
updateSirene();
|
updateSirene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user