Skip to main content

i2c.readerror()

Returns the error code generated by the last I²C read

Availability

Device

Returns

Integer — an I²C error code, or 0 (no error)

Description

The error code generated by the most recent i2c.read() operation may be useful in diagnosing a hardware fault when i2c.read() has returned null — its error signal.

I²C error codes returned by i2c.readerror() and i2c.write() are listed below.

Error Value Description
No error 0 Method completed successfully
Controller select error -1 Timeout waiting for bus to be released after sending start
Transmit select error -2 Timeout while selecting transmit mode
Transmit error -3 Timeout while sending data
BTF error -4 Timeout waiting for data transfer to complete
Stop error -5 Timeout waiting for stop condition to be detected
Address clear error -6 Timeout waiting for address flag to be cleared
Address RXNE error -7 Timeout waiting for address to be read
Data RXNE error -8 Timeout waiting for data to be read
Peripheral NACKed error -9 Peripheral NACKs the send
Controller receive select error -10 Timeout while selecting multibyte receive mode
Receive error -11 Timeout during multibyte read
Reselect error -12 Timeout waiting for bus to be released after sending start
Not enabled -13 Attempt to read or write from an unconfigured peripheral