Wire (I2C)

endTransmission()

Ends a transmission to a slave device that was begun by beginTransmission() and transmits the bytes that were queued by write().

// SYNTAX
Wire.endTransmission();
Wire.endTransmission(stop);

Parameters: stop : boolean. true will send a stop message after the last byte, releasing the bus after transmission. false will send a restart, keeping the connection active. The bus will not be released, which prevents another master device from transmitting between messages. This allows one master device to send multiple transmissions while in control. If no argument is specified, the default value is true.

Returns: byte, which indicates the status of the transmission:

Value System error description
0 SYSTEM_ERROR_NONE success
1 SYSTEM_ERROR_I2C_BUS_BUSY busy timeout upon entering endTransmission()
2 SYSTEM_ERROR_I2C_ARBITRATION_FAILED START bit generation timeout
3 SYSTEM_ERROR_I2C_TX_ADDR_TIMEOUT end of address transmission timeout
4 SYSTEM_ERROR_I2C_FILL_DATA_TIMEOUT data byte transfer timeout
5 SYSTEM_ERROR_I2C_TX_DATA_TIMEOUT data byte transfer succeeded, busy timeout immediately after
6 SYSTEM_ERROR_I2C_STOP_TIMEOUT timeout waiting for peripheral to clear stop bit
7 SYSTEM_ERROR_INVALID_STATE Using endTransmission in slave mode, or I2C not enabled
7 SYSTEM_ERROR_NOT_ENOUGH_DATA Incorrect number of bytes returned (can be returned for incorrect addresss)
7 SYSTEM_ERROR_CANCELLED Transaction aborted
7 SYSTEM_ERROR_INTERNAL Internal error
7 Any other non-zero system error code