Code stopps after adding one library

Im using Arduino Uno with RTC ds1307 and esp8266 (Blynk)

my code just stops at the setup function precisely on the Blynk.begin function.
I have discovered that If I just get rid of all related to RTClib.h or SimpleTimer it works just file alone.

Similar problem id described and solved here but is that exaple is used NodeMCU, not Arduino

As you see Im using more than those libraries in my code and the code is kind of long itself, it could be a memory shortage on Arduino side.
image

This is my full code:


#define BLYNK_PRINT Serial

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

char auth[] = "";//private

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = ""; //private
char pass[] = "";//private

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(5,6); // RX, TX
BlynkTimer timer;

#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);


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

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



RTC_DS1307 rtc;

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;

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 ClockHourWrite(){// get time and prints on the clocks digits
 
 DateTime now = rtc.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 = rtc.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 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);
 }
/*
BLYNK_CONNECTED() {
 // Synchronize time on connection
 Wrtc.begin();
}
*/

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

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

 // Set ESP8266 baud rate
 EspSerial.begin(ESP8266_BAUD);
 delay(10);

 Blynk.begin(auth, wifi, ssid, pass);
 Serial.println("connected up!");
 timer.setInterval(1000L, clockLoop);//every second call clockloop function
 


   //rtc thing:
 if (! rtc.begin()) {
 Serial.println("rtcNotRunning");
}
//if (! rtc.isrunning()) {
 
 //setDateToRTC(second(),minute(),hour(),weekday(),day(),month());
 DateTime now = rtc.now();
 Serial.println(String(now.second())+":"+now.minute()+":"+now.hour()+"   "+now.year());
 nixieWrite(hourPins[1],floor(now.hour()/10));
 nixieWrite(hourPins[0],now.hour()%10);
 nixieWrite(minPins[1],floor(now.minute()/10));
 nixieWrite(minPins[0],now.minute()%10);
 nixieWrite(secPins[1],floor(now.second()/10));
 nixieWrite(secPins[0],now.second()%10);

 last = now;
 
}

BLYNK_WRITE(V10) // V10 is the number of Virtual Pin  
{
 if(param.asInt()==mode){return;}
switch(param.asInt()){//change DisplayMode
 case 1:
 {
    mode=1;
    Serial.println("hour");
    DateTime now = rtc.now();
    nixieWrite(hourPins[1],floor(now.hour()/10));
    nixieWrite(hourPins[0],now.hour()%10);
    nixieWrite(minPins[1],floor(now.minute()/10));
    nixieWrite(minPins[0],now.minute()%10);
    nixieWrite(secPins[1],floor(now.second()/10));
    nixieWrite(secPins[0],now.second()%10);
    break;
   }
 case 2:
 {
   mode=2;
   Serial.println("date");
   DateTime now = rtc.now();
   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));
   break;
 }
 case 3:
 {
    mode=3;
   Serial.println("Custom");    
   break;
   }
 }
}
BLYNK_WRITE(V9)// set time to RTC from Blynk server
{
 if(param.asInt()==1){
 setDateToRTC(second(),minute(),hour(),weekday(),day(),month());
 }
}


void loop()
{
 Blynk.run();
 timer.run();

}

Your topic has been moved here as this forum section is more relevant to the subject than where it was originally posted

I think you have already identified your problem: memory shortage.

Solution would be to reduce memory usage. I think you forgot to post a question related to your problem.

So If compiler shows that im 90% on Unos memory arduino still can use additional when running the code to store all the variables. Accualy my code is not even fully finished yet, so there is more code coming. I could invest in board with more memory than 32kb.

I see an option to buy arduino mega board, but it is much larger in size or buy an esp32, that has much more memory and wifi connection that im for now using external esp8266 chip and its more cheaper than arduino mega. Idk if esp32 is the right choise, and why is it so uch cheaper and has more resources, I have to be missing something.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.