Skip to content

Arduino Wire.write Data Not Sent to Slave

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about Arduino Wire.write Data Not Sent to Slave. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

Data sent via Wire.write() does not reach the I2C slave device.

Quick Fix

Wrong

Wire.write(0x42);  // Must call between beginTransmission and endTransmission
Data is buffered but never sent (no begin/end transmission calls shown).
#include <Wire.h>

void setup() {
  Wire.begin();
}

void sendToSlave(byte addr, byte reg, byte val) {
  Wire.beginTransmission(addr);
  Wire.write(reg);  // Register address
  Wire.write(val);  // Value to write
  byte error = Wire.endTransmission();
  
  if (error == 0) {
    Serial.println("Write successful");
  } else {
    Serial.print("Error: ");
    Serial.println(error);
  }
}

void loop() {
  sendToSlave(0x3C, 0x00, 0x01);
  delay(1000);
}
Write successful

Prevention

Wire.write() buffers data — nothing is sent until Wire.endTransmission(). Always use the beginTransmission/write/endTransmission sequence. Check endTransmission() return value: 0 = success, 1 = data too long, 2 = NAK on address, 3 = NAK on data, 4 = other error.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What is the maximum data per transmission?

32 bytes on AVR (Wire library buffer size). For larger data, send in 32-byte chunks with separate transmissions.

Can I send data without register address?

Yes. Just omit the register byte: Wire.beginTransmission(addr); Wire.write(data); Wire.endTransmission(); This sends raw data to the device.

What does endTransmission return?

0 = success. 1 = buffer overflow. 2 = address NAK (device not responding). 3 = data NAK. 4 = bus error. Always check it.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro