garage_esp32.fzz
This commit is contained in:
Binary file not shown.
@@ -44,17 +44,17 @@ const char *PUSHOVER_ROOT_CA = "-----BEGIN CERTIFICATE-----\n"
|
|||||||
|
|
||||||
const int PIN_LED = 2; // esp32 dev board integrated LED
|
const int PIN_LED = 2; // esp32 dev board integrated LED
|
||||||
const int PIN_GARAGE_BUTTON = 4; // button to open/close the garage door
|
const int PIN_GARAGE_BUTTON = 4; // button to open/close the garage door
|
||||||
const int PIN_GATE_BUTTON = 5; // button to open/close the gate
|
const int PIN_GATE_BUTTON = 16; // button to open/close the gate
|
||||||
const int PIN_MOWER_ACTIVE = 15; // only contact mower if pin is HIGH
|
const int PIN_MOWER_ACTIVE = 15; // only contact mower if pin is HIGH
|
||||||
const int PIN_GARAGE = 18; // relais pin for garage door
|
const int PIN_GARAGE = 17; // relais pin for garage door
|
||||||
const int PIN_GATE = 19; // relais pin for gate
|
const int PIN_GATE = 5; // relais pin for gate
|
||||||
const int PIN_DOOR_OPEN = 21; // sensor pin for garage door in position 'open'
|
const int PIN_DOOR_OPEN = 18; // sensor pin for garage door in position 'open'
|
||||||
const int PIN_DOOR_CLOSED = 22; // sensor pin for garage door in position 'closed'
|
const int PIN_DOOR_CLOSED = 19; // sensor pin for garage door in position 'closed'
|
||||||
const int PIN_SENSOR_GATE= 23; // sensor pin for gate (HIGH is open)
|
const int PIN_SENSOR_GATE= 21; // sensor pin for gate (HIGH is open)
|
||||||
const int PIN_SPRINKLER1 = 16; //25 relais pin for sprinkler 1
|
const int PIN_SPRINKLER1 = 26; // relais pin for sprinkler 1
|
||||||
const int PIN_SPRINKLER2 = 26; // relais pin for sprinkler 2
|
const int PIN_SPRINKLER2 = 25; // relais pin for sprinkler 2
|
||||||
const int PIN_SPRINKLER3 = 27; // relais pin for sprinkler 3
|
const int PIN_SPRINKLER3 = 33; // relais pin for sprinkler 3
|
||||||
const int PIN_SPRINKLER4 = 14; // relais pin for sprinkler 4
|
const int PIN_SPRINKLER4 = 32; // relais pin for sprinkler 4
|
||||||
|
|
||||||
AsyncWebServer server(80);
|
AsyncWebServer server(80);
|
||||||
const char* PARAM_MESSAGE = "message";
|
const char* PARAM_MESSAGE = "message";
|
||||||
@@ -190,10 +190,10 @@ void mowerAuto() {
|
|||||||
void triggerGarage() {
|
void triggerGarage() {
|
||||||
Serial.println("Trigger garage door");
|
Serial.println("Trigger garage door");
|
||||||
|
|
||||||
digitalWrite(PIN_GARAGE, HIGH);
|
digitalWrite(PIN_GARAGE, LOW);
|
||||||
digitalWrite(PIN_LED, HIGH);
|
digitalWrite(PIN_LED, HIGH);
|
||||||
delay(400);
|
delay(400);
|
||||||
digitalWrite(PIN_GARAGE, LOW);
|
digitalWrite(PIN_GARAGE, HIGH);
|
||||||
digitalWrite(PIN_LED, LOW);
|
digitalWrite(PIN_LED, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,10 +205,10 @@ void triggerGate() {
|
|||||||
toSafety = true;
|
toSafety = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
digitalWrite(PIN_GATE, HIGH);
|
digitalWrite(PIN_GATE, LOW);
|
||||||
digitalWrite(PIN_LED, HIGH);
|
digitalWrite(PIN_LED, HIGH);
|
||||||
delay(400);
|
delay(400);
|
||||||
digitalWrite(PIN_GATE, LOW);
|
digitalWrite(PIN_GATE, HIGH);
|
||||||
digitalWrite(PIN_LED, LOW);
|
digitalWrite(PIN_LED, LOW);
|
||||||
|
|
||||||
// DEAKTIVIEREN FÜR WINTERPAUSE:
|
// DEAKTIVIEREN FÜR WINTERPAUSE:
|
||||||
@@ -228,10 +228,10 @@ void triggerGate() {
|
|||||||
void stopSprinklers() {
|
void stopSprinklers() {
|
||||||
Serial.println("Stopping sprinklers");
|
Serial.println("Stopping sprinklers");
|
||||||
|
|
||||||
digitalWrite(PIN_SPRINKLER1, LOW);
|
digitalWrite(PIN_SPRINKLER1, HIGH);
|
||||||
digitalWrite(PIN_SPRINKLER2, LOW);
|
digitalWrite(PIN_SPRINKLER2, HIGH);
|
||||||
digitalWrite(PIN_SPRINKLER3, LOW);
|
digitalWrite(PIN_SPRINKLER3, HIGH);
|
||||||
digitalWrite(PIN_SPRINKLER4, LOW);
|
digitalWrite(PIN_SPRINKLER4, HIGH);
|
||||||
sprinklerDuration = 0;
|
sprinklerDuration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,6 +256,13 @@ void setup() {
|
|||||||
pinMode(PIN_SPRINKLER3, OUTPUT);
|
pinMode(PIN_SPRINKLER3, OUTPUT);
|
||||||
pinMode(PIN_SPRINKLER4, OUTPUT);
|
pinMode(PIN_SPRINKLER4, OUTPUT);
|
||||||
|
|
||||||
|
digitalWrite(PIN_GARAGE, HIGH);
|
||||||
|
digitalWrite(PIN_GATE, HIGH);
|
||||||
|
digitalWrite(PIN_SPRINKLER1, HIGH);
|
||||||
|
digitalWrite(PIN_SPRINKLER2, HIGH);
|
||||||
|
digitalWrite(PIN_SPRINKLER3, HIGH);
|
||||||
|
digitalWrite(PIN_SPRINKLER4, HIGH);
|
||||||
|
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(1000);
|
delay(1000);
|
||||||
@@ -370,8 +377,6 @@ void setup() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// timer
|
|
||||||
|
|
||||||
server.onNotFound(notFound);
|
server.onNotFound(notFound);
|
||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
@@ -381,7 +386,8 @@ void setup() {
|
|||||||
|
|
||||||
unsigned long lastDebounceTime = 0;
|
unsigned long lastDebounceTime = 0;
|
||||||
unsigned long debounceDelay = 80;
|
unsigned long debounceDelay = 80;
|
||||||
int lastVal = LOW;
|
int lastValGarage = LOW;
|
||||||
|
int lastValGate = LOW;
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
@@ -390,30 +396,40 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int newVal = digitalRead(PIN_GARAGE_BUTTON);
|
int newVal = digitalRead(PIN_GARAGE_BUTTON);
|
||||||
if (newVal != lastVal) {
|
if (newVal != lastValGarage) {
|
||||||
|
Serial.print("Garage Button: ");
|
||||||
lastDebounceTime = millis();
|
lastDebounceTime = millis();
|
||||||
while (((millis() - lastDebounceTime) < debounceDelay) and digitalRead(PIN_GARAGE_BUTTON) != lastVal) {
|
while (((millis() - lastDebounceTime) < debounceDelay) and digitalRead(PIN_GARAGE_BUTTON) != lastValGarage) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
if (digitalRead(PIN_GARAGE_BUTTON) != lastVal) {
|
if (digitalRead(PIN_GARAGE_BUTTON) != lastValGarage) {
|
||||||
lastVal = newVal;
|
Serial.println("REAL");
|
||||||
|
lastValGarage = newVal;
|
||||||
if (newVal == HIGH) {
|
if (newVal == HIGH) {
|
||||||
triggerGarage();
|
triggerGarage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Serial.println("fluke");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newVal = digitalRead(PIN_GATE_BUTTON);
|
newVal = digitalRead(PIN_GATE_BUTTON);
|
||||||
if (newVal != lastVal) {
|
if (newVal != lastValGate) {
|
||||||
|
Serial.print("Gate Button: ");
|
||||||
lastDebounceTime = millis();
|
lastDebounceTime = millis();
|
||||||
while (((millis() - lastDebounceTime) < debounceDelay) and digitalRead(PIN_GATE_BUTTON) != lastVal) {
|
while (((millis() - lastDebounceTime) < debounceDelay) and digitalRead(PIN_GATE_BUTTON) != lastValGate) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
if (digitalRead(PIN_GATE_BUTTON) != lastVal) {
|
if (digitalRead(PIN_GATE_BUTTON) != lastValGate) {
|
||||||
lastVal = newVal;
|
Serial.println("REAL");
|
||||||
|
lastValGate = newVal;
|
||||||
if (newVal == HIGH) {
|
if (newVal == HIGH) {
|
||||||
triggerGate();
|
triggerGate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Serial.println("fluke");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user