garage_esp32.ino v1.0 bugfix gate

This commit is contained in:
2023-05-28 08:04:47 +02:00
parent e118e68b3a
commit 1a4084e995
+12 -10
View File
@@ -51,10 +51,10 @@ const int PIN_GATE = 23; // relais pin for gate
const int PIN_DOOR_OPEN = 18; // sensor pin for garage door in position 'open'
const int PIN_DOOR_CLOSED = 19; // sensor pin for garage door in position 'closed'
const int PIN_SENSOR_GATE= 21; // sensor pin for gate (HIGH is open)
const int PIN_SPRINKLER1 = 26; // relais pin for sprinkler 1
const int PIN_SPRINKLER2 = 25; // relais pin for sprinkler 2
const int PIN_SPRINKLER3 = 33; // relais pin for sprinkler 3
const int PIN_SPRINKLER4 = 32; // relais pin for sprinkler 4
const int PIN_SPRINKLER1 = 25; // relais pin for sprinkler 1
const int PIN_SPRINKLER2 = 33; // relais pin for sprinkler 2
const int PIN_SPRINKLER3 = 32; // relais pin for sprinkler 3
const int PIN_SPRINKLER4 = 26; // relais pin for sprinkler 4
const int PIN_MOISTURE_ANALOG = 14; // moisture sensor analog value // XXX currently blocked by WiFi
const int PIN_MOISTURE_DIGITAL = 27; // moisture sensor digital value
@@ -261,14 +261,15 @@ void setup() {
pinMode(PIN_SPRINKLER4, OUTPUT);
pinMode(PIN_MOISTURE_DIGITAL, INPUT);
digitalWrite(PIN_LED, HIGH);
digitalWrite(PIN_GARAGE, HIGH);
digitalWrite(PIN_GATE, HIGH);
digitalWrite(PIN_SPRINKLER1, HIGH);
digitalWrite(PIN_SPRINKLER2, HIGH);
digitalWrite(PIN_SPRINKLER3, HIGH);
digitalWrite(PIN_SPRINKLER4, HIGH);
digitalWrite(PIN_LED, HIGH);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
@@ -277,8 +278,7 @@ void setup() {
Serial.println(WiFi.localIP());
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
digitalWrite(PIN_LED, LOW);
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
pinStatus(request);
});
@@ -329,10 +329,10 @@ void setup() {
}
else {
if (digitalRead(PIN_SENSOR_GATE)) {
request->send(200, "application/json", "{ \"status\": \"false\" }");
request->send(200, "application/json", "{ \"status\": \"true\" }");
}
else {
request->send(200, "application/json", "{ \"status\": \"true\" }");
request->send(200, "application/json", "{ \"status\": \"false\" }");
}
}
});
@@ -388,6 +388,8 @@ void setup() {
server.onNotFound(notFound);
server.begin();
digitalWrite(PIN_LED, LOW);
Serial.println("Setup completed");
}