Garage: new pin for moisture sensor
Doorbell: Vibration motor connected via PC817C optocoupler
This commit is contained in:
Binary file not shown.
@@ -1,35 +1,31 @@
|
|||||||
/* Klingel-Sensor auf Arduino Nano ATmega168
|
/* Klingel-Sensor auf Arduino Nano ATmega168
|
||||||
*
|
*
|
||||||
* https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button
|
* https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button
|
||||||
* https://elektro.turanis.de/html/prj035/index.html
|
* https://docs.arduino.cc/tutorials/generic/digital-input-pullup/
|
||||||
*
|
|
||||||
* D2 -------------
|
|
||||||
* | |
|
|
||||||
* 10kOhm |
|
|
||||||
* | |
|
|
||||||
* +5V ----- |
|
|
||||||
* Button
|
|
||||||
* |
|
|
||||||
* GND -------------
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
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 = 200;
|
const int flare_threshold = 200;
|
||||||
const int ring_delay = 250;
|
const int ring_delay = 250;
|
||||||
|
|
||||||
|
|
||||||
bool active = false;
|
bool active = false;
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(ledPin, OUTPUT);
|
pinMode(ledPin, OUTPUT);
|
||||||
pinMode(buttonPin, INPUT);
|
pinMode(buttonPin, INPUT_PULLUP);
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("Doorbell sensor");
|
Serial.println("Doorbell sensor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
int val = digitalRead(buttonPin);
|
int val = digitalRead(buttonPin);
|
||||||
|
|
||||||
|
|
||||||
if (val == LOW) {
|
if (val == LOW) {
|
||||||
delay(flare_threshold); // catch flares
|
delay(flare_threshold); // catch flares
|
||||||
val = digitalRead(buttonPin);
|
val = digitalRead(buttonPin);
|
||||||
@@ -45,8 +41,10 @@ void loop() {
|
|||||||
Serial.print(flare_threshold);
|
Serial.print(flare_threshold);
|
||||||
Serial.println(")");
|
Serial.println(")");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
digitalWrite(ledPin, LOW);
|
digitalWrite(ledPin, LOW);
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -2,6 +2,8 @@
|
|||||||
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/
|
||||||
|
|
||||||
|
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>
|
#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_SPRINKLER2 = 33; // relais pin for sprinkler 2
|
||||||
const int PIN_SPRINKLER3 = 32; // relais pin for sprinkler 3
|
const int PIN_SPRINKLER3 = 32; // relais pin for sprinkler 3
|
||||||
const int PIN_SPRINKLER4 = 26; // 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 = 35; // moisture sensor analog value
|
||||||
const int PIN_MOISTURE_DIGITAL = 27; // moisture sensor digital value
|
const int PIN_MOISTURE_DIGITAL = 27; // moisture sensor digital value
|
||||||
|
|
||||||
AsyncWebServer server(80);
|
AsyncWebServer server(80);
|
||||||
|
|||||||
Reference in New Issue
Block a user