Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Is it safe to connect a 5V I2C LCD module to a 3.3v Teensy 3.6 ?

  1. #1
    Member
    Join Date
    Mar 2019
    Location
    Bordeaux / France
    Posts
    68

    Is it safe to connect a 5V I2C LCD module to a 3.3v Teensy 3.6 ?

    Hi, I'll get my Teensy 3.6 today and the only component I have to play with it is an I2C 5V LCD module...

    Being a total newbie, I wonder if any arm can happen if I just try to use the LCD module with the 3.3v out of the Teensy (and I2C wires of course), without any pullup resistors, except that the LCD could not operate at 3.3v (being to dark to be read for example)

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,586
    Whatever you do - be sure to NOT connect 5V to any pin on the T3.6 - It will die immediately.
    Best is to buy a 3V display.

  3. #3
    Member
    Join Date
    Mar 2019
    Location
    Bordeaux / France
    Posts
    68
    Yeah, I just want to stick to 3.3v and see if the LCD can work at this voltage, I'll not use any 5V power supply...

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    2,955
    Quote Originally Posted by Tactif CIE View Post
    Hi, I'll get my Teensy 3.6 today and the only component I have to play with it is an I2C 5V LCD module...

    Being a total newbie, I wonder if any arm can happen if I just try to use the LCD module with the 3.3v out of the Teensy (and I2C wires of course), without any pullup resistors, except that the LCD could not operate at 3.3v (being to dark to be read for example)
    As Frank B says, the 3.6 is not tolerant of 5v at all, and you are likely to fry the 3.6 if you use a 5v connection.

    To do it properly, you need a bi-directional i2c level converter that you plug 3.3v, SCL, & SDA on the Teensy to one side, and 5v, SCL, & SDA on the remote side. Some provide a ground pin to connect as well. If not, you need to connect the grounds between the Teensy and the display. If you are powering your Teensy via USB, you can use the VIN pin on the Teensy to provide 5v power to the display. Here is the i2c level converter that I've used in the past:


    Note, many displays will work with either 3.3v or 5v. Some of the early i2c displays that I got were 5v only, but most things you buy today are dual voltage.

    If you had a 3.3v capable display and didn't need the level conversion, you may need two pull-up resistors (in the 2.2k to 4.7k range). One resistor would connect to the Teensy's SDA pin and 3.3v, while the other would connect the SCL pin and 3.3v. You might not need it, if the display has its own pull-up resistors (some do, some don't). On an Arduino AVR system like the Uno, you don't need pull-up resistors, since the chip has strong enough internal pull-up resistors. On ARM based systems like the Teensy LC or 3.x systems, you tend to need the external pull-up resistors.

    If you just want status messages, you can use the serial monitor on the IDE session, using Serial.print and Serial.println statements. These is a button in the upper right of the Arduino display to bring up the serial monitor.

    The way to see if you need pull-up resistors is to bring up the example Wire -> Scanner. Start the serial monitor, and download the scanner example to the Teensy. Every 5 seconds you should see a line saying Device such and such. If the scanner example hangs, that is a sign you need pull-up resistors. If the scanner example loops printing, but does not print a device, that is a symptom that something isn't connected correctly.

    Rather than fritz around level shifting, it might be simpler to get a new display. PJRC.com offers a TFT LCD display (320x240 pins) complete with touchscreen for $15. Note, this is a SPI display rather than I2C, so the connections are a little different:


    You can get cheap 128x64 OLED displays on ebay. These may or may not have pull-up resistors. For example, from US sellers:


    I believe the Adafruit displays do have pull-up reisstors already in place:

  5. #5
    Member
    Join Date
    Mar 2019
    Location
    Bordeaux / France
    Posts
    68
    Thank you for your answers ! But there's something I really don't understand : how would I fry my Teensy if I drive the LCD with 3.3v instead of 5V ?

    Does that mean that a 5V LCD fed with 3.3V will produce 5V on I2C wires ?

  6. #6
    Does that mean that a 5V LCD fed with 3.3V will produce 5V on I2C wires ?
    No, it doesn't.
    If you just feed the LCD with 3.3V your teensy is not in danger. Maybe your display doesn't work (depends on LCD module).

  7. #7
    Member
    Join Date
    Mar 2019
    Location
    Bordeaux / France
    Posts
    68
    Ok, fine ! Will have a toy to play with tonight ;-)

  8. #8
    Member
    Join Date
    Mar 2019
    Location
    Bordeaux / France
    Posts
    68
    Done it just right now ! For newbies like me I leave a trace here ;-)

    1) Yes a 5V I2C LCD works under 3.3v but obviously the screen is not very bright
    2) I had to install (and use) the i2c_t3 library from github zip latest release
    3) I had to install from library manager the LiquidCrystal_I2C library
    4) Find the LiquidCrystal_I2C .cpp and .h, comment #include <Wire.h> and add #include <i2c_t3.h>
    5) Use internal pullups with i2c_t3 library

    First time booted my Teensy at 17:15PM - Got LCD display ok at 18:30

    Not soooo bad :-) Even with way too long breadboard wires - That might and will cause problems - But at least I can start to code and play with something else than a blinking led !

    Eg.

    Code:
    //YWROBOT
    //Compatible with the Arduino IDE 1.0
    //Library version:1.1
    #include <i2c_t3.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()
    {
      Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_INT, 400000);
      Wire.setDefaultTimeout(10000); // 10ms
      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()
    {
    }

  9. #9
    Junior Member
    Join Date
    May 2019
    Posts
    2
    Thank you so much for this. I'm also a newbie and have just bought a new led module (like literally I just bought one yesterday haha) I can play with my Teensy.

  10. #10
    Member
    Join Date
    Mar 2019
    Location
    Bordeaux / France
    Posts
    68
    You're welcome ;-)

    BTW, if you want to use the i2c_t3 library everywhere you can create a "Wire" subdirectory in your local arduino path (on a Mac it's ~/Arduino/libraries) and put an Wire.h file with only one line

    Code:
    #include <i2c_t3.h>
    Because the real Wire library is not compatible with i2c_t3

    Second point, contrary to what I said in a previous post, you don't have to clone the i2c_t3 library from Github, because it's already included and available in TeensyDuino

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •