Conflict between I2C and interruption

I have a problem with programming a sensor using interruption and printing the result over LCD screen which uses I2C, I found after deep research that they couldn't be programmed together because they share the same wire library. But I some people solved that problem with a trick in the code but I didn't understand it to implement it in my code.
By the way, in the project later I will use millis() function, does it conflict with interruption and I2C when they are solved?

Could anyone help me.
Regards

The Wire library and I2C work very well to communicate with more than one device, as intended. The use of interrupts with sensors is usually not necessary and is not recommended.

Post the details of your problem, after carefully studying the "How to use this forum" post.

I found after deep research that they couldn't be programmed together because they share the same wire library.

Apparently not deep enough, because many I2C devices can be on the bus, and the Arduino can communicate with them all.

But I some people solved that problem with a trick in the code

Harry Potter did not wave his magic wand. There are no "trick"s required.

but I didn't understand it to implement it in my code.

Nor did you share the code you didn't understand, so it was pointless to tell us that you didn't understand it.

By the way, in the project later I will use millis() function, does it conflict with interruption and I2C

The millis() function relies on interrupts happening, so it knows that time has passed. It will work just fine with other code that uses interrupts properly, including I2C.

Thank you Mr. Paul.
I read that from LCD print within Interrupt Function - Programming Questions - Arduino Forum in #8 maybe I miss understand him.
Let me discuss my problem from beginning:
When I test interrupt code for the sensor I works perfectly and when I test the LCD screen (which works on I2C) alone it works perfectly too

BUT when I combine both codes they don't work. I just receive "Tu" in serial monitor which is the first two letters in the first Serial.print in the code.

The LCD code Which work alone perfectly :

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7);

void setup(){
  Serial.begin(9600);
  lcd.begin (16,2);
  lcd.setBacklightPin(3,POSITIVE);
  lcd.setBacklight(HIGH);
}

void loop(){
Serial.println();
  lcd.setCursor (0,0);
  lcd.print("Speed: 1800");
  lcd.setCursor (6,1);
  lcd.print("RPM");
delay (1000);
}

The sensor code Which work alone perfectly :

//inductive
int metalPin = A5;
volatile int count; //measuring the rising edges of the signal
int Calc;

void setup(){
  Serial.begin(9600);
//sensor
 pinMode(2, INPUT);
 attachInterrupt(0, rpm, RISING);
 }

void loop(){
Serial.println();
  inductive();
Serial.println();
delay (1000);
}

void inductive(){
 count = 0; //reset the counter
 sei(); //Enables interrupts
 delay (15000);
 cli(); //Disable interrupts
 Calc = (count *4); //to be(RPM)
 Serial.print ("Turbine:     ");
 Serial.print (Calc);
 Serial.println ("    RPM");
}

void rpm(){ //This is the function that the interupt calls
 count++;
}

The combined code which doesn't work:

//LCD
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7);

//inductive
int metalPin = A5;
volatile int count; //measuring the rising edges of the signal
int Calc;

void setup(){
  Serial.begin(9600);
//sensor
  pinMode(2, INPUT);
  attachInterrupt(0, rpm, RISING);
//LCD
  lcd.begin (16,2);
  lcd.setBacklightPin(3,POSITIVE);
  lcd.setBacklight(HIGH);
 }

void loop(){
  inductive();
  lcd.setCursor (0,0);
  lcd.print("Speed: ");
  lcd.print(Calc);
  lcd.setCursor (6,1);
  lcd.print("RPM");
delay (1000);
}

void inductive(){
 count = 0; //reset the counter
 sei(); //Enables interrupts
 delay (15000);
 cli(); //Disable interrupts
 Calc = (count *4); //to be(RPM)
 Serial.print ("Turbine:     ");
 Serial.print (Calc);
 Serial.println ("    RPM");
}

void rpm(){ //This is the function that the interupt calls
 count++;
}

Thanks

 sei(); //Enables interrupts
 delay (15000);
 cli(); //Disable interrupts

That is the poorest possible way to count the number of interrupts in 15 seconds. Only during the delay() can interrupts happen.

ALL of this stuff:

 Calc = (count *4); //to be(RPM)
 Serial.print ("Turbine:     ");
 Serial.print (Calc);
 Serial.println ("    RPM");

  lcd.setCursor (0,0);
  lcd.print("Speed: ");
  lcd.print(Calc);
  lcd.setCursor (6,1);
  lcd.print("RPM");
delay (1000);

happens with interrupts disabled. delay() does not work with interrupts disabled. Serial printing required interrupts. Printing to the LCD requires interrupts.

Sh*t can that code. Read, understand, and embrace the blink with delay example. When it is time (i.e. 15 seconds has passed since last time), disable interrupts, copy count, and re-enable interrupts. Then, you can calculate RPM and print to your heart's desire.

It is partly because of the often made, but fatal mistakes outlined above that we do not recommend use of interrupts!

Study this Blink without Delay tutorial to learn more appropriate programming techniques.

It is partly because of the often made, but fatal mistakes outlined above that we do not recommend use of interrupts!

Polling the state of a pin that can change 500 times a second (30000 RPM, which my spindle motor does) may not work. Sometimes interrupts are necessary. But, you do have to know what you are doing to use them correctly.

Thank you too much.
I test it with starting interruption again after saving the number and everything worked perfectly.