[Solved]Did my Nano has bad SDA and SCL pins?

I build a circuit using Nano to switch relay on/off automatically every 5 second with 16x2 i2C LCD but my Nano did freeze randomly after a couple of seconds.

Here are some experiments I did and made me believe that its my Nano SDA SCL pins that had issue.

  • tried disconnecting LCD SDA and SCL from A4 and A5(VCC and GND still connected) and my Nano seem to work fine and did't freeze anymore but nothing show on LCD.

  • Changing LCD to another one didn't fix the problem.

  • and finally I change the Nano to the new one and put SDA and SCL back to A4 and A5 pins, up until now my Nano still working and no freezing anymore.

Is it possible that the previous Nano has bad SDA SCL pins? if it is, is there a way to fix that? I really don't want to throw it to trash can because it's other pins still work.

Sorry if my English confuse you and thanks in advance.

After left it running for 4478 seconds the issue is comeback again. it's all dark for me now. Can't seem to figure it out what the cause of this. Sometime its not only the freezing but LCD just light-off it self as well.

It is vastly more likely that your secret code is faulty.

Possible cause is using “String” variables.

It is vastly more likely that your secret code is faulty.

Possible cause is using “String” variables.

I don’t have String on my code though. All the texts show on LCD are int and float. Actually, I build a product of current sensors that read AC motor current and switch it off if the current go over the maximum motor can take. This sketch is for testing if all the components are work properly. I already test a lot of my previous products with this sketch and this is the first time that I get this issue.

I’ll leave my code here and do some more experiment and see if I get anything new.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include "EmonLib.h"

EnergyMonitor emon1;
EnergyMonitor emon2;
EnergyMonitor emon3;

int count;
int count2;
int BAuto = 8;
int BManual = 9;
int Bstart = 10;
int Bstop = 11;
int Bautostate;
int Bmanualstate;
int Bstopstate;
int Bstartstate;
float value1;
float value2;
float value3;
int relay1 = 5;
int relay2 = 6;
int relay3 = 7;
float CT = 80;
int relay_state;
boolean Auto_Mode;
boolean Manual_Mode;

void setup()
  emon1.current(A0, CT);          
  emon2.current(A1, CT);
  emon3.current(A2, CT);
  pinMode(BAuto, INPUT);
  pinMode(BManual, INPUT);
  pinMode(Bstart, INPUT);
  pinMode(Bstop, INPUT);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  Auto_Mode = true;

void loop()
  value1 = emon1.calcIrms(1480);  
  value2 = emon2.calcIrms(1480);
  value3 = emon3.calcIrms(1480);
  Bstartstate = digitalRead(Bstart);
  Bstopstate = digitalRead(Bstop);
  Bautostate = digitalRead(BAuto);
  Bmanualstate = digitalRead(BManual);

  switch (Auto_Mode) {
    case true :
      relay_state = 0;
      if (Bmanualstate == HIGH)delay(250),digitalWrite(relay1, LOW), digitalWrite(relay2, LOW), digitalWrite(relay3, LOW),Auto_Mode = false, Manual_Mode = true;

      if (count > 5)count = 0;
      if (count == 1)digitalWrite(relay1, HIGH), digitalWrite(relay2, HIGH), digitalWrite(relay3, HIGH);
      if (count == 4)digitalWrite(relay1, LOW), digitalWrite(relay2, LOW), digitalWrite(relay3, LOW);
      lcd.setCursor(7, 1);

    case false : break;

  switch (Manual_Mode) {
    case true :

      count = 0;
      if (Bautostate == HIGH)delay(250),digitalWrite(relay1, LOW), digitalWrite(relay2, LOW), digitalWrite(relay3, LOW),Manual_Mode = false, Auto_Mode = true;

      if (Bstartstate == HIGH)digitalWrite(relay1, HIGH), digitalWrite(relay2, HIGH), digitalWrite(relay3, HIGH), relay_state = 1;
      if (Bstopstate == HIGH)digitalWrite(relay1, LOW), digitalWrite(relay2, LOW), digitalWrite(relay3, LOW), relay_state = 0;
      lcd.setCursor(7, 1);

    case false : break;
  lcd.setCursor(0, 0);
  lcd.print(value1, 1);
  lcd.setCursor(12, 0);
  lcd.print(value2, 1);
  lcd.setCursor(0, 1);
  lcd.print(value3, 1);
  lcd.setCursor(11, 1);

sometime it’s even freeze just only 3 sec after resetting.

I think I found the solution. I found that the SDA and SCL cables are coiled near the switch-side of my relays and I'm not sure if the contactor generate some kind of magnetic field each time its switch off but when I move the cable away from relays and let it run again no freezing occur anymore.

This is the big problem with people reporting “mysterious” failures.

There are important design principles in electronics, always have been and particularly relating to RF (Radio Frequency) technology but computers and these microprocessors now use the frequencies traditionally classified as "RF’ and in the case of recent CPUs, “microwave” frequencies.

While you might just “breadboard” something on a solderless breadboard using those long “Dupont” jumper wires, once the actual performance - and reliability - of the system really matters, you must obey design rules. One in particular is that all the connections between one part of the circuit and another must be kept together as a bundle - that includes power and ground and signal and ground - I2C being in that category of “signal” or “control” or “data”.

Leaving the different connections draped away from each other forms loops which inductively couple interference from one part to another while having wires together (with the ground) tends to shield them from capacitive pickup so both mechanisms of coupling of interference are important.

Particularly important is to distance power wiring which is being switched, from signal and control wiring. The requirement for “lead dress” - keeping the wires together - applies equally to those wires which will be the source of the interference with those which will be susceptible.