BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Timer and Blynk Hardware provisioning

Timer isnt working in the blynk Provisioning.

I have tested the hardware and timer widget with a regular project, connecting the hardware directly to the project and it works. When I use the NodeMCU provisioning, everything is working, Led, Relay, relay + a button, but when I include the timer, doesnt work.

I have also read the virtual pin of the timer, and voila! I found what is happening, or at least I think I found it! :slight_smile:

When I check the API URL, the value is “1” or “0”, but if I change it from the app, nothing happens. Then I went back to some old projects and I realize that the API was reading the project timer and not the app timer, but Relay and NodeMCU is linked to the App timer and not the project timer as in original projects with Blynk.

So I guess, Timer is not working in Blynk Provisioning. The code is as simple as the one in the regular projects, but this one is not working at all.

Any ideas? Here down below the details:

  1. Search forum for similar topics: I searched a lot but nothing appeared.
  2. Add details :
    • Hardware model: NodeMCU v3 ESP8266 Lolin1 § communication type: WIFI ESP8266
    • Smartphone OS: Android + version 9 (Samsung Galaxy S8)
    • Blynk server
    • Blynk Library version: 0.6.1

My Sketch:


#define USE_NODE_MCU_BOARD
#define APP_DEBUG        // Comment this out to disable debug prints

#define BLYNK_PRINT Serial


#include "BlynkProvisioning.h"

// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V12);

#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11 
#define BMP_CS 10

Adafruit_BMP280 bme; // I2C

//Registering Led pin 1
WidgetLED led10(V10);


BlynkTimer timer;
/------------------- Global Variables --------------------------
unsigned long previousMillis = 0;
int AmbTemp = 0;

void requestTime() {
  Blynk.sendInternal("rtc", "sync");
}

BLYNK_WRITE(InternalPinRTC) {
  long t = param.asLong();
  Serial.print("Unix time: ");
  Serial.print(t);
  terminal.println(t);
  Serial.println();
}
void setup() {
  delay(500);
  Serial.begin(115200);

  pinMode(14, OUTPUT);

 Serial.println(F("BMP280 test"));
  
  if (!bme.begin()) {  
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1);
  }

  timer.setInterval(10000L, requestTime);
  timer.setInterval(1000L, sendSensor);
  BlynkProvisioning.begin();

}

void sendSensor(){

    int TempNow;

    Serial.print("T=");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");

    TempNow = bme.readTemperature();
    Blynk.virtualWrite(V6, TempNow);
    AmbTemp = bme.readTemperature();
}

void loop() {

    unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= 5000) { //envia la temperatura cada 5 segundos
    previousMillis = currentMillis;

  }

  timer.run();
  BlynkProvisioning.run();

}


BLYNK_WRITE(V3) { //Blynk Timer Widget

      if (param.asStr()=="1") {
          //HIGH
          Serial.println(">>>> Sistema Temporizador Accionado <<<<<");
          pin_activated();
      } else {
         //LOW
         pin_deactivated();
      }
}

void pin_activated(){
    led10.on();  //LED 10 "HIGH"
    digitalWrite(14, 1);        //relay is on 
    Serial.println("Pin Activado");
    sendSensor();
}

void pin_deactivated(){
    led10.off();    //LED "LOW"
    digitalWrite(14, 0);        //relay is off
    Serial.println("Pin Desactivado");
    sendSensor();
}