lotsa changes
This commit is contained in:
@@ -38,7 +38,8 @@ while True:
|
||||
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjYjY5NjA5NmY0N2E0NmZlOGEzYjczOGYzYmUzOTk5ZSIsImlhdCI6MTY2MTM0NDgxOSwiZXhwIjoxOTc2NzA0ODE5fQ.z9fzbVOA1Pbur3Zb07481n-SoYesj8cetw-CX6WPmTs"
|
||||
}
|
||||
data = json.dumps({'payload': 'RING', 'topic': 'lewe/doorbell', 'retain': 'False'}).encode('utf8')
|
||||
reqest = urllib.request.Request("https://www.nodebucket.de:8123/api/services/mqtt/publish", data, headers)
|
||||
request = urllib.request.Request("localhost:8123/api/services/mqtt/publish", data, headers)
|
||||
# request = urllib.request.Request("https://www.nodebucket.de:8123/api/services/mqtt/publish", data, headers)
|
||||
response = urllib.request.urlopen(reqest)
|
||||
except Exception:
|
||||
logger.error("Could not ring doorbell")
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
const int ledPin = LED_BUILTIN;
|
||||
const int buttonPin = 2; // Button connected to D2
|
||||
const int flare_threshold = 20;
|
||||
const int flare_threshold = 120;
|
||||
|
||||
bool active = false;
|
||||
|
||||
|
||||
+2094
-4
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 202 KiB After Width: | Height: | Size: 291 KiB |
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Sources:
|
||||
* https://randomnerdtutorials.com/esp32-esp8266-web-server-physical-button/
|
||||
* https://randomnerdtutorials.com/esp32-pushover-notifications-arduino/
|
||||
*/
|
||||
Sources:
|
||||
https://randomnerdtutorials.com/esp32-esp8266-web-server-physical-button/
|
||||
https://randomnerdtutorials.com/esp32-pushover-notifications-arduino/
|
||||
*/
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <AsyncTCP.h>
|
||||
@@ -50,7 +50,7 @@ const int PIN_GARAGE = 22; // relais pin for garage door
|
||||
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_SENSOR_GATE = 21; // sensor pin for gate (HIGH is open)
|
||||
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
|
||||
@@ -282,11 +282,11 @@ void setup() {
|
||||
WiFi.setAutoReconnect(true);
|
||||
WiFi.persistent(true);
|
||||
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
pinStatus(request);
|
||||
});
|
||||
|
||||
server.on("/garage", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
server.on("/garage", HTTP_GET, [] (AsyncWebServerRequest * request) {
|
||||
String action;
|
||||
if (request->hasParam("action")) {
|
||||
action = request->getParam("action")->value();
|
||||
@@ -313,7 +313,7 @@ void setup() {
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/gate", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
server.on("/gate", HTTP_GET, [] (AsyncWebServerRequest * request) {
|
||||
String action;
|
||||
if (request->hasParam("action")) {
|
||||
action = request->getParam("action")->value();
|
||||
@@ -340,7 +340,7 @@ void setup() {
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/sprinkler", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
server.on("/sprinkler", HTTP_GET, [] (AsyncWebServerRequest * request) {
|
||||
String action;
|
||||
if (request->hasParam("action")) {
|
||||
action = request->getParam("action")->value();
|
||||
@@ -382,25 +382,18 @@ void setup() {
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/irrigation", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
server.on("/irrigation", HTTP_GET, [] (AsyncWebServerRequest * request) {
|
||||
String action;
|
||||
if (request->hasParam("action")) {
|
||||
|
||||
Serial.println("action");
|
||||
action = request->getParam("action")->value();
|
||||
|
||||
Serial.println(action.equals("start"));
|
||||
Serial.println(request->hasParam("duration"));
|
||||
|
||||
if (action.equals("start") and request->hasParam("duration")) {
|
||||
String duration = request->getParam("duration")->value();
|
||||
sprinklerDuration = duration.toInt();
|
||||
sprinklerDuration = sprinklerDuration * 60 * 1000;
|
||||
sprinklerDuration = sprinklerDuration * 60 * 500; // XXX Terrasse nur halb so lange bewässern
|
||||
sprinklerStartMillis = millis();
|
||||
|
||||
programStatus = 4;
|
||||
digitalWrite(PIN_SPRINKLER4, LOW);
|
||||
sprinklerStartMillis = sprinklerStartMillis + ((sprinklerDuration / 2) * 60 * 1000); // XXX Terrasse nur halb so lange bewässern
|
||||
request->send(200, "application/json", "{ \"action\": \"start\" }");
|
||||
}
|
||||
else {
|
||||
@@ -436,6 +429,11 @@ void loop() {
|
||||
if ((sprinklerDuration > 0) and ((millis() - sprinklerStartMillis) > sprinklerDuration)) {
|
||||
stopSprinklers();
|
||||
if (programStatus > 0) {
|
||||
|
||||
if (programStatus == 4) {
|
||||
sprinklerDuration = sprinklerDuration * 2; // XXX Terrasse nur halb so lange bewässern
|
||||
}
|
||||
|
||||
programStatus--;
|
||||
sprinklerStartMillis = millis();
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Soil moisture sensor on Wemos D1
|
||||
*/
|
||||
|
||||
// the analog input on the Wemos D1 accepts up to 3.3V
|
||||
const int analogPin = A2;
|
||||
int val = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Starting moisture measurement");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
val = analogRead(analogPin);
|
||||
Serial.println(val);
|
||||
delay(1000);
|
||||
}
|
||||
Reference in New Issue
Block a user