lotsa changes
This commit is contained in:
@@ -38,7 +38,8 @@ while True:
|
|||||||
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjYjY5NjA5NmY0N2E0NmZlOGEzYjczOGYzYmUzOTk5ZSIsImlhdCI6MTY2MTM0NDgxOSwiZXhwIjoxOTc2NzA0ODE5fQ.z9fzbVOA1Pbur3Zb07481n-SoYesj8cetw-CX6WPmTs"
|
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjYjY5NjA5NmY0N2E0NmZlOGEzYjczOGYzYmUzOTk5ZSIsImlhdCI6MTY2MTM0NDgxOSwiZXhwIjoxOTc2NzA0ODE5fQ.z9fzbVOA1Pbur3Zb07481n-SoYesj8cetw-CX6WPmTs"
|
||||||
}
|
}
|
||||||
data = json.dumps({'payload': 'RING', 'topic': 'lewe/doorbell', 'retain': 'False'}).encode('utf8')
|
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)
|
response = urllib.request.urlopen(reqest)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error("Could not ring doorbell")
|
logger.error("Could not ring doorbell")
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
const int ledPin = LED_BUILTIN;
|
const int ledPin = LED_BUILTIN;
|
||||||
const int buttonPin = 2; // Button connected to D2
|
const int buttonPin = 2; // Button connected to D2
|
||||||
const int flare_threshold = 20;
|
const int flare_threshold = 120;
|
||||||
|
|
||||||
bool active = false;
|
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,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Sources:
|
Sources:
|
||||||
* https://randomnerdtutorials.com/esp32-esp8266-web-server-physical-button/
|
https://randomnerdtutorials.com/esp32-esp8266-web-server-physical-button/
|
||||||
* https://randomnerdtutorials.com/esp32-pushover-notifications-arduino/
|
https://randomnerdtutorials.com/esp32-pushover-notifications-arduino/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
@@ -385,22 +385,15 @@ void setup() {
|
|||||||
server.on("/irrigation", HTTP_GET, [] (AsyncWebServerRequest * request) {
|
server.on("/irrigation", HTTP_GET, [] (AsyncWebServerRequest * request) {
|
||||||
String action;
|
String action;
|
||||||
if (request->hasParam("action")) {
|
if (request->hasParam("action")) {
|
||||||
|
|
||||||
Serial.println("action");
|
|
||||||
action = request->getParam("action")->value();
|
action = request->getParam("action")->value();
|
||||||
|
|
||||||
Serial.println(action.equals("start"));
|
|
||||||
Serial.println(request->hasParam("duration"));
|
|
||||||
|
|
||||||
if (action.equals("start") and request->hasParam("duration")) {
|
if (action.equals("start") and request->hasParam("duration")) {
|
||||||
String duration = request->getParam("duration")->value();
|
String duration = request->getParam("duration")->value();
|
||||||
sprinklerDuration = duration.toInt();
|
sprinklerDuration = duration.toInt();
|
||||||
sprinklerDuration = sprinklerDuration * 60 * 1000;
|
sprinklerDuration = sprinklerDuration * 60 * 500; // XXX Terrasse nur halb so lange bewässern
|
||||||
sprinklerStartMillis = millis();
|
sprinklerStartMillis = millis();
|
||||||
|
|
||||||
programStatus = 4;
|
programStatus = 4;
|
||||||
digitalWrite(PIN_SPRINKLER4, LOW);
|
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\" }");
|
request->send(200, "application/json", "{ \"action\": \"start\" }");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -436,6 +429,11 @@ void loop() {
|
|||||||
if ((sprinklerDuration > 0) and ((millis() - sprinklerStartMillis) > sprinklerDuration)) {
|
if ((sprinklerDuration > 0) and ((millis() - sprinklerStartMillis) > sprinklerDuration)) {
|
||||||
stopSprinklers();
|
stopSprinklers();
|
||||||
if (programStatus > 0) {
|
if (programStatus > 0) {
|
||||||
|
|
||||||
|
if (programStatus == 4) {
|
||||||
|
sprinklerDuration = sprinklerDuration * 2; // XXX Terrasse nur halb so lange bewässern
|
||||||
|
}
|
||||||
|
|
||||||
programStatus--;
|
programStatus--;
|
||||||
sprinklerStartMillis = millis();
|
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