The timer doesn’t work anymore. But right before the update it did. I have nothing changed…
@hutje before the 2.9.0 update the Timer widget was changed and required mods to your sketch. Did you make the mods as per the new Timer widget example?
No, didn’t edit my sketch for months because it worked…
You mean the 0 and 1 instead of LOW and HIGH?
This worked after the change.
If you don’t want to follow the Announcements made by Blynk disable auto update of the app.
Do you use local server? I see issue is solved. All is ok now?
No not yet. I have local server. Before the android update everything worked fine. Now I don’t get the virtualWrite on fader. Also don’t get output of the timer. But when I replace the timer for a button, it works…
Do I need to put the Timer as param.asStr or can it still be param.asInt?
Did you update your local server?
How do I need to put the timer? I always had
BLYNK_WRITE(V27){
alarmTrigger = param.asInt;
alarmMode();
}
and then
void alarmMode(){
if (alarmTrigger == 1){
....
}
}
Only Timer widget. I have rtc but don’t know exactly why I have it😂
It’s set to amsterdam Europe but don’t use it in my code
Do I need to change this to param.asStr?
No.
BLYNK_WRITE(V27){
alarmMode(param.asInt());
}
void alarmMode(int p){
if (p == 1){
....
}
}
Thanks, I will try this tonight.
And if I need two inputs to be high before executing the void?
Sorry, I am new with parameters inside the () of a void…
I currently have this and this worked a few days ago, now the alarmTrigger (button) does work, but the alarmTrigger (timer-widget) doesn’t anymore…
This is the toggle to turn on/off the alarm.
BLYNK_WRITE(V30) {
alarmToggle = param.asInt();
alarmMode();
}
This is the toggle for the alarmTrigger as timer
BLYNK_WRITE(V27) { //alarmTrigger, to enter alarmMode with timer-widget
alarmTrigger = param.asInt();
alarmMode();
}
This is a toggle to enter alarmMode without timer-widget but button
BLYNK_WRITE(V28) //alarmTrigger button, to enter alarmMode with just a button instead of timer
alarmTrigger = param.asInt();
alarmMode();
}
void alarmMode() {
if (alarmToggle == HIGH && alarmTrigger == HIGH) {
presetMode = LOW;
Blynk.virtualWrite(V44, presetMode);
varManualMode = LOW;
Blynk.virtualWrite(V10, varManualMode);
varBrightness = (int)0;
Blynk.virtualWrite(V2, varBrightness);
wakeUpModeON = true;
wakeUpMode();
}
if (alarmTrigger == LOW || alarmToggle == LOW) {
wakeUpFirstStart = true;
wakeUpModeON = false;
alarmTimer.deleteTimer(alarm1);
}
}
This is the code I now have for my Wake up light.
When I try to enable the alarmTrigger with the button it works fine.
But when I try to trigger it with the timer, nothing happens.
Also when the alarm is enabled the slider for the brightness normally moves every step. But now it doesn’t during the alarm fading, but when I read its value from terminal, it is updated.
For those who want to help me, please
/****************************************************************************/
#define BLYNK_PRINT Serial
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <FastLED.h>
#include <SimpleTimer.h>
//#include <WidgetRTC.h>
/**********************TEST WEBSERVER UPLOAD************************************************/
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
#include <ESP8266WebServer.h>
ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;
/****************************************************************************/
#define BLYNK_MSG_LIMIT 200
#define DATA_PIN D6
/************************ *************************/
#define NUM_LEDS 150
char nickname[] = "LED1";
char auth[] = "XXXXXXXXXXXXXXXXXXXXXXXXX";
/****************************************************************************/
int varHue;
int varSaturation;
float varBrightness;
int varManualMode;
int varNextColour;
int varNextColourPrev;
int varBlendingMode;
int varUpdatesPerSec;
int varAlertMode;
int varRainbowSpeed;
long HexRGB;
int varBrightnessPrev;
boolean varManualModePrev;
boolean alarmToggle = 1;
boolean alarmTrigger = 0;
int alarmHue = 20;
int alarmSaturation = 200;
float alarmBrightness = 255.00000;
float timeOfFade = 60.00000;
boolean wakeUpModeON = false; //Blocks RGB Control during alarm !ONLY IN CODE NOT IN BLYNK-APP!
boolean wakeUpFirstStart = true; // Makes settings for first start wakeUpModeON.
float fadeStep = 0.00000;
boolean previewAlarm;
//WidgetRTC rtc;
//
//BLYNK_ATTACH_WIDGET(rtc, V24);
/****************************************************************************/
WidgetTerminal terminal(V9);
SimpleTimer timer;
SimpleTimer alarmTimer;
int alarm1;
CRGB leds[NUM_LEDS];
/****************************************************************************/
void sendUptime() {
Blynk.virtualWrite(V16, millis() / 1000);
Blynk.virtualWrite(V17, map(WiFi.RSSI(), -105, -40, 0, 100) );
}
/****************************************************************************/
void setup()
{
WiFi.mode(WIFI_STA);
Blynk.begin(auth, "xxxxxxxx", "xxxxxxxxx", "RASPBERRYPI");
while (Blynk.connect() == false) {}
/*********** OTA *************/
ArduinoOTA.setHostname("ESP-WAKEUP");
ArduinoOTA.begin();
/*********** TEST *************/
MDNS.begin("ESP-WAKEUP");
httpUpdater.setup(&httpServer);
httpServer.begin();
MDNS.addService("http", "tcp", 80);
/******** BOOT VARS **********/
varSaturation = 255; // Start Full Colour
varBrightness = 0; // Start Full Brightness
varManualMode = 1; // Start in preset mode
varNextColour = 0; //
varNextColourPrev = 0; // Set Button State
varBlendingMode = 1; // Start LINEARBLEND
varUpdatesPerSec = 128; // Start on 100 fps
varAlertMode = 0; // Start Alert Mode OFF
varRainbowSpeed = 0; // Start stationary
/******** FASTLED ************/
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
/******** READY **************/
terminal.print(F("# Blynk v" BLYNK_VERSION ": "));
terminal.print(nickname);
terminal.println(F(" Device started"));
terminal.flush();
timer.setInterval(1000L, sendUptime);
Blynk.syncAll();
rtc.begin();
}
/****************************************************************************/
// List of patterns to cycle through. Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle };
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
/****************************************************************************/
BLYNK_WRITE(V0) {
varHue = param.asInt();
//HexRGB = ((long)leds[0].r << 16) | ((long)leds[0].g << 8 ) | (long)leds[0].b;
//Blynk.setProperty(V0, "color", "#" + String(HexRGB, HEX));
}
BLYNK_WRITE(V1) {
varSaturation = param.asInt();
}
BLYNK_WRITE(V2) {
varBrightness = param.asInt();
}
BLYNK_WRITE(V3) {
varNextColour = param.asInt();
if (varNextColour == 1 && varNextColourPrev == 0) {
nextPattern();
}
varNextColourPrev = varNextColour;
}
BLYNK_WRITE(V4) {
varManualMode = 1;
varHue = (int)165;
varSaturation = (int)255;
Blynk.virtualWrite(V1, varSaturation);
Blynk.virtualWrite(V10, varManualMode);
Blynk.virtualWrite(V0, varHue);
}
BLYNK_WRITE(V6) {
varManualMode = 1;
varHue = (int)0;
varSaturation = (int)255;
Blynk.virtualWrite(V1, varSaturation);
Blynk.virtualWrite(V10, varManualMode);
Blynk.virtualWrite(V0, varHue);
}
BLYNK_WRITE(V7) {
varManualMode = 1;
varHue = (int)100;
varSaturation = (int)255;
Blynk.virtualWrite(V1, varSaturation);
Blynk.virtualWrite(V10, varManualMode);
Blynk.virtualWrite(V0, varHue);
}
BLYNK_WRITE(V8) {
varManualMode = 1;
varSaturation = (int)0;
Blynk.virtualWrite(V10, varManualMode);
Blynk.virtualWrite(V1, varSaturation);
}
BLYNK_WRITE(V10) {
varManualMode = param.asInt();
if (varManualMode == 1) {
previewAlarm = LOW;
Blynk.virtualWrite(V35, previewAlarm);
}
}
BLYNK_WRITE(V11) {
gHue = 0;
terminal.print(nickname);
terminal.println(" | Sync'd gHUE ");
terminal.flush();
}
BLYNK_WRITE(V15) {
varManualMode = 1;
varHue = (int)12;
varSaturation = (int)255;
Blynk.virtualWrite(V1, varSaturation);
Blynk.virtualWrite(V10, varManualMode);
Blynk.virtualWrite(V0, varHue);
}
BLYNK_WRITE(V12) {
varManualMode = 1;
varHue = (int)26;
varSaturation = (int)255;
Blynk.virtualWrite(V1, varSaturation);
Blynk.virtualWrite(V10, varManualMode);
Blynk.virtualWrite(V0, varHue);
}
BLYNK_WRITE(V13) { //alert button
varAlertMode = param.asInt();
terminal.print(nickname);
terminal.println(" | ALERT!");
terminal.flush();
}
BLYNK_WRITE(V14) { //off button lights
varManualMode = 1;
varBrightness = 0;
Blynk.virtualWrite(V10, varManualMode);
Blynk.virtualWrite(V2, varBrightness);
}
BLYNK_WRITE(V22) {
varRainbowSpeed = param.asInt();
}
BLYNK_WRITE(V28) { //alarmTrigger, to enter alarmMode with just a button instead of timer
alarmTrigger = param.asInt();
alarmMode();
}
BLYNK_WRITE(V27) { //alarmTrigger, to enter alarmMode with timer-widget
alarmTrigger = param.asInt();
alarmMode();
}
BLYNK_WRITE(V30) {
alarmToggle = param.asInt();
alarmMode();
}
BLYNK_WRITE(V31) {
alarmHue = param.asInt();
}
BLYNK_WRITE(V36) {
alarmSaturation = param.asInt();
}
BLYNK_WRITE(V33) {
alarmBrightness = param.asInt();
if (previewAlarm == HIGH) {
varBrightness = alarmBrightness;
Blynk.virtualWrite(V2, alarmBrightness);
}
}
BLYNK_WRITE(V34) {
timeOfFade = param.asInt() * 60; // Writes time of fade to seconds
terminal.print("timeOfFade: ");
terminal.println(timeOfFade);
terminal.flush();
}
BLYNK_WRITE(V35) {
previewAlarm = param.asInt();
if (previewAlarm == HIGH) {
varManualModePrev = varManualMode;
varBrightnessPrev = varBrightness;
varBrightness = alarmBrightness;
varManualMode = false;
Blynk.virtualWrite(10, varManualMode);
}
if (previewAlarm == LOW) {
varManualMode = varManualModePrev;
varBrightness = varBrightnessPrev;
Blynk.virtualWrite(10, varManualMode);
}
}
/****************************************************************************/
void alarmMode() {
if (alarmToggle == HIGH && alarmTrigger == HIGH) {
varManualMode = LOW;
Blynk.virtualWrite(V10, varManualMode);
varBrightness = 0;
Blynk.virtualWrite(V2, varBrightness);
wakeUpModeON = true;
wakeUpMode();
}
if (alarmTrigger == LOW || alarmToggle == LOW) {
wakeUpFirstStart = true;
wakeUpModeON = false;
alarmTimer.deleteTimer(alarm1);
}
}
void wakeUpMode() {
if (wakeUpModeON = true) {
if (wakeUpFirstStart == true) {
fadeStep = alarmBrightness / timeOfFade;
terminal.print("fadeStep: ");
terminal.println(fadeStep);
wakeUpFirstStart = false;
alarm1 = alarmTimer.setTimer(1000, alarmFader, timeOfFade);
alarmTimer.enable(alarm1);
}
}
}
//FADING
void alarmFader() {
varBrightness += fadeStep;
Blynk.virtualWrite(V2, varBrightness);
Blynk.virtualWrite(V5, varBrightness);
/*********DEBUGGING SLIDER UPDATE*******************/
terminal.print("varBrightness during alarm: ");
terminal.println(varBrightness);
terminal.flush();
}
/****************************************************************************/
void loop()
{
Blynk.run();
ArduinoOTA.handle();
httpServer.handleClient(); //TEST*******************************************************
timer.run(); // Initiates SimpleTimer
alarmTimer.run();
// updateTimer.run();
if (varAlertMode == 1) {
for (int i = 0; i < 20; i++) {
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.show();
FastLED.delay(50);
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
FastLED.delay(50);
}
varAlertMode = 0;
}
if (varManualMode == 1 && (alarmTrigger == LOW || alarmToggle == LOW)) { // Manual Control
fill_solid(leds, NUM_LEDS, CHSV(varHue, varSaturation, varBrightness));
FastLED.show();
}
if (varManualMode == 0 && ((alarmTrigger == HIGH && alarmToggle == HIGH) || previewAlarm == HIGH)) { // Manual Control
fill_solid(leds, NUM_LEDS, CHSV(alarmHue, alarmSaturation, varBrightness));
FastLED.show();
}
if (varManualMode == 0 && (alarmTrigger == LOW || alarmToggle == LOW) && previewAlarm == LOW) { // Pallette Mode
gPatterns[gCurrentPatternNumber]();
FastLED.show();
// updateTimer.setInterval(varUpdatesPerSec, updatePerSec);
FastLED.delay(1000 / varUpdatesPerSec);
EVERY_N_MILLISECONDS( 20 ) {
gHue++; // slowly cycle the "base color" through the rainbow
}
}
FastLED.show();
}
/****************************************************************************/
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
void nextPattern() {
// add one to the current pattern number, and wrap around at the end
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}
void rainbow() {
// FastLED's built-in rainbow generator
fill_rainbow( leds, NUM_LEDS, gHue, varRainbowSpeed);
}
void rainbowWithGlitter() {
// built-in FastLED rainbow, plus some random sparkly glitter
rainbow();
addGlitter(80);
}
void addGlitter( fract8 chanceOfGlitter) {
if ( random8() < chanceOfGlitter) {
leds[ random16(NUM_LEDS) ] += CRGB::White;
}
}
void confetti() {
// random colored speckles that blink in and fade smoothly
fadeToBlackBy( leds, NUM_LEDS, 10);
int pos = random16(NUM_LEDS);
leds[pos] += CHSV( gHue + random8(64), varSaturation, varBrightness);
}
void sinelon() {
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16(13, 0, NUM_LEDS);
leds[pos] += CHSV( gHue, varSaturation, varBrightness);
}
void juggle() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, NUM_LEDS, 20);
byte dothue = 0;
for ( int i = 0; i < 8; i++) {
leds[beatsin16(i + 7, 0, NUM_LEDS)] |= CHSV(dothue, varSaturation, varBrightness);
dothue += 32;
}
}
I see lots of familiar code in your sketch hah (from my LED controller )
Good work
That’s right! I made an alarm feature with fade, but the timer stopped working. I got it working with eventor, but I want to easily change the timer. Every day I need to get up an other time.
Okay, Timer works. Saw on he github that there was a new update. Normally I look on the docs.blynk.com but there was 0.22.1 and on git was 0.22.2.
But still got problem with slider that won’t sync during the fade…
I am having trouble with the timer widget on my esp8266 standalone. I haven’t gotten into the Eventor widget yet, I just wanted to figure out the simple timer example. The Button widget works fine. Android phone time is set to network. I am running a local server. Here’s my sketch:
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#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[] = "***";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, IPAddress(192.168.100.1));
}
void loop()
{
Blynk.run();
}
I saw someone mention there were supposed to be changes to the sketch for the simple timer widget to work. I am not sure what those are. By the way, when I tried the timer widget on an arduino connected with ethernet before the recent app updates it worked fine.
I have android app version 2.9.0 and I replaced the server-0.22.0 jar file with the server-0.22.2.jar file.
Please help)
Hello. What settings do you have in timer? How exactly do you check it is working?