WalterHeisenberg
Posts: 10
Joined: Thu Aug 03, 2017 7:04 pm

PI4J + Adafruit LCD with MCP23017

Sun Jul 29, 2018 6:18 am

Trying to work with LCD but looks like Im doing something wrong.

Code: Select all

        LCD lcd = new I2CLcdDisplay(2, 16, 1, 20,
                0, 15, 14, 13, 9, 6, 11, 12);

        lcd.clear();
Got values from python example:

Code: Select all

# Char LCD plate GPIO numbers.
LCD_PLATE_RS            = 15
LCD_PLATE_RW            = 14
LCD_PLATE_EN            = 13
LCD_PLATE_D4            = 12
LCD_PLATE_D5            = 11
LCD_PLATE_D6            = 10
LCD_PLATE_D7            = 9
LCD_PLATE_RED           = 6
LCD_PLATE_GREEN         = 7
LCD_PLATE_BLUE          = 8
Result:
java.io.IOException: Input/output error
at java.io.RandomAccessFile.write0(Native Method) ~[na:1.8.0_65]
at java.io.RandomAccessFile.write(RandomAccessFile.java:489) ~[na:1.8.0_65]
at java.io.RandomAccessFile.writeByte(RandomAccessFile.java:991) ~[na:1.8.0_65]
at com.pi4j.io.i2c.impl.I2CBusImpl.lambda$writeByteDirect$4(I2CBusImpl.java:170) ~[pi4j-core-1.2-SNAPSHOT.jar!/:na]
at com.pi4j.io.i2c.impl.I2CBusImpl.runBusLockedDeviceAction(I2CBusImpl.java:260) ~[pi4j-core-1.2-SNAPSHOT.jar!/:na]
at com.pi4j.io.i2c.impl.I2CBusImpl.writeByteDirect(I2CBusImpl.java:169) ~[pi4j-core-1.2-SNAPSHOT.jar!/:na]
at com.pi4j.io.i2c.impl.I2CDeviceImpl.write(I2CDeviceImpl.java:92) ~[pi4j-core-1.2-SNAPSHOT.jar!/:na]
at com.pi4j.component.lcd.impl.I2CLcdDisplay.write(I2CLcdDisplay.java:280) ~[pi4j-device-1.1.jar!/:na]
at com.pi4j.component.lcd.impl.I2CLcdDisplay.lcd_byte(I2CLcdDisplay.java:188) ~[pi4j-device-1.1.jar!/:na]
at com.pi4j.component.lcd.impl.I2CLcdDisplay.init(I2CLcdDisplay.java:216) ~[pi4j-device-1.1.jar!/:na]
at com.pi4j.component.lcd.impl.I2CLcdDisplay.<init>(I2CLcdDisplay.java:133) ~[pi4j-device-1.1.jar!/:na]
at display.Display.test(Display.java:22) ~[classes!/:na]

i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --


What are correct values for init?

User avatar
DougieLawson
Posts: 34166
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: PI4J + Adafruit LCD with MCP23017

Sun Jul 29, 2018 11:16 am

Can you post your Display.java source code (in [code][/code] tags) or tell us where you found it?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

WalterHeisenberg
Posts: 10
Joined: Thu Aug 03, 2017 7:04 pm

Re: PI4J + Adafruit LCD with MCP23017

Sun Jul 29, 2018 2:42 pm

DougieLawson wrote:
Sun Jul 29, 2018 11:16 am
Can you post your Display.java source code (in [code][/code] tags) or tell us where you found it?
See first code block in my post.
Line 22 from stacktrace is the first line

Code: Select all

LCD lcd = new I2CLcdDisplay(2, 16, 1, 20,   0, 15, 14, 13, 9, 6, 11, 12);
 

User avatar
DougieLawson
Posts: 34166
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: PI4J + Adafruit LCD with MCP23017

Sun Jul 29, 2018 4:49 pm

I need the whole Pi4J Java program because my crystal ball went offine in "The Great Crystal Ball Disaster" of 1989 and I can't invent Java at will now.

Or do I start hacking https://raw.githubusercontent.com/Pi4J/ ... ample.java ?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

WalterHeisenberg
Posts: 10
Joined: Thu Aug 03, 2017 7:04 pm

Re: PI4J + Adafruit LCD with MCP23017

Sun Jul 29, 2018 5:54 pm

DougieLawson wrote:
Sun Jul 29, 2018 4:49 pm
whole Pi4J Java program

What are you talking about?
This is whole java program. "public static void main" + 2 lines I provided. What else do you need? Sources of pi4j?

User avatar
DougieLawson
Posts: 34166
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: PI4J + Adafruit LCD with MCP23017

Sun Jul 29, 2018 6:05 pm

I need something that tells me what the heck you're trying to compile and run on your Rpi because I'm not psychic and you've not given the whole picture.

http://www.catb.org/esr/faqs/smart-questions.html

If you can't do that, I can't be bothered to help. Best of luck getting your code to work.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

WalterHeisenberg
Posts: 10
Joined: Thu Aug 03, 2017 7:04 pm

Re: PI4J + Adafruit LCD with MCP23017

Sun Jul 29, 2018 6:10 pm

I already said:
Trying to work with LCD

Code: Select all

LCD lcd = new I2CLcdDisplay(2, 16, 1, 20,   0, 15, 14, 13, 9, 6, 11, 12);

Code: Select all

Result:
java.io.IOException: Input/output error
at java.io.RandomAccessFile.write0(Native Method) ~[na:1.8.0_65]
at java.io.RandomAccessFile.write(RandomAccessFile.java:489) ~[na:1.8.0_65]
at java.io.RandomAccessFile.writeByte(RandomAccessFile.java:991) ~[na:1.8.0_65]
at com.pi4j.io.i2c.impl.I2CBusImpl.lambda$writeByteDirect$4(I2CBusImpl.java:170) ~[pi4j-core-1.2-SNAPSHOT.jar!/:na]
at com.pi4j.io.i2c.impl.I2CBusImpl.runBusLockedDeviceAction(I2CBusImpl.java:260) ~[pi4j-core-1.2-SNAPSHOT.jar!/:na]
at com.pi4j.io.i2c.impl.I2CBusImpl.writeByteDirect(I2CBusImpl.java:169) ~[pi4j-core-1.2-SNAPSHOT.jar!/:na]
at com.pi4j.io.i2c.impl.I2CDeviceImpl.write(I2CDeviceImpl.java:92) ~[pi4j-core-1.2-SNAPSHOT.jar!/:na]
at com.pi4j.component.lcd.impl.I2CLcdDisplay.write(I2CLcdDisplay.java:280) ~[pi4j-device-1.1.jar!/:na]
at com.pi4j.component.lcd.impl.I2CLcdDisplay.lcd_byte(I2CLcdDisplay.java:188) ~[pi4j-device-1.1.jar!/:na]
at com.pi4j.component.lcd.impl.I2CLcdDisplay.init(I2CLcdDisplay.java:216) ~[pi4j-device-1.1.jar!/:na]
at com.pi4j.component.lcd.impl.I2CLcdDisplay.<init>(I2CLcdDisplay.java:133) ~[pi4j-device-1.1.jar!/:na]
at display.Display.test(Display.java:22) ~[classes!/:na]
If you can't help then just move away.

WalterHeisenberg
Posts: 10
Joined: Thu Aug 03, 2017 7:04 pm

Re: PI4J + Adafruit LCD with MCP23017

Sun Jul 29, 2018 6:16 pm

Your example https://raw.githubusercontent.com/Pi4J/ ... ample.java is not working for me.

I got just a message
<--Pi4J--> Wiring Pi LCD test program
in output and nothing else. Lcd didnt change the state.

WalterHeisenberg
Posts: 10
Joined: Thu Aug 03, 2017 7:04 pm

Re: PI4J + Adafruit LCD with MCP23017

Mon Jul 30, 2018 2:11 am

Looks like I found the issue.

was:

Code: Select all

LCD lcd = new I2CLcdDisplay(2, 16, 1, 20,   0, 15, 14, 13, 9, 6, 11, 12);
now:

Code: Select all

LCD lcd = new I2CLcdDisplay(2, 16, 1, 0x20, 0, 15, 14, 13, 9, 10, 11, 12);
Trying to print something with no reaction..

Code: Select all

        lcd.clear();

        lcd.write(0, "111 ");
        lcd.write(1, "222");
Update 1:
I feel like Im doing something wrong with GPIO connections...
IMG_4356.JPG
IMG_4356.JPG (139.63 KiB) Viewed 821 times
Update 2:
No... python example is working fine...

Return to “Java”