teensy 3.5 and I2C MODULE FOR LCD 20X4

Status
Not open for further replies.

turnarobo

Member
Dear All. We are passing to Arduino mega to teensy but really hard time for us . One problem appear at lcd . We use LCD with LCD_I2C lib in arduino and it work well . When i check at teensy forum a lot solution but LCD could not working .

1)Which library do you use for LCD ?
2) do you use 4.7K pull up resistors for SDA-SCL?
3) Which code do you use ?
 
LiquidCrystal_I2C has been reported to work.

Yes, pullup resistors are required on SDA and SCL. Most displays have these built in. But if your doesn't, or if you're making your own circuitry, you must have the real pullup resistors when using Teensy 3.5.
 
We tried 4.7K and LiquidCrystal_I2C.h library with below code (it is sample code ) We did not see any words on lcd . connection VIN-VCC , GND- GND, SDA-PIN 18 ,SCL-PIN19 .. VIN- 4.7K SDA , VIN -4.7K+ SCL
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("Hello, world!");
lcd.setCursor(2,1);
lcd.print("Ywrobot Arduino!");
lcd.setCursor(0,2);
lcd.print("Arduino LCM IIC 2004");
lcd.setCursor(2,3);
lcd.print("Power By Ec-yuan!");
}


void loop()
{
}
 
Do you see the test characters when the LCD is turned on? If not you have some form of contrast issue to sort out before chasing the interface. Depending on the LCD PCB it may be possible to run the controller and I2C at 3.3V while the LCD, and critically it's contrast circuit is on 5V.

Certainly I have had success getting that display or a near clone to work on a Teensy at 3.3V, but the actual display had so little contrast as to appear non functional which may be what is happening. If you have access to test equipment it may be useful to monitor the clock line to the LCD, which should be toggling at least a couple of times for each display write if the i2C side of things is working.
 
We tried 4.7K and LiquidCrystal_I2C.h library with below code (it is sample code ) We did not see any words on lcd . connection VIN-VCC , GND- GND, SDA-PIN 18 ,SCL-PIN19 .. VIN- 4.7K SDA , VIN -4.7K+ SCL
The pull-up resistors must be between SDA and 3.3v and the other between SCL and 3.3v, NOT VIN.

Now, depending on the LCD, it may work with 3.3v. I had some old LCDs that only worked with 5v, but I had newer ones that worked with either 3.3v or 5v. Also for 3.3v systems, the pull-up resistor would typically be 2.2K or 2.4K. 4.7K is the standard pull-up resistor for 5v systems. You can use it with Teensy, but it may prevent you from using the higher i2c bus speeds (which is not an issue in this case).

I would try using the LCD with a 3.3v setup:
  • Teensy 3.3v to LCD VCC;
  • Teensy normal ground (next to pin 0, not the analog ground between 3.3v and VIN) to LCD GND;
  • Teensy pin 18/A4 to LCD SDA;
  • Teensy pin 19/A5 to LCD SCL;
  • 2.2K pull-up resistor between Teensy pin 18/A4 and Teensy 3.3v;
  • 2.2K pull-up resistor between Teensy pin 19/A5 and Teensy 3.3v.

The 16x2 and 20x4 LCDs tended to have a back light to show the text. If the backlight doesn't show up, it may be the display needs 5v.

Then go to the Teensy IDE, and goto Examples -> wire -> Scanner. Start the serial monitor, and then load this sketch. If the sketch hangs, then it is a sign that the pull-up resistors aren't right. If it finds a device, that is probably your LCD. If the scanner doesn't find any devices, then the setup isn't correct. If it prints a number in hex (starting with 0x), then that is the device id. If the number isn't 0x27, then you need to change your sketch to use that number. While 0x27 is the default, on some LCDs, you can change the default, and perhaps the default on your LCD is not 0x27.

If the i2c scanner doesn't show anything, then you need to think about using a level shifter.

In the future, when you add code to display there is a '#' button. Click that, and enter the text between the CODE and /CODE sections (CODE and /CODE will be inside square brackets).

Code:
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

Note, if you have a 16x2 display, you should change the 20, 4 to 16, 2.
 
LCD-I2C Works

I followed Michael's directions and could not get my LCD-I2C to work until I added the level shifters that Michael mentioned. I powered the LCD with 5 V then level shifted the SCL and SDA lines. I have the 5v in to the level shifter on the high voltage side and 3.3 v to the level shifter on the LV side.. I included the pullup resistors mentioned on the LV side SCL and SDA lines to 3.3 v. It worked both with 2.2 k ohms and 4.7 k ohms. The chip on my I2C port expander is a PCF8574AT, its address is 0x3F. I believe the PCF8574 address is 0x27.

Thanks to Michael for getting me on the right track.



The pull-up resistors must be between SDA and 3.3v and the other between SCL and 3.3v, NOT VIN.

Now, depending on the LCD, it may work with 3.3v. I had some old LCDs that only worked with 5v, but I had newer ones that worked with either 3.3v or 5v. Also for 3.3v systems, the pull-up resistor would typically be 2.2K or 2.4K. 4.7K is the standard pull-up resistor for 5v systems. You can use it with Teensy, but it may prevent you from using the higher i2c bus speeds (which is not an issue in this case).

I would try using the LCD with a 3.3v setup:
  • Teensy 3.3v to LCD VCC;
  • Teensy normal ground (next to pin 0, not the analog ground between 3.3v and VIN) to LCD GND;
  • Teensy pin 18/A4 to LCD SDA;
  • Teensy pin 19/A5 to LCD SCL;
  • 2.2K pull-up resistor between Teensy pin 18/A4 and Teensy 3.3v;
  • 2.2K pull-up resistor between Teensy pin 19/A5 and Teensy 3.3v.

The 16x2 and 20x4 LCDs tended to have a back light to show the text. If the backlight doesn't show up, it may be the display needs 5v.

Then go to the Teensy IDE, and goto Examples -> wire -> Scanner. Start the serial monitor, and then load this sketch. If the sketch hangs, then it is a sign that the pull-up resistors aren't right. If it finds a device, that is probably your LCD. If the scanner doesn't find any devices, then the setup isn't correct. If it prints a number in hex (starting with 0x), then that is the device id. If the number isn't 0x27, then you need to change your sketch to use that number. While 0x27 is the default, on some LCDs, you can change the default, and perhaps the default on your LCD is not 0x27.

If the i2c scanner doesn't show anything, then you need to think about using a level shifter.

In the future, when you add code to display there is a '#' button. Click that, and enter the text between the CODE and /CODE sections (CODE and /CODE will be inside square brackets).



Note, if you have a 16x2 display, you should change the 20, 4 to 16, 2.
 
Status
Not open for further replies.
Back
Top