Debug with a logic analyser
Build it step by step
0 of 7 doneConnect ground first
Then the signal channels.
Set the sample rate
At least 1 MHz.
Capture the first run
Wrong address.
Add decoders
I2C and UART.
Read the failed transaction
No acknowledge.
Fix the address
Use 0x3C.
Capture again
See the acknowledge and data.
How do you build a debug with a logic analyser?
Capture I2C, SPI and UART from a working project and decode them to understand what is happening. You need Logic analyser 8-channel 24 MHz, Arduino Uno R3, SSD1306 OLED Display and Jumper wires male to female (40 pcs). It takes 7 steps and about 45 minutes.
- Level
- Intermediate
- Time
- About 45 min
- Parts
- 4
Parts list
- InterfacesBuy
- Development BoardsBuyArduino Uno R3 × 1
- DisplaysBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Analyser GND | Uno GND | Common ground first |
| Analyser channel 0 | Uno A4 (SDA) | I2C data |
| Analyser channel 1 | Uno A5 (SCL) | I2C clock |
| Analyser channel 2 | Uno D1 (TX) | Serial output |
| OLED SDA, SCL, VCC, GND | Uno A4, A5, 5V, GND | Device under test |
| Analyser USB | Computer | PulseView or the vendor software |
Code
An analyser records the high and low level of each wire many times a second, and a protocol decoder turns the shapes into bytes you can read. Sample at least four times faster than the signal: 1 MHz or more for 100 kHz I2C, and 100 kHz or more for 9600 baud serial. Start the capture and run the sketch, then add the I2C decoder on channels 0 and 1 and the UART decoder on channel 2 at 9600 baud. The sketch starts with the wrong address on purpose, so the decode shows the address byte followed by a missing acknowledge, which explains why the serial text says result 2. Change the address to 0x3C, capture again, and see the address acknowledged and the two data bytes. The analyser's ground must connect to the board's ground, and keep its probe leads short. Arduino IDE, board "Arduino Uno". Only measure low-voltage circuits this way; do not connect the clips to mains or to anything above 5 V.
Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Something to capture: I2C writes to an OLED plus serial text. Start with the WRONG address on purpose.
// Board: Arduino Uno. Change OLED_ADDR to 0x3C after you find the problem in the capture.
#include <Wire.h>
const byte OLED_ADDR = 0x3D; // most SSD1306 modules use 0x3C
void setup() {
Serial.begin(9600);
Wire.begin();
}
void loop() {
Wire.beginTransmission(OLED_ADDR);
Wire.write(0x00); // control byte: command follows
Wire.write(0xAF); // display on
byte result = Wire.endTransmission(); // 0 = acknowledged, 2 = address not acknowledged
Serial.print("I2C result: "); Serial.println(result);
delay(1000);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
I2C result: 2
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Wrong address | NACK in the decode and result 2 on serial |
| Right address | ACK and result 0 |
| UART decode | Shows the same text as the monitor |
| Clock speed | About 100 kHz |
If it does not work
Flat lines
Check the ground and the channel order.
Decode garbage
Raise the sample rate and check the baud rate.
No trigger
Set a falling-edge trigger on SDA.
Software finds no device
Install the driver for the analyser.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the debug with a logic analyser?
Logic analyser 8-channel 24 MHz, Arduino Uno R3, SSD1306 OLED Display and Jumper wires male to female (40 pcs).
How long does the debug with a logic analyser take to build?
About 45 minutes for a intermediate maker, in 7 steps.
How do I know the debug with a logic analyser works?
Wrong address: NACK in the decode and result 2 on serial. Right address: ACK and result 0. UART decode: Shows the same text as the monitor.
Flat lines: what should I check?
Check the ground and the channel order.
Decode garbage: what should I check?
Raise the sample rate and check the baud rate.
No trigger: what should I check?
Set a falling-edge trigger on SDA.
Software finds no device: what should I check?
Install the driver for the analyser.
