indent preformatted text by 4 spaces[quote="trentonf4i, post:1, topic:26478, full:true"]
Hello Blynkers, I have a garage door project that I need help with. I am teaching my self so it very well could be an obvious answer. I have a WeMos D1 mini with a DHT sheild and a Relay shield. The project works fine as of now but I wanted to add a notification when the door is left up for longer than 10 or 15 minutes. I have seen other code that allows a notification if a temperature gets to high or at a certain time with the timer, but I was wanting it to realize the change in the switch and start counting till 30 minutes and then let me know I left the door up. The code I putting up is the very basic that works as of now to open and close the door with a relay, read the temperature status and show the status of the magnetic switch I have on the door. The Magnetic switch is on D2 and when its low the switch is together and when its high then the switch is broken and the door is up. I will also show a picture of the code that i tried to implement but it will only send me an alert as soon as the switch is broken. I would just want it on a timed delay to notify me. Any help would be greatly appreciated!!
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "xxxxxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
#define DHTPIN D4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(true); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void setup() {
// put your setup code here, to run once:
Blynk.begin(auth, ssid, pass);
dht.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop() {
// put your main code here, to run repeatedly:
Blynk.run();
timer.run();
}
[/quote]
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "xxxxxxxxxxxxxxxx";
char pass[] = "xxxxxxxxxl";
#define DHTPIN D4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
int inputPin = D2:
BlynkTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(true); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void setup() {
pinMode(inputPin, INPUT);
Blynk.begin(auth, ssid, pass);
dht.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop() {
if(digitalRead(inputPin == HIGH > 10000){
Blynk.notify("Garage Door - Put Me Down!");
}
Blynk.run();
timer.run();
}