1. Make setup as per following diagram using level shifter (Fig-1). If using level shifter, then there is no need to install additional pull-up resistors with the i2C Bus.
2. Upload the following sketches:
Master-NANO requests Slave-ESP32 to send 0x17 in every second; Master receives the data and shows on its Serial Monitor.
If you really need the Nano and the ESP32 (I don't think so), then you can use Serial/UART communication (also via a level shifter).
Can you do your project with a single Arduino board ?
What is your project ? please give us a broader view.
The impression I have is that the master makes the request, the slave responds but the master only prints the value sent by the slave 1 second later, getting out of order and giving the impression that the master is "delayed".
I'm a beginner and the first time I'm having to deal with I2C communication, it may be something very obvious, but I can't see it at the moment, I apologize in advance.
Swap these statements. The first transmission may be aborted due to a timeout during Serial output, so that you get the bytes delayed by one transmission.
In I2C Communication, the following Protocol is followed: 1. As requestFrom() method is a blocking code, it stays here until requested number of data bytes arrive into its I2C Buffer from the Slave. The control automatically goes o the next line. So, there is no need to check the presence of data in the buffer.
2. The print() method requires active interrupt logic (Fig-1) for its functionality. Therefore, execute this method in the function where the interrupt logic is active, and it is the loop() function.
3. Now reload the following adjusted codes and check if there is any improvement in your perception. Master Sketch: