I've connected this "LCM1602" LCD that has an I2C interface based on PCF8574T. I use GP23 and GP24 for it, which on my WiPy are SCL and SDA respectively.
First thing I did was initialise I2C and scan for the board, which returned the address successfully (0x27). So far so good.
The next thing I did was utilise slothy's lcdi2c library at https://github.com/slothyrulez/lcdi2c (announced on the forum at http://forum.micropython.org/viewtopic. ... 397&p=8634 ) - which worked fine from the REPL. The following code, however:
Code: Select all
# main.py -- put your code here!
from lcd_i2c import LCDI2C
from machine import Pin
from time import sleep_ms
disp = LCDI2C()
disp.configure()
# switch
user_switch = Pin.board.GP17
user_switch.init(mode=Pin.IN, pull=Pin.PULL_UP)
marq = [c for c in b'This is a test ']
while user_switch():
disp.setCursor(0,0)
for c in marq:
disp.write(c)
marq = marq[-1:] + marq[:-1]
sleep_ms(250)
Code: Select all
Traceback (most recent call last):
File "main.py", line 19, in <module>
File "hd44780_lcd.py", line 153, in write
File "lcd_i2c.py", line 98, in send
File "lcd_i2c.py", line 124, in _write4bits
File "lcd_i2c.py", line 106, in _pulse_enable
OSError: the requested operation failed
Code: Select all
self.i2c.writeto(self.addr, data & ~self.en[0])
My uname() result is (sysname='WiPy', nodename='WiPy', release='1.2.0', version='v1.8.1-181-ga4c8a1f on 2016-07-08', machine='WiPy with CC3200') - I updated to today's build. I use the expansion board.
I did a bit of digging in the lcd_itc code, and through the PCF8574T datasheet - but with my limited experience I can't see what's wrong.
From a hardware perspective, I run the system from USB using the WiPy expansion board, so I have the two voltage buses - 5v and 3.3v. The LCD requires 5v, and since WiPy comes with strict warnings about not tolerating anything above 3.8v I had to build bidirectional level shifters for the SDA and SCL signals. I used a simple design with a BS170 MOSFET and two 10Kohm pull-up resistors. It seems to work well as far as I'm able to test. I use GP23 and GP24 on the board.