I have a small project where I have 2 leds controlled with buttons for on and off and a slider for each controlling their brightness with PWM. The leds are blue and white.
I want to add a simple schedule where the blue leds come on at a set time, and off again at a set time. The same for the white leds.
I have the buttons and sliders working but adding the timer is confusing as I cant select a digital pin on the widget only a virtual one. So I added this code:
Yeah I have seen that and the only thing that isnt in the getting started code is
BLYNK_WRITE(V5)
{
// You'll get HIGH/1 at startTime and LOW/0 at stopTime.
// this method will be triggered every day
// until you remove widget or stop project or
// clean stop/start fields of widget
Serial.print("Got a value: ");
Serial.println(param.asStr());
}
I have tried this code. Something isnt right still, I presume with my app on my phone. I have a timer, the start time is 8:00 and the end is 22:00 Pin is V5… Sorry I feel I am being dense.
The thing is the button works great. I just want the app to press the button essentially… I even tried deleting the button, so no conflict there. Tried just pointing the timer at the digital pin and even that doesnt work. Do I need to get the time into the sketch itself?
D2 is not the pin you are using in your sketch, you are using GPIO 2.
D2 is GPIO 4.
The D references printed on ESP boards are not like Arduino’s where they match the GPIO’s.
Sorry I dont follow. I am not using the V5 at the moment, just trying to get the timer widget to turn the pin on using D2. If it was V5 I would get what your saying through!
Suggest changing these so we don’t have to wait until tomorrow morning.
Ensure your phone has the correct time (most are updated by the internet but some are not). If it’s wrong by a minute or two it will give you false readings.
Then set timer widget for on in 2 minutes time and off in 3 minutes time.
Ok so I misunderstood that the timer would not activate unless is was exactly the start time! Setting the time to a few mins in the future worked if I set the timer to D2. However my V5 still doesnt work.
this is my sketch
#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[] = "a307f39e0d9f45c88211f1376d00aafc";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "PrettyFlyForAWifi";
char pass[] = "reidbuck";
BLYNK_WRITE(V5)
{
if (param.asInt()) {
digitalWrite (4, HIGH);
Blynk.notify("Blues are ON");
} else {
digitalWrite (4,LOW);
Blynk.notify("Blues are OFF");
}
Serial.print("Got a value: ");
Serial.println(param.asStr());
}
BLYNK_WRITE(V6)
{
if(param.asInt()) {
digitalWrite (16, HIGH);
Blynk.notify("Whites are ON");
} else {
digitalWrite (16,LOW);
Blynk.notify("Whites are OFF");
}
Serial.print("Got a value: ");
Serial.println(param.asStr());
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
}
Timer is set to V5.
Connected to Pins D0 and D2 on the nodeMcu which should be GPIO 4 and 16.
Yeah I have a standard timer for both V5 and V6. They work but the TimerInputs dont work at all. Adding a notification to each they both read as on as soon as i “play” the app way before the timer is due to go off. standard timers will have to do i suppose!