Garage: new pin for moisture sensor

Doorbell: Vibration motor connected via PC817C optocoupler
This commit is contained in:
2024-05-24 16:17:03 +02:00
parent 4b1502b460
commit 25be0a87fc
4 changed files with 13 additions and 13 deletions
@@ -1,35 +1,31 @@
/* Klingel-Sensor auf Arduino Nano ATmega168
*
* https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button
* https://elektro.turanis.de/html/prj035/index.html
*
* D2 -------------
* | |
* 10kOhm |
* | |
* +5V ----- |
* Button
* |
* GND -------------
* https://docs.arduino.cc/tutorials/generic/digital-input-pullup/
*/
const int ledPin = LED_BUILTIN;
const int buttonPin = 2; // Button connected to D2
const int flare_threshold = 200;
const int ring_delay = 250;
bool active = false;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600);
Serial.println("Doorbell sensor");
}
void loop() {
int val = digitalRead(buttonPin);
if (val == LOW) {
delay(flare_threshold); // catch flares
val = digitalRead(buttonPin);
@@ -45,8 +41,10 @@ void loop() {
Serial.print(flare_threshold);
Serial.println(")");
}
} else {
}
else {
digitalWrite(ledPin, LOW);
active = false;
}
}
Binary file not shown.
+3 -1
View File
@@ -2,6 +2,8 @@
Sources:
https://randomnerdtutorials.com/esp32-esp8266-web-server-physical-button/
https://randomnerdtutorials.com/esp32-pushover-notifications-arduino/
Note: Usage of wifi blocks the ADC2 analog pins. ADC1 pins can be used. See https://github.com/espressif/arduino-esp32/issues/102#issuecomment-295272351
*/
#include <WiFi.h>
@@ -55,7 +57,7 @@ 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_ANALOG = 35; // moisture sensor analog value
const int PIN_MOISTURE_DIGITAL = 27; // moisture sensor digital value
AsyncWebServer server(80);