garage_esp32.ino v1.0 bugfix gate
This commit is contained in:
@@ -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_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_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_SENSOR_GATE= 21; // sensor pin for gate (HIGH is open)
|
||||||
const int PIN_SPRINKLER1 = 26; // relais pin for sprinkler 1
|
const int PIN_SPRINKLER1 = 25; // relais pin for sprinkler 1
|
||||||
const int PIN_SPRINKLER2 = 25; // relais pin for sprinkler 2
|
const int PIN_SPRINKLER2 = 33; // relais pin for sprinkler 2
|
||||||
const int PIN_SPRINKLER3 = 33; // relais pin for sprinkler 3
|
const int PIN_SPRINKLER3 = 32; // relais pin for sprinkler 3
|
||||||
const int PIN_SPRINKLER4 = 32; // relais pin for sprinkler 4
|
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_ANALOG = 14; // moisture sensor analog value // XXX currently blocked by WiFi
|
||||||
const int PIN_MOISTURE_DIGITAL = 27; // moisture sensor digital value
|
const int PIN_MOISTURE_DIGITAL = 27; // moisture sensor digital value
|
||||||
|
|
||||||
@@ -261,6 +261,8 @@ void setup() {
|
|||||||
pinMode(PIN_SPRINKLER4, OUTPUT);
|
pinMode(PIN_SPRINKLER4, OUTPUT);
|
||||||
pinMode(PIN_MOISTURE_DIGITAL, INPUT);
|
pinMode(PIN_MOISTURE_DIGITAL, INPUT);
|
||||||
|
|
||||||
|
digitalWrite(PIN_LED, HIGH);
|
||||||
|
|
||||||
digitalWrite(PIN_GARAGE, HIGH);
|
digitalWrite(PIN_GARAGE, HIGH);
|
||||||
digitalWrite(PIN_GATE, HIGH);
|
digitalWrite(PIN_GATE, HIGH);
|
||||||
digitalWrite(PIN_SPRINKLER1, HIGH);
|
digitalWrite(PIN_SPRINKLER1, HIGH);
|
||||||
@@ -268,7 +270,6 @@ void setup() {
|
|||||||
digitalWrite(PIN_SPRINKLER3, HIGH);
|
digitalWrite(PIN_SPRINKLER3, HIGH);
|
||||||
digitalWrite(PIN_SPRINKLER4, HIGH);
|
digitalWrite(PIN_SPRINKLER4, HIGH);
|
||||||
|
|
||||||
digitalWrite(PIN_LED, HIGH);
|
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(1000);
|
delay(1000);
|
||||||
@@ -277,7 +278,6 @@ void setup() {
|
|||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
WiFi.setAutoReconnect(true);
|
WiFi.setAutoReconnect(true);
|
||||||
WiFi.persistent(true);
|
WiFi.persistent(true);
|
||||||
digitalWrite(PIN_LED, LOW);
|
|
||||||
|
|
||||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
pinStatus(request);
|
pinStatus(request);
|
||||||
@@ -329,10 +329,10 @@ void setup() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (digitalRead(PIN_SENSOR_GATE)) {
|
if (digitalRead(PIN_SENSOR_GATE)) {
|
||||||
request->send(200, "application/json", "{ \"status\": \"false\" }");
|
request->send(200, "application/json", "{ \"status\": \"true\" }");
|
||||||
}
|
}
|
||||||
else {
|
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.onNotFound(notFound);
|
||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
|
|
||||||
|
digitalWrite(PIN_LED, LOW);
|
||||||
Serial.println("Setup completed");
|
Serial.println("Setup completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user