Hello,
I am very new to Blynk. I had a previous project in the legacy app for opening my garage door with ESP 8266. IT seemed to work great and the occasional freeze requiring reboot of the router and the esp device. Since Blynk IOT, cannot get it to work. I tried diffrent things.
I need to have a counter that tell me when the status of digital pin 2 has changed to low I think in order to activate a counter and if greater than 5 minutes if sends a notification repeatidly every minute ontil the garage door closes. I also would want to be able to deactivate this notification.
Here is the old sketch
#include <Blynk.h>
/*************************************************************
This is the latest and likely final rev of my Smartphone Garage Door Opener sketch
using the Adafruit Feather Huzzah board and the Blynk framework. It's pretty robust
and yells at you when you leave the garage door open too long. I hope it serves you well.
Tyler Winegarner, 2017
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = ########
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = ######
char pass[] = ########
// Select your pin with physical button
const int doorPin = 2;
int warnPin;
int warnThreshold = 2000;
int tick = 0;
WidgetLCD lcd(V3);
BlynkTimer timer;
BLYNK_WRITE(V1) {
warnPin = param.asInt();
}
// V3 LED Widget represents the physical button state
boolean btnState = false;
void buttonLedWidget()
{
// Read button
// If state has changed...
if (digitalRead(doorPin) == HIGH) {
lcd.print(0,0, "Porte Garage Ouverte "); means garage door open in french
tick++;
} else {
lcd.print(0,0, "Porte Garage Fermée"); means garage door cosed in french
tick = 0;
Blynk.virtualWrite(warnPin, LOW);
}
if (tick > warnThreshold) {
if (warnPin == LOW) {
Blynk.notify("LE GARAGE EST OUVERT!"); warning me the garage door is opened pass 5 min.
tick = (tick - 500);
}
}
Blynk.virtualWrite(V2, tick);
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
// Setup physical button pin (active low)
pinMode(doorPin, INPUT);
timer.setInterval(10, buttonLedWidget);
}
void loop()
{
Blynk.run();
timer.run();
}
My new sketch.
Work in progress.
/*************************************************************
You’ll need:
- Blynk IoT app (download from App Store or Google Play)
- ESP8266 board
- Decide how to connect to Blynk
(USB, Ethernet, Wi-Fi, Bluetooth, ...)
There is a bunch of great example sketches included to show you how to get
started. Think of them as LEGO bricks and combine them as you wish.
For example, take the Ethernet Shield sketch and combine it with the
Servo example, or choose a USB sketch and add a code from SendData
example.
*************************************************************/
"" /* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID ########
#define BLYNK_TEMPLATE_NAME "Quickstart Device"
#define BLYNK_AUTH_TOKEN #######
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = #########
char pass[] = ######
// Select your pin with physical button
const int doorPin = 2;
int warnPin;
int warnThreshold = 100;
int tick = 0;
WidgetLCD lcd(V3);
BlynkTimer timer;
// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(doorpin)/*devrait etre V0*/
{
// Set incoming value from pin V0 to a variable
int value = param.asInt();
// Update state
Blynk.virtualWrite(V4, value);
}
BLYNK_WRITE(V1) {
warnPin = param.asInt();
}
// V3 LED Widget represents the physical button state
boolean btnState = false;
void buttonLedWidget()
{
// Read button
// If state has changed...
if (digitalRead(doorPin) == HIGH) {
lcd.print(0,0, "Porte Gar Fermee"); means garage door closed
tick++;
} else {
lcd.print(0,0, "Porte Gar Ouvert"); means garage door opened
tick = 0;
Blynk.virtualWrite(warnPin, LOW);
}
if (tick > warnThreshold) {
if (warnPin == HIGH) {Blynk.logEvent("test3");
/*Blynk.notify("LE GARAGE EST OUVERT!")*/
tick = (tick - 500);
}
}
Blynk.virtualWrite(V2, tick);
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// You can also specify server:
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
// Setup physical button pin (active low)
pinMode(doorPin, INPUT);
timer.setInterval(10, buttonLedWidget);
}
void loop()
{
Blynk.run();
timer.run();
}
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
Iphone 11 as device.
Help would be appreciated. Please remember, very new to this.