i2c LCD Backpack & Level Shifter
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- igotdt
- Posts: 11
- Joined: Sun Mar 09, 2014 4:06 pm
i2c LCD Backpack & Level Shifter
Starting to get the hang of this hardware/software maker stuff, but I still have a lot to learn. Without doing enough research, I recently purchased two LCD 20x4 (id:198) and i2c/SPI LCD Backpacks (id:292) to use with my RPi. Afterwards, I figured out the 5V needed for the LCD is too much for the RPi's 3.3V i2c. I have now learned I need a level shifter on the i2c lines. No problem (this hobby keeps me out of trouble). Before I place the order for the level shifters (I am looking at id:757), will they work for these LCDs/Backpacks and will they work with other components on the i2c that are 3.3V? I have read through many help pages and found that they should. Also have learned that I need to place resistors in but am getting really confused as to where (and size?). I need explicit direction or pictures on the wiring part. My mind is going to mush. Is the following going in the right direction? Any help would be greatly appreciated. Thanks
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: i2c LCD Backpack & Level Shifter
That looks fine.
- igotdt
- Posts: 11
- Joined: Sun Mar 09, 2014 4:06 pm
Re: i2c LCD Backpack & Level Shifter
And any resistors? Where? Size?
- igotdt
- Posts: 11
- Joined: Sun Mar 09, 2014 4:06 pm
Re: i2c LCD Backpack & Level Shifter
Any help, please? This is not working as shown above. Do I or do I not add p/u resistors to the sda/scl lines? Any other advice? I am using the code from Adafruit_CharLCD on github if it matters.
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: i2c LCD Backpack & Level Shifter
You need pull up resistors if the product does not provide them internally. 4.7K (4K7) should work.
- igotdt
- Posts: 11
- Joined: Sun Mar 09, 2014 4:06 pm
Re: i2c LCD Backpack & Level Shifter
Thank you for the response. According to the product description for the level shifter (http://www.adafruit.com/products/757), it includes 10k p/u. However, I have tried with and without and the result was still nothing. "sudo i2cdetect -y 1" sees the device at 0x20, so I know at least that part is working. Perhaps my code is bad.
It runs with no errors but I get nothing on the display. I have three displays and none of them produce a result. They did work fine without the i2c backpack. Am I missing something? Suggestions?
Code: Select all
import math
import time
import Adafruit_CharLCD as LCD
import Adafruit_GPIO.MCP230xx as MCP
lcd_rs = 0
lcd_en = 1
lcd_d4 = 2
lcd_d5 = 3
lcd_d6 = 4
lcd_d7 = 5
lcd_backlight = 6
lcd_columns = 20
lcd_rows = 4
gpio = MCP.MCP23008()
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight, gpio=gpio)
lcd.message('Hello\nworld!')
time.sleep(5.0)
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: i2c LCD Backpack & Level Shifter
Then let's have a look at your code. Post it here using the </> button above the reply window and post your code between the tags.
- igotdt
- Posts: 11
- Joined: Sun Mar 09, 2014 4:06 pm
Re: i2c LCD Backpack & Level Shifter
I did. Does it not show for anyone but me?
- igotdt
- Posts: 11
- Joined: Sun Mar 09, 2014 4:06 pm
Re: i2c LCD Backpack & Level Shifter
Here is the code. Quite simple to test. I am just pasting it in without the tags because apparently no one can see the code when I use the code tags.
import math
import time
import Adafruit_CharLCD as LCD
import Adafruit_GPIO.MCP230xx as MCP
lcd_rs = 0
lcd_en = 1
lcd_d4 = 2
lcd_d5 = 3
lcd_d6 = 4
lcd_d7 = 5
lcd_backlight = 6
lcd_columns = 20
lcd_rows = 4
gpio = MCP.MCP23008()
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight, gpio=gpio)
lcd.message('Hello\nworld!')
time.sleep(5.0)
import math
import time
import Adafruit_CharLCD as LCD
import Adafruit_GPIO.MCP230xx as MCP
lcd_rs = 0
lcd_en = 1
lcd_d4 = 2
lcd_d5 = 3
lcd_d6 = 4
lcd_d7 = 5
lcd_backlight = 6
lcd_columns = 20
lcd_rows = 4
gpio = MCP.MCP23008()
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight, gpio=gpio)
lcd.message('Hello\nworld!')
time.sleep(5.0)
- igotdt
- Posts: 11
- Joined: Sun Mar 09, 2014 4:06 pm
Re: i2c LCD Backpack & Level Shifter
Final plea for help. What is wrong here? LCD display does not work.
Code: Select all
import math
import time
import datetime
from LEDseven import led
import Adafruit_CharLCD as LCD
import Adafruit_GPIO.MCP230xx as MCP
lcd_rs = 0
lcd_en = 1
lcd_d4 = 2
lcd_d5 = 3
lcd_d6 = 4
lcd_d7 = 5
lcd_backlight = 6
lcd_columns = 20
lcd_rows = 4
lcd_gpio = MCP.MCP23008(address=0x20)
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight, gpio=lcd_gpio)
disp = led(address=0x74)
colon = False
try:
xso = 90
xmo = 90
while True:
x = datetime.datetime.now()
xs = x.second
xm = x.minute
if (xmo != xm):
disp.writeDigit(0, int(x.hour / 10))
disp.writeDigit(1, x.hour % 10)
disp.writeDigit(2, int(xm / 10))
disp.writeDigit(3, xm % 10)
xmo = xm
if (xso != xs):
lcd_time = str(int(x.hour / 10)) + str(x.hour % 10) + ":" + str(int(xm / 10)) + str(xm % 10) + ":" + str(int(xs / 10)) + str(xs % 10)
lcd.clear()
lcd.message(lcd_time)
xso = xs
print lcd_time # checking to see if this loop is even running
disp.colon(colon)
colon = not colon
time.sleep(0.5)
except KeyboardInterrupt:
disp.erase(True)
lcd.clear()
finally:
print "Exiting"
Please be positive and constructive with your questions and comments.