IO Pi Plus programming C error "Failed to write to i2c device for write"
4459 Views - Created 07/03/2018
I'm having some troubles getting my Raspberry Pi 3+ to work with the IO Pi Plus. I'm testing this IO expander for the first time, but always get following error: "Failed to write to i2c device for write"
- Instead of using the OI Pi Plus header, I used a few jumper wires for now to connect 5V, GND, SDA and SCL from the Pi to the OI Pi Plus.
- Also removed the solder jumper link already (I will use a seperate 5V power supply in the future).
- No changes to addresses, so 0x20 for IC 1 (000) and 0x21 for IC 2 (001).
- Pre loaded NOOBS
- Geany for C programming
- Installed the ABElectronics libraries
- ARM I2C enabled in raspi-config
I'm using the demo-iopiread.c code (see also /ABElectronics_C_Libraries). When compiling, I first got 5 warnings "implicit declaration of function" (strerror, write, read, close and usleep), by adding #include <unistd.h> to ABE_IoPi.c, I removed 3 warnings (write, read, close). Don't know how to get the 2 other warnings go away, but not really my concern for now, I guess.
When I run the demo code, one of the first things to execute is function IOPi_init(0x20)
Then function write_byte_data
And then when the code fails
I'm searching for hours now and can't figure out why I can't write/communicate to the MCP23017 .
I'm not even sure if this is an hardware or software problem.
Can someone help me with this issue?
Thank you in advance
Sorry, there was a bug with the IO Pi C library which was stopping it from compiling on the recent releases of Raspbian Linux. I have updated the library and it should be working now, please can you download a new version from our GitHub repository and see if it works on your Raspberry Pi?
You will also need to make sure the libi2c-dev package is installed for the code to compile. You can download it using apt-get.
sudo apt-get install libi2c-dev
thanks for the fast response! I replaced the libraries with the new you just updated and reinstalled libi2c-dev.
I tried the code again, but still got the same error "Failed to write to ic2 device for write".
I also switched to another IO Pi Plus board and retried, still the same problem.
If the board does appear on 0x20 and 0x21 can you try our python library and see if that can talk to the board? If it does not appear then check the connections between the Raspberry Pi and the IO Pi to make sure it has good ground and power connections. You will need to connect the 3.3V pin as well as supply 5V to the IO Pi as the 3.3V is used on the I2C level shifter circuit.
I overlooked this while checking the schematic of the OI Pi Plus. And now it also shows up with the i2c detect
Thank you so much for you're quick help!
Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.