-
Hello, My goal is to execute a blink using I2C and pi4j. I checked multiple times the wiring and i can't find any error. This is my code (mainly copied from pi4j docs):
The error i am getting is
The line 'i2c created' is correctly printed out, the error comes up when i try to write to board register to configure it as output. There is one weird doubt that i have... do i need a internet connection to run this? Because i have no internet now, whereas i had internet a couple of months ago when the program used to run correctly. Thanks from my heart to anyone who will take their time to help me |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 20 replies
-
Hello
Let me know if this answers your questions or have additional questions. Tom |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for your response Tom. I really appreciate it! I tried your code but i am getting the same error. (I got error for device 32 instead of 33, since you used 0x20 instead of 0x21) Please note that my code throws the error on this line
In fact this line What this means is that i can successfully create the i2c bus, but as i try to set the registers as output, the error appears. |
Beta Was this translation helpful? Give feedback.
-
Here is a README to document the mcp23017 pin connection, Pi snapshot and jdk |
Beta Was this translation helpful? Give feedback.
-
So... I made this test, i disconnected everything but the port expander (http://www.cqrobot.wiki/index.php/MCP23017_IO_Expansion_Board_SKU:_CQRMCP23017A) and raspberry. |
Beta Was this translation helpful? Give feedback.
-
Data "10101111" would then be this byte array being sent to the mcp23017 49 48 49 48 49 49 49 49 The chip expects a single byte of data. At the moment I have a different 23017 plugged in but it appears to ignore all the bytes and not drive any pins. As an example of driving GPA 0 and 1, mcp23017Dev.writeRegister(GPIOA, 0b00000011); |
Beta Was this translation helpful? Give feedback.
-
Ok so... with the LEDs, unfortunately... it properly works... i can control groups of pins, not just all or none. So, what does this mean? What is the problem with controlling relays instead of LEDs? |
Beta Was this translation helpful? Give feedback.
-
I finally solved the issue. The problem lied with the wiring of course... basically the reference to 0 was not shared amongst the devices and that caused an unpredictable, undesired, outcome... On the other hand the Pi4J works smoothly with MCP23017. I am able to write to my register like so |
Beta Was this translation helpful? Give feedback.
I got a MCP23017 module like yours.
CQRobot MCP23017
Pi SCL Blue
Pi SDA Green
Pi Gnd Black
Pi 3.3 Red
PA0 ++++LED--//////---- Gnd pin
I did no Ax jumpers i2cdetect -y 1 shows I2C device address 0x27
Per CQRobot spec
/*the param can be 0 to 7,the default param is 7.means the dafault device address 0x27.
Test case executes and LED blinks on/off as expected.
I can only assume you have a Hardware Problem. If other I2C devices function correctly I think your MCP23017 module is the problem.