What I2C really looks like on a cheap USB scope: pull-up shark fins at 400 kHz
In February 2018 I wrote about debugging an I2C bus between an STM32F103C8T6 “blue pill” and an MPU-6050 board, using a Hantek 6022BE USB scope. That post showed the setup and said it worked. It never really looked at what was on the screen.
I still have the photos, the captures and the sketch from that evening. If you have ever put a scope on an I2C line and thought “that is not a square wave, is it broken?”, this post is for you. It is not broken. At 400 kHz the signal the scope showed me looks like a row of shark fins.

Full walkthrough (3:56). Loads from YouTube only after you press play. Open on YouTube. The narration in my videos is an AI voice; the sketch, captures and numbers are from my bench.
The bench
This is the same bench as the old post, from 30 and 31 January 2018:
- an STM32F103C8T6 blue pill,
- a small MPU-6050 breakout (a GY-521 style board),
- an FTDI USB-serial board on the same breadboard,
- a Hantek 6022BE with one probe clipped to the bus, and its own Windows software (version 1.0.5 in the screenshot),
- a 24 MHz USB logic analyzer on the same lines, with its own software. The analyzer is not in the photos, only its screenshots.
My Fritzing drawing puts the MPU-6050 clock and data on the blue pill’s B6 and B7.
100 kHz first
At the standard 100 kHz speed the scope’s own readout is exactly what you would hope for: frequency 100.0 kHz, period 10.0 µs, at 100 µs per division and a 1 MS/s sample rate.
This capture is not from the 400 kHz sketch below (that one calls Wire.setClock(400000)).
The sketch, then 400 kHz
The sketch that produced the 400 kHz capture is short. It sets the I2C clock to 400 kHz, talks to the MPU-6050 at address 0x68, wakes it by writing 0 to register 0x6B, then repeatedly reads 14 bytes starting at register 0x3B (accelerometer, temperature, gyroscope). The cleaned listing is in the code section below.
Same wire, fast mode, 400 kHz. The trace is not a square wave. Each pulse rises slowly, then drops almost vertically.
The scope’s measurements for that capture, CH1 at 1.00 V per division:
| What | Reading |
|---|---|
| Frequency | 400.0 kHz |
| Period | 2.50 µs |
| High for | 625 ns |
| Low for | 1.87 µs |
| Duty cycle | 25 % high, 75 % low |
| Rise time | 479 ns |
| Fall time | 31.3 ns |
| Maximum | 3.55 V |
| Minimum | −31.4 mV |
| Amplitude | 3.26 V |
Wire.setClock(400000) asked for.Two numbers tell the story: it takes about 479 ns to climb and about 31 ns to fall. The fall is about fifteen times faster than the rise.
Why shark fins?
An I2C line is open-drain. The chip can only pull the line down. To get back up, a pull-up resistor has to charge the wire and the pins, which have a little capacitance. That slow charge is the climb. The fall is the chip pulling hard, which is why it is nearly vertical.
I did not measure the pull-up values or the capacitance on this breadboard, so I cannot give you an RC number. What the capture does show is that a breadboard bus at 400 kHz is not square, and that the scope is honest about it.
The same bus on a logic analyzer
For the same 400 kHz bus, the logic analyzer shows something very different: clean digital levels, SDA, SCL, and an I2C decoder that turns the bits into bytes. The decoded labels in my screenshot are 240 + ACK and 208 + ACK. The analyzer measures the clock at 400.0 kHz, 2.5 µs period, 0.75 µs width, 30 % duty.
240 + ACK and 208 + ACK, clock 400.0 kHz.
208 decimal is 0xD0, which is the 8-bit I2C write address for the 7-bit address 0x68 in the sketch (0x68 << 1). That is the start of a write: either the wake-up to register 0x6B, or the write of 0x3B that precedes the 14-byte read. 240 is also on the capture. I do not know what 240 is, and I am not going to guess.
The analyzer cannot show shark fins, because it only knows high or low. The scope shows the shape but does not decode bytes. For this job I used both.
How high does this scope go?
The listing for this class of scope says 20 MHz bandwidth and 48 MS/s. A few days later, on 3 February 2018, I have captures on the same scope at 6.3–6.4 MHz, 48 MS/s. The frequency footer still works (6.400 MHz, 46.7 % duty; a cursor reads 6.300 MHz), but the shape is rounded and sine-like.
I also have a short STM32 sketch, stm32_pwm_test.ino, that sets HardwareTimer 1 on pin PA8, prescale 1, overflow 10, and pwmWrite(PA8, 5). On a 72 MHz blue pill that is a 7.2 MHz PWM at 50 % duty (72 MHz / 10, compare at half). The filename on the capture is STM32_6_4MHz_up to 6_8_error. That sketch is the likely source of these captures, but I am not certain, so I am treating it as likely, not proven. What I can say either way: in this range the frequency readout still works, and the shape has rounded off.
What I take away
- A 400 kHz I2C line on a breadboard looks like shark fins on a scope. That is the pull-up charging the bus, not a broken scope or a broken sensor.
- The sketch is doing something ordinary: 400 kHz, address
0x68, a 14-byte read from0x3B. The analyzer’s208is that write address. The interesting part is the shape, not a strange transaction. - Use the scope to see the shape of the signal (rise and fall, overshoot, how high the line really gets). Use a logic analyzer to read what the bus says.
- A cheap USB scope was good enough to see all of this at 400 kHz. Pushed toward a few megahertz, the frequency footer still works and the shape starts to fall apart.
The code
This is the sketch behind the 400 kHz capture, lightly cleaned: same logic, short comments, and the serial prints restored as an optional block (they were commented out in the file I ran). You can download the cleaned sketch or the original file as I found it (Tests/TEST1/TEST1.ino).
#include <Wire.h>
const int MPU6050_addr = 0x68;
int16_t AccX, AccY, AccZ, Temp, GyroX, GyroY, GyroZ;
void setup() {
Wire.setClock(400000); // 400 kHz fast-mode I2C
Wire.begin();
// Wake the MPU-6050: write 0 to PWR_MGMT_1 (0x6B)
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop() {
// Start at ACCEL_XOUT_H (0x3B) and read 14 bytes: accel, temp, gyro
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false); // repeated start
Wire.requestFrom(MPU6050_addr, 14);
AccX = Wire.read() << 8 | Wire.read();
AccY = Wire.read() << 8 | Wire.read();
AccZ = Wire.read() << 8 | Wire.read();
Temp = Wire.read() << 8 | Wire.read();
GyroX = Wire.read() << 8 | Wire.read();
GyroY = Wire.read() << 8 | Wire.read();
GyroZ = Wire.read() << 8 | Wire.read();
// Optional: print the readings (commented out when I took the captures)
/*
Serial.print("AccX = "); Serial.print(AccX);
Serial.print(" || AccY = "); Serial.print(AccY);
Serial.print(" || AccZ = "); Serial.print(AccZ);
Serial.print(" || Temp = "); Serial.print(Temp / 340.00 + 36.53);
Serial.print(" || GyroX = "); Serial.print(GyroX);
Serial.print(" || GyroY = "); Serial.print(GyroY);
Serial.print(" || GyroZ = "); Serial.println(GyroZ);
delay(100);
*/
}
stm32_mpu6050_i2c_400k.ino
Two other sketches from the same archive, not used for the I2C captures:
stm32_pwm_test.ino— STM32 HardwareTimer 1, PA8 PWM, prescale 1, overflow 10,pwmWrite(PA8, 5). Nominal 7.2 MHz at 50 %. Likely, not certain, the source of the 6.3–6.4 MHz captures (see above).mhztest.ino— AVR Timer2 fast PWM on pin 3, 9 cycles = 1.778 MHz. A different board, not used in this post.