Same code working differently on Nano 33 IoT and Mega

Hi,

a) use an Oscilloscope between GND and SCL or SDA.
SCL=clock will show a constant "signal" while SDA=data will change ...

b) Use a LED between GND and SCL or SDA.
It should light up a bit - not very bright. If not something will be wrong.

Alex