The adafruit library offers LCD control with python on RPI GPIO or over MCP230XX i2C gpio expander. I want to use the same idea for the PCF8574. It's all about these things: http://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html
The Adafruit library i use for the LCD is this one: https://github.com/adafruit/Adafruit_Python_CharLCD
In Adafruit_GPIO is also contained a library for the PCF8574 i2C gpio expander. https://github.com/adafruit/Adafruit_Python_GPIO
In the examples there is only made use of the MCP230XX but not of the PCF8574.
After hours of trying, i do not get that thing to work properly with the adafruit code.
Notice that i found a working code but want to use the adafruit code instead for better maintenance and support. The working code is this one: https://github.com/goshkis/rpi/blob/master/lcddriver.py
Here is my current code:
#!/usr/bin/env python
import time
import Adafruit_CharLCD as LCD
import Adafruit_GPIO.PCF8574 as PCF
# Define PCF pins connected to the LCD.
PCF8574T_addr = 0x27
lcd_rs = 0
lcd_rw = 1
lcd_en = 2
lcd_d4 = 4
lcd_d5 = 5
lcd_d6 = 6
lcd_d7 = 7
lcd_backlight = 3
# Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows = 2
# Initialize i2C device using its I2C address.
gpio = PCF.PCF8574(PCF8574T_addr, busnum=1)
# Initialize the LCD
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
lcd_columns, lcd_rows, lcd_backlight, gpio=gpio)
# Clear display and show greeting, pause 1 sec
lcd.clear()
lcd.set_backlight(True)
lcd.message("Gartenwasser startet...")
time.sleep(1)
Can you find that error i make?
The fork of that Adafruit repository on github shows how it works: https://github.com/sylvandb/Adafruit_Python_CharLCD
working example:
import PCF_CharLCD as LCD
lcd = LCD.PCF_CharLCD(0, address=0x27, busnum=1, cols=16, lines=2)