I2C protocol doesn't work properly
You may need to do some additional research. I'm debugging some I2C problems myself at the moment. Happy to share what my research has turned up:
Guiding Ideas - What could break?

Physical Layer

Unintentionally switched connections (SDA&lt;&gt;SCL)
Incorrect Pins selected on Microcontroller
Pull-up Resistors

Too many

Devices often have pull-ups installed by default. Only one set is needed per bus. Rule of parallel resistors applies to calculate effective resistance.


Too big (too high resistance)
Too small (too low resistance)


Voltage Conversion / Mismatched  devices
Spikes or noise on SDA, SCL or Vcc
Parasitic Capacitance

wire / trace design
bus too long




Protocol Layer

Bus Addresses incorrect / collisions
No ACK received from slave  (ref. TI article &quot;Troubleshooting I2C Bus Protocol&quot; below)

Timing
Missing / Unexpected SCL pulses
Incomplete 8 bit block
Missing Bytes
False slave address
Unsuccessful address change


NACK signal meaning ambiguity
Clock speed mismatch (should be running at the speed of the slowest slave on the bus)
Blocked bus (i.e., a device has reset or dropped during transmission putting the bus into an invalid state. There is no timeout.)
Multimastering (too many masters on bus?) - if more than one all must support multi-master mode
Clock stretching (a slave is holding the clock low)
What part of the message is missing? Is the initial ACK from the slave received?


Code Layer

For boards with multiple I2C ports, correctly passing the desired port to the relevant library.
Use of interrupts causing timing problems
Use of blocking code structures causing timing problems



Testing Methods

Bus Pinging / Bus Scan (like Arduino Multi-speed scanner https://forum.arduino.cc/index.php?topic=197360)
Connect additional devices to the bus and see which combinations work to identify the failing item
Multimeter checks

Stable Vcc?
Common Ground?
(Open Drain) pull-up resistance from SDA &amp; SCL to Vcc


Test devices like Bus Pirate
Oscilloscope Analysis / Decode (references below)
Sifting out which device is causing the problem. (See Hackaday article) Put different-value resistors on the output of all chips on the bus. The low voltage values will be slightly different for each chip, allowing you to see on a scope which chip is talking at any given time, and diagnose when they’re talking over each other.
install I2C multiplexor to seperate bus into a single connector for each device (i.e., from bus to star topology) (e.g., PCA9544A)

References
I2C General

For Arduino Programming Arduino Next Steps - Going Further with
Sketches Chapter 7
For ESP32
https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/

I2C Debug Advice

I2C Primer (I2C-bus.org) - a good reference for everything discussed here https://www.i2c-bus.org/i2c-primer/


Common Problems https://www.i2c-bus.org/i2c-primer/common-problems/
Obscure Problems https://www.i2c-bus.org/i2c-primer/obscure-problems/ Analysing Obscure Problems https://www.i2c-bus.org/i2c-primer/analysing-obscure-problems/


WHAT COULD GO WRONG? I2C EDITION (Hackaday) https://hackaday.com/2016/07/19/what-could-go-wrong-i2c-edition/
How to design and debug a custom I2C master-slave system? (Stack Exchange) How to design and debug a custom I2C master-slave system?
Troubleshooting I2C Bus Protocol  https://www.ti.com/lit/an/scaa106/scaa106.pdf

Oscilloscope Analysis of I2C

How to debug I2C through waveform analysis (Texas Instruments) https://www.ti.com/lit/an/slyt770/slyt770.pdf
Using an oscilloscope to debug the I2C protocol https://www.electronicproducts.com/using-an-oscilloscope-to-debug-the-i2c-protocol/