I2C stopped working after 2 days of use

I am building an automatic feeder for my cat using an Arduino Nano, stepper motor, servo, and a few sensors. I have a load cell with HX711 ADC, a typical 16x2 LCD with I2C backpack, and a DS3231 I2C real-time clock module. Basically, time is read and at specific times the motor dispenses food which is weighed and dropped into a bowl. The LCD is used to display information about the last feeding time and error cases. I finished everything and I had the whole system working flawlessly for 2 days before everything froze up.

I reset the Nano multiple times and it never made it past the setup. With some Serial.print debugging, I was able to narrow my problem to the intializers of the I2C devices ("lcd.begin" and "Clock.begin"). When the code reaches these it hangs forever. I then tried some 4.7kohm pullup resistors on the SDA and SCL lines. Still didn't work...

After more research, I found the Wire library has a spot where it can go into and infinite loop. So I tried a different I2C library called WSWire and it still did not work. Finally, I tried replacing the Nano and that didn't work either. So here I am asking for help.

I have attached some pictures of my circuit. The I2C line to the LCD is about 6 inches long about 1 inch long to the RTC module. The circuit diagram is correct except it is missing the two 4.7k pullup resistors. The SDA line is blue and goes to pin A4 and the SCL line is green and goes to pin A5.

Code wouldn't fit on the first one, sorry.

//============================================================
//                    LIBRARIES
//============================================================
#include <Q2HX711.h>
#include <HX711.h>
#include <Wire.h> 
//#include <WSWire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3231_Simple.h>
#include <Servo.h>

//============================================================
//                    PIN ASSIGNMENTS
//============================================================

// Stepper -----------------------------
#define resetPin 8
#define sleepPin 7
#define stepPin 6
#define dirPin 5
#define MS1 11
#define MS2 10
#define MS3 9

int delayTime = 70;    //step delay in microseconds 70
bool forward = false;
bool backward = true;
int stepCounter = 0;  // keeps track of auger position

// Servo ------------------------------
#define servoPin A3
Servo servo;

// Buzzer -----------------------------
//#define beeperPin

// Panel ---------------------------------
#define greenLEDPin 3
#define redLEDPin 4
#define backlightPin 2
#define buttonPin 5
LiquidCrystal_I2C lcd(0x27, 16, 2);

String feedString;

// HX711 ------------------------------
#define DATPin A1
#define SCKPin A0
float calibration_factor = -2251000;
HX711 scale;
double mass = 0;
double oldMass = 0;

// Real time clock ---------------------
DS3231_Simple  Clock;
DateTime rtcTime;
DateTime lastFedTime;
char lastFedString [16];


bool feedComplete = false;
bool lcdOnComplete = false;
bool lcdOffComplete = false;


//============================================================
//                    SETUP
//============================================================
void setup() {  
  Serial.begin(9600);
  
  
  pinMode(resetPin, OUTPUT);
  pinMode(sleepPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(MS1, OUTPUT); 
  pinMode(MS2, OUTPUT);
  pinMode(MS3, OUTPUT);

  digitalWrite(resetPin, HIGH);
  digitalWrite(sleepPin, LOW);
  digitalWrite(MS1, HIGH); // L L L Full stepping
  digitalWrite(MS2, HIGH); // H L L Half
  digitalWrite(MS3, HIGH); // L H L Quarter
                           // H H L Eighth
                           // H H H Sixteenth
  


  scale.begin(DATPin, SCKPin);
  scale.set_scale(calibration_factor);
  scale.tare(); //set scale to zero

  
  Serial.println("hi");
  //lcd.begin();
  Serial.println("hi");
  
  pinMode(greenLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(backlightPin, OUTPUT);
  digitalWrite(backlightPin, LOW);
  digitalWrite(greenLEDPin, LOW);
  digitalWrite(redLEDPin, LOW);


  Clock.begin();
  Serial.println("hi");
  lastFedTime.Hour = 255;
  delay(50);
  
}

//============================================================
//                    LOOP
//============================================================
void loop() {

  rtcTime = Clock.read();
  Serial.println(rtcTime.Second);
  
  if((rtcTime.Hour == 8 || rtcTime.Hour == 12 || rtcTime.Hour == 16 || rtcTime.Hour == 20) && rtcTime.Minute == 0) {
    if(feedComplete == false) {
       dispenseFood(8);
       delay(1000);
       dispenseFood(8);
       lastFedTime = rtcTime;
       feedComplete = true;
    }
  }
  
  else if(rtcTime.Minute % 5 == 0) {
    if(lcdOnComplete == false) {
      digitalWrite(backlightPin, HIGH);
      
      if(lastFedTime.Hour == 255) {
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print("Not yet fed");
      }
      else{
        sprintf(lastFedString, "%d:%02d Date:%d/%d", lastFedTime.Hour, lastFedTime.Minute, lastFedTime.Month, lastFedTime.Day);
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print("Last fed at:");
        lcd.setCursor(0,1);
        lcd.print(lastFedString);
      }
      
      lcdOnComplete = true;
    }
 
  }
  
  else if(rtcTime.Minute % 5 == 1) {
    if(lcdOffComplete == false) {
      lcd.clear();
      digitalWrite(backlightPin, LOW);
      lcdOffComplete = true;
    }
    
  }
  
  else{
    feedComplete = false;
    lcdOnComplete = false;
    lcdOffComplete = false;
  }


}  
  
  


//============================================================
//                    DISPENSEFOOD
//============================================================
void dispenseFood(int foodWeight) {
  // dispense food equal to weight in grams
  
  float currentWeight = getWeight();

  int stepSize = 800; // steps forward per weight check
  stepCounter = 0;
  int motorJamCounter = 0;
  int servoJamCounter = 0;
  
  digitalWrite(sleepPin, HIGH);
  
  
  while (getWeight() < foodWeight) {
    motorStep(stepSize);
//    lcdWrite(String(getWeight()));
    motorJamCounter++;
    error(motorJamCounter < 20, "Auger is jammed"); // jam counter should always be less than 20
  }

  motorJamCounter = 0;
  digitalWrite(sleepPin, LOW);
  servo.attach(servoPin);
  
  while (scale.get_units(10)*1000 > 0.5) {
  // check weight each loop and make sure that less than 0.5 grams of food remains on scale
    servoShake();
    servoJamCounter++;
    error(servoJamCounter < 4, "Servo is jammed"); // servo jam counter should always be less than 4  
  }
//  servoShake();
  servoJamCounter = 0;
  servo.detach();
}

//============================================================
//                    MOTORSTEP
//============================================================
void motorStep(int numSteps) {
  int motorDirection = (numSteps > 0)? HIGH:LOW;
  digitalWrite(dirPin, motorDirection);
  digitalWrite(greenLEDPin, HIGH);
  int backwardSteps = 1200;
  
  for(int x = 0; x < abs(numSteps); x++) {
    digitalWrite(stepPin, HIGH); 
    delayMicroseconds(delayTime); 
    digitalWrite(stepPin, LOW); 
    delayMicroseconds(delayTime);
    stepCounter++;
    
    if (stepCounter >= 2400) {
      // drive backwards if step counter goes past threshold
      digitalWrite(dirPin, LOW); 
      
      for (x = 0; x < backwardSteps; x++) {
        digitalWrite(stepPin, HIGH); 
        delayMicroseconds(delayTime); 
        digitalWrite(stepPin, LOW); 
        delayMicroseconds(delayTime);
      }
      stepCounter = 0;
    }
  }
  digitalWrite(greenLEDPin, LOW);
  delay(50);
}


//============================================================
//                    SERVOSHAKE
//============================================================
void servoShake() {
  for (int servoPos = 1400; servoPos >= 1050; servoPos--) {
    // servo should go from 1200us to 1500us
    servo.writeMicroseconds(servoPos);
    delay(1);
  }

  for(int ii = 0; ii < 40; ii++) {
    delay(60);
    servo.writeMicroseconds(1050);
    delay(60);
    servo.writeMicroseconds(1150);
  }
  delay(500);
  
  for (int servoPos = 1150; servoPos <= 1400; servoPos++) {
    // servo should go from 1500us to 1200us
    servo.writeMicroseconds(servoPos);
    delay(1);
  }
  
}


//============================================================
//                    GETWEIGHT
//============================================================

float getWeight()  {
  return scale.get_units()*1000;
}

//============================================================
//                    ERROR
//============================================================
void error(bool condition, String errorCode) {
  if (!condition) {
    digitalWrite(sleepPin, LOW);
    digitalWrite(backlightPin, HIGH);
    
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Error:");
    lcd.setCursor(0,1);
    lcd.print(errorCode);
    
    while(1) {
      digitalWrite(redLEDPin, HIGH);
      delay(100);
      digitalWrite(redLEDPin, LOW);
      delay(500);
    }
  }
}

    
}

I was able to narrow my problem to the intializers of the I2C devices ("lcd.begin" and "Clock.begin"). When the code reaches these it hangs forever. I then tried some 4.7kohm pullup resistors on the SDA and SCL lines. Still didn't work...

If things were working and now don't I suspect some sort of hardware problem. Run an i2c bus scanner to see what happens. If this scanner hangs at "I2C scanner. Scanning ..." its likely there is a short between sda/scl or either of them to 5v or ground.

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

Well, now I feel dumb. I tested the scanner and it stopped where you predicted. So I checked my circuit and lo and behold the SDA and SCL lines were shorted together... Cleaned up my messy soldering and the scanner worked perfectly. Testing my code as I'm writing this and IT WORKS! Thanks for help cattledog. Karma given