1/20/2024 0 Comments Arduino wire library addressThe NACK seems to indicate that the read went wrong. Looking at my logic analyzer this is what I get: Wire.write(MCP23008_REGISTER_GPIO) // Select the GPIO register Wire.write(IO_ALL_PINS_INPUT) // Set all pins as inputĪfter which I attempt to read from it, by first addressing the GPIO register and then requesting a byte to read: inline uint8_t eeprog::_read() Wire.write(MCP23008_REGISTER_IODIR) // Set I/O direction Syntax Wire.begin () Wire.begin (address) Parameters address: the 7-bit slave address (optional) if not specified, join the bus as a controller device. This function should normally be called only once. Wire.beginTransmission(MCP23008_DEVICE_I2C_ADDRESS | MCP23008_SLAVE_I2C_ADDRESS) begin () Description This function initializes the Wire library and join the I2C bus as a controller or a peripheral. ![]() So I set it up for read as follows: #define MCP23008_DEVICE_I2C_ADDRESS 0x20 Writing to the device GPIO seems to work fine, and I'm a bit confused on how to read from the GPIO. ![]() The MCP23008 is wired to address 0x04, giving an effective device address of 0x24. I'm trying to read from an MCP23008 I/O expander using the Wire library over I2C.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |