Problem using Rs485 and 4 bit I2C seven segment display together

I am using rs485 to communicate between two Arduino nano. I have connected a 4 digit I2C display to one of the Arduino nano. When the nano receives data via Rs485 from the master nano, the data is displayed on the I2C display. But the issue is that I am only able to use one of those things i.e. if I am receiving data I am not able to display it on the I2C display and if I am displaying, then I am not able to receive the data. Has someone tried doing it together?

Code for master Arduino nano

// rs485 master
void setup() {
  Serial.begin(115200);
  pinMode(2, OUTPUT); //DE/RE pin

}
int i;

String s = "s1b01n01";
void loop() {
  digitalWrite(2, HIGH); // high for transmiting
  for (i = 0; i <= 8; i++)
  {
    Serial.print(s[i]);
  }

  digitalWrite(2, LOW);
}

Code for slave nano

 #include <TM1637Display.h>
#define CLK 4
#define DIO 16
#define ExtEnable 2  //DE/RE pin

TM1637Display display = TM1637Display(CLK, DIO); // Create display object of type TM1637Display:

const uint8_t data[] = {0xff, 0xff, 0xff, 0xff};// Create array that turns all segments on:
const uint8_t blank[] = {0x00, 0x00, 0x00, 0x00}; // Create array that turns all segments off:

int i = 0;
char add[8], c;
char address[] = {'s', '1', 'b', '0', '1', 'n', '0', '1'};

void setup() {
  Serial.begin(115200);
  pinMode(ExtEnable, OUTPUT); //DE/RE pin
  display.clear();
  delay(1000);
  display.setBrightness(7); // Set the brightness:
}

void loop() {
  digitalWrite(ExtEnable, LOW); // low for receiving
  if (Serial.available())
  {
    c = Serial.read();
    Serial.print(c);
    add[i] = c;
    i++;
    digitalWrite(ExtEnable, HIGH);
    //display.showNumberDec(3); //print on display
  } Serial.print("add");
  Serial.println(add);

  if (add == address) // to check
  {
    display.showNumberDec(3); //print on display
  }
}

it appears that the slave (transmitting) device is continuously transmitting data and overrunning the receiver
could the master when it is ready for data poll the slave ?
it then receives data, displays it then polls again

Unless your slave device has something to say to the master device, then it should stay in permanent receive mode.

rishita_jaiswal:
I am using rs485 to communicate between two Arduino nano. I have connected a 4 bit digit I2C display to one of the Arduino nano.

Fixed that.

  if (add == address) // to check
  {
    display.showNumberDec(3); //print on display
  }

That's wrong. You can't compare arrays this way.

Also, when using RS-485, you need to wait for all the characters/bytes to be transmitted before you put your RS-485 chip back into “receive” mode.

Altering your Tx code to this should help with that issue:

void loop() {
  digitalWrite(2, HIGH); // high for transmiting
  for (i = 0; i <= 8; i++)
  {
    Serial.print(s[i]);
  }
  Serial.flush();
  digitalWrite(2, LOW);
}

It is working now. Thanks for pointing out the mistakes.

FYI, TM1637 is not i2c.