Interpret Wire.endTransmission() status on an Arduino Uno
Tell apart an I²C address NACK, data NACK and timeout with a minimal address probe for the shipped AVR Wire library.
Read the status from this transmission
For the supplied AVR Wire version, 0 means success, 1 means the outgoing data was too long, 2 means NACK on the address, 3 means NACK on data, 4 means another bus error, and 5 is a timeout when timeout support is enabled. Read the return value immediately after the related transmission rather than assuming that beginTransmission found the part. Other cores can differ.
Probe one address before sending data
The example sends an address-only probe to 0x3C. It uses a 7-bit address and no register payload, so a data NACK is not expected in this probe. If you get 2, check the actual address, supply, common ground, SDA/SCL and pull-ups. A 0 confirms the address acknowledged, not which controller is attached. Avoid unbounded retry loops.
Open the exact Uno example
On compatible hardware, expect 0 for an acknowledging address or 2 if the address is free. Bus faults can yield a different result.
#include <Wire.h>
void setup() {
Serial.begin(9600);
Wire.begin();
Wire.setWireTimeout(25000, true);
Wire.beginTransmission(0x3C);
const byte status = Wire.endTransmission();
Serial.println(status);
}
void loop() {}Verified with [email protected] on Uno R3 (2026-12-05 UTC). This check did not use physical hardware.