1

I am using a 16x2 LCD and have it connected with MCP23017 16-bit IO port expander. To display message to the LCD, I am using Adafruit LCD library. The also have a test python code to get it working with MCP23017. I have changed the pin according to the connections I have made but it seems to be displaying only blocks in the first row of the LCD. I tried different pins, but I can't get it to work.

LCD: http://www.ebay.in/itm/16x2-Character-LCD-Module-HD44780-JHD-Black-on-Green-Backlight-Berg-Strip-/221634648684?pt=LH_DefaultDomain_203&hash=item339a745a6c

Adafruit library: https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/master/Adafruit_CharLCD

Also I have I2C enabled on my Raspberry Pi 2

Code I am using:

#!/usr/bin/python
# Example script to show usage of MCP230xx GPIO extender to drive character LCD.

from Adafruit_CharLCD import Adafruit_CharLCD
from Adafruit_MCP230xx import MCP230XX_GPIO

bus = 1         # Note you need to change the bus number to 0 if running on a revision 1 Raspberry Pi.
address = 0x20  # I2C address of the MCP230xx chip.
gpio_count = 16  # Number of GPIOs exposed by the MCP230xx chip, should be 8 or 16 depending on chip.

# Create MCP230xx GPIO adapter.
mcp = MCP230XX_GPIO(bus, address, gpio_count)

# Create LCD, passing in MCP GPIO adapter.
lcd = Adafruit_CharLCD(pin_rs=0, pin_e=1, pins_db=[4,5,6,7], GPIO=mcp)

lcd.clear()
lcd.message("  Adafruit 16x2\n  Standard LCD")

Wiring:

MCP           - PI2
SCL(Pin 12)   - GIPO0 (Pin 3)
SDA(Pin 13)   - GPIO1 (Pin 5)
VDD(pin 9)    - 3.3V
VSS(Pin 10)   - Gnd
A0(Pin 15)    - Gnd
A1(Pin 16)    - Gnd
A2(Pin 17)    - Gnd
Reset(Pin 18) - 3.3V

MCP          - LCD
GPA0(Pin 21) - RS (Pin 4)
GPA1(Pin 22) - E (Pin 6)
GPA4(Pin 25) - DB4 (Pin 11)
GPA5(Pin 26) - DB5 (Pin 12)
GPA6(Pin 27) - DB6 (Pin 13)
GPA7(Pin 28) - DB7 (Pin 14)

Also the RW pin of LCD is grounded. Below is the sketch for more clarity:

MCP23017-LCD-PI2

Any idea why this is happening or is there any step I am missing.

Prashant
  • 121
  • 1
  • 7

1 Answers1

1

This problem is all about setting the correct pin number. In my case there were 2 things that happened. First, the jumper wire I am using is faulty and the second thing was the wiring was not proper. This is the final wiring I have now. This works well with Adafruit CharLCD library.

enter image description here

Code:

#!/usr/bin/python
import Adafruit_CharLCD as LCD
import Adafruit_GPIO.MCP230xx as MCP

#assuming i2c address is 0x20 and bus address is 1
gpio = MCP.MCP23017();

#replace None with the pin number if you want to control backlight
lcd = LCD.Adafruit_CharLCD(14,12,8,9,10,11,16,2,None,gpio=gpio)

#turn on the LCD backlight
#lcd.set_backlight(0)

lcd.clear()
lcd.message('This is a test msg')
Prashant
  • 121
  • 1
  • 7