As a forewarning, this is my first PCB. I am experiencing issues with the I2C bus. There are two I2C slaves on this bus (SSD1306 display and BQ27441 Fuel gauge, currently the program only sends commands to the display at 0x3C, so I'm not worry about the other device causing problems right now.)
My first concern was noise issues because I did not realize it was poor practice to route the I2C signals next to each other, so I cut the traces and re-routed using magnet wire. This resulted in the same exact issue. The issue is: the screen only displays for about a second, not even, and then cuts out. I changed out the pull-up resistors to pretty low values (1.1k, originally 4.7k but the rise time on the oscilloscope looked pretty bad). Important note: the screen did not work at all before this change. However, the screen is still very intermittent, which leads me to believe this was not the direct cause.
The SDA trace is 71.5mm and the SCL trace is 80.8mm, I didn't think length matching would be important at 400kHz, but thought I would include the information. Also, would cross-coupling be an issue here potentially? The clearance is about 5mil I believe. It probably wasn't the best idea to route under the ESP32 either...I've definitely been learning the hard way on this project.
It is a 2-layer board, most of the bottom layer is a ground plane, there are a couple very small sections of the I2C traces that go down to this layer. Top Layer and Bottom Layers are 0.03556mm thick separated by an FR-4 dielectric of 1.6mm.
Please note that this code was verified on the ESP32 DevKitC V4 and was working perfectly. I also tested different frequencies on the I2C bus as well (100kHz, 400kHz, and 700kHz).
From the oscilloscope capture, my first guess would be too high of a bus capacitance, but I would like some other opinions before I am forced to do another board revision.
I also captured the communication with a logic analyzer as seen below. It repeatedly is doing a setup write to 0xF8 which does not appear in the code at all (based on oscilloscope capture I would not expect anything meaningful from a logic analyzer anyways, but for completeness), again pointing to a hardware issue.
It does not appear to be power issues either because both 3v3 and 5v rails seem stable.
Edit: I've cut the traces going to the fuel gauge to eliminate any possible bus contention, still nothing. I also added schematic, along with oscilloscope set-up and another oscilloscope capture with repeated "data". It is interesting that the signals appear to be pretty much exact opposites.
I managed to capture this ^^ as soon as I plugged my board into micro-USB....interesting. This shouldn't be a power issue, the DC-DC converters are rated for over an amp each at their voltages of 3v3 and 5v, not drawing anywhere near that.
EDIT: I was stubborn regarding answers about the oscilloscope ground, but for the wrong reason! The J2 header is having ground issues apparently, I was able to capture this on the scope using one of the mounting holes as a ground reference for the scope, I will have to check the solder connection for the header, or maybe even replace the header as there was a tiny bit of flux that surrounded the header and may have got stuck in there? I did verify the GND pin on J2 goes directly to the ground plane on the bottom layer.