I'm trying to use the Pi4J java library to write data to an IO Expander via i2C. When I create a new instance of the MCP23017GpioProvider class using the following code:
mcp = new MCP23017GpioProvider(I2CBus.BUS_1, 0x21);
I get the following error: Error writing to /dev/i2c-1 at address 0x21. Got -20001
I have confirmed that I have a rev2 board (hence using bus 1) and that my IO Expander is at address 0x21 by using "i2cdetect -y 1"
Does anyone know what could be causing this error?
P.S. The expander I am using is an MCP23017 16-bit