BLYNK
BLYNK.IO       šŸ“² GETTING STARTED       šŸ“— DOCS       šŸ‘‰ SKETCH BUILDER

Timer implementation stops my script at the start

Im running Arduino Uno and Esp8266

Adding BlynkTimer causes my sketch to stop on Blynk.begin function, and not processing any further. It could be something with other libraries that Iā€™m using

If I dont include RTClib it works fine.

I think this post describes a problem very similar to mine but he is running on some other hardware SOLVED: Any timer kills my sketch (ESP core version)

This is my code :
I know it is kind of messy but I will try to anwser any questions about it

#define BLYNK_PRINT Serial


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <WidgetRTC.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "LRJWdn_W0OOln4_5KmGpZRwnsEB_i9Ev";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Router Local WIFI"; //RouterTOTO 2.4GHz
char pass[] = "malina123";//malina123



// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(5, 6); // RX, TX
BlynkTimer timer;

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);
//WidgetRTC Wrtc;

#include <ShiftRegister74HC595.h>
#include <math.h>

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 Hrtc;

ShiftRegister74HC595<3> sr (2, 3, 4);

byte zero = 0;

const int  minusButton = 8;
const int  plusButton = 9;

static int secPins [2][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}}; // first units then dec
static int minPins [2][4] = {{8, 9, 10, 11}, {12, 13, 14, 15}};
static int hourPins [2][4] = {{16, 17, 18, 19}, {20, 21, 22, 23}};

DateTime last = (2020, 03, 06, 00, 00, 00, 00);
int mode = 1;

byte decToBcd(byte val) {
  return ((val / 10 * 16) + (val % 10));
}
byte bcdToDec(byte val) {
  return ((val / 16 * 10) + (val % 16));
}



void setDateToRTC(byte seconde, byte minutee, byte houre, byte weekDaye, byte monthDaye, byte monthe) {
  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero); //stop Oscillator

  Wire.write(decToBcd(seconde));
  Wire.write(decToBcd(minutee));
  Wire.write(decToBcd(houre));
  Wire.write(decToBcd(weekDaye));
  Wire.write(decToBcd(monthDaye));
  Wire.write(decToBcd(monthe));
  Wire.write(decToBcd(byte(2021)));

  Wire.write(zero); //start

  Wire.endTransmission();

}

void nixieWrite(int pins[], uint8_t value) { // gets set of pins for nixie digit and number, and sends it to
  sr.set(pins[3], (value & 0x08) >> 3);
  sr.set(pins[2], (value & 0x04) >> 2);
  sr.set(pins[1], (value & 0x02) >> 1);
  sr.set(pins[0], value & 0x01);
}

void ClockHourWrite() { // get time and prints on the clocks digits

  DateTime now = Hrtc.now();
  //Serial.println(String(now.second()) + ":" + now.minute() + ":" + now.hour());
  //Serial.println(now.second());
  nixieWrite(secPins[0], now.second() % 10); //sec unit
  if (floor(last.second() / 10) != floor(now.second() / 10)) {
    nixieWrite(secPins[1], floor(now.second() / 10)); //sec dec
  }

  if (last.minute() % 10 != now.minute() % 10) {
    nixieWrite(minPins[0], now.minute() % 10);
  }
  if (floor(last.minute() / 10) != floor(now.minute() / 10)) {
    nixieWrite(minPins[1], floor(now.minute() / 10));
  }

  if (last.hour() % 10 != now.hour() % 10) {
    nixieWrite(hourPins[0], now.hour() % 10);
  }
  if (floor(last.hour() / 10) != floor(now.hour() / 10)) {
    nixieWrite(hourPins[1], floor(now.hour() / 10));
  }

  last = now;

}

void ClockDateWrite() { // get time and prints on the clocks digits

  DateTime now = Hrtc.now();
  Serial.println(String(now.day()) + ":" + now.month() + ":" + now.year() % 2000);

  if (last.day() != now.day()) {
    nixieWrite(secPins[0], (now.year() % 2000) % 10);
    nixieWrite(secPins[1], floor((now.year() % 2000) / 10));

    nixieWrite(minPins[0], now.month() % 10);
    nixieWrite(minPins[1], floor(now.month() / 10));

    nixieWrite(hourPins[0], now.day() % 10);
    nixieWrite(hourPins[1], floor(now.day() / 10));

    last = now;
  }
}

void ClockCustomWrite() {
  //This will be custom number to display

}

void clockLoop() {
  Serial.println("tick");
  
  //if(mode==1)
  ClockHourWrite();
  //else if(mode==2)
  //ClockDateWrite();
  //else //mode 3
  //ClockCustomWrite();
}

void setup()
{
  // Debug console
  Serial.begin(9600);

#ifndef ESP8266
  while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

  /*if (! Hrtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    abort();
  }*/
  EspSerial.begin(ESP8266_BAUD);
  delay(100);

  Blynk.begin(auth, wifi, ssid, pass);

  
  Serial.println("connected up!");
  Serial.println(Hrtc.begin());
  timer.setInterval(1000L, clockLoop);//every second call clockloop function


}


BLYNK_WRITE(V10) // V10 is the number of Virtual Pin
{
  if (param.asInt() == mode) {
    return;
  }


}
BLYNK_WRITE(V9)// set time to RTC from Blynk server
{
  if (param.asInt() == 1) {
    Serial.println("settingTime");
  }
  return;
}

void loop()
{

  Blynk.run();
  timer.run();
}

BLYNK_CONNECTED() {
  Blynk.syncAll();  // Synchronize hardware with App widgets when connected
  //Wrtc.begin();
}

A post was merged into an existing topic: Adding Timer to my skech stopps it at the beggining