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).
Right
#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
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro