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

Thread: 1602 lcd with I2c board and Teensy 3.2

  1. #1

    1602 lcd with I2c board and Teensy 3.2

    I have a teensy 3.2 and want to hook up a 1602 LCD display. I purchased a few of these cheap with the 1602 and I2C board

    Click image for larger version. 

Name:	1602lcdi2c.JPG 
Views:	225 
Size:	31.0 KB 
ID:	13609

    I have the VCC hooked to the 3.3v pin on the Teensy and Ground to ground.

    SDA to A4
    SDL to A5

    I can see the text barely on the screen and I have adjusted the contrast pot already. It is very dim. I have tested it on a Raspberry Pi and it works and looks good.

    What am I missing here? Is it because it is hooked up to 3.3v and not 5v?

    Just using a some example code I found on the internet:

    Code:
    /* YourDuino.com Example Software Sketch
     20 character 4 line I2C Display
     Backpack Interface labelled "LCM1602 IIC  A0 A1 A2"
     terry@yourduino.com */
    
    /*-----( Import needed libraries )-----*/
    #include <Wire.h>  // Comes with Arduino IDE
    // Get the LCD I2C Library here: 
    // https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
    // Move any other LCD libraries to another folder or delete them
    // See Library "Docs" folder for possible commands etc.
    #include <LiquidCrystal_I2C.h>
    
    /*-----( Declare Constants )-----*/
    //none
    /*-----( Declare objects )-----*/
    // set the LCD address to 0x20 for a 20 chars 4 line display
    // Set the pins on the I2C chip used for LCD connections:
    //                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
    LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
    
    
    /*-----( Declare Variables )-----*/
    //none
    
    void setup()   /*----( SETUP: RUNS ONCE )----*/
    {
      Serial.begin(9600);  // Used to type in characters
    
      lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines and turn on backlight
    
    // ------- Quick 3 blinks of backlight  -------------
      for(int i = 0; i< 3; i++)
      {
        //lcd.setBacklight(HIGH);
        lcd.backlight();
        delay(250);
        lcd.noBacklight();
        delay(250);
      }
      lcd.backlight(); // finish with backlight on  
      
    //-------- Write characters on the display ----------------
    // NOTE: Cursor Position: CHAR, LINE) start at 0  
      lcd.setCursor(3,0); //Start at character 4 on line 0
      lcd.print("Hello, world!");
      delay(1000);
      lcd.setCursor(2,1);
      lcd.print("From YourDuino");
      delay(1000);  
      lcd.setCursor(0,2);
      lcd.print("20 by 4 Line Display");
      lcd.setCursor(0,3);
      delay(2000);   
      lcd.print("http://YourDuino.com");
      delay(8000);
    // Wait and then tell user they can start the Serial Monitor and type in characters to
    // Display. (Set Serial Monitor option to "No Line Ending")
      lcd.setCursor(0,0); //Start at character 0 on line 0
      lcd.print("Start Serial Monitor");
      lcd.setCursor(0,1);
      lcd.print("Type chars 2 display");   
    
    
    }/*--(end setup )---*/
    
    
    void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
    {
      {
        // when characters arrive over the serial port...
        if (Serial.available()) {
          // wait a bit for the entire message to arrive
          delay(100);
          // clear the screen
          lcd.clear();
          // read all the available characters
          while (Serial.available() > 0) {
            // display each character to the LCD
            lcd.write(Serial.read());
          }
        }
      }
    
    }/* --(end main loop )-- */
    
    
    /* ( THE END ) */

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,584
    Just give it a try with 5V supply. If the I2C adapter is of good quality, it will deal with the 3.3V signals from the Teensy’s 5V tolerant pins.

  3. #3
    Quote Originally Posted by Theremingenieur View Post
    Just give it a try with 5V supply. If the I2C adapter is of good quality, it will deal with the 3.3V signals from the Teensy’s 5V tolerant pins.
    Do I need to use and pullup resistors on the SDA/SCL pins of the LCD then? or just hook a 5v and ground to the I2C adapter and the SDA/SCL to the teensy?

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,584
    On I2C, pull-up resistors are always needed. If there aren’t on your I2C adapter board, hook 4.7k from each SDA and SCL towards 5V. It won’t kill the Teensy.

  5. #5
    Quote Originally Posted by Theremingenieur View Post
    On I2C, pull-up resistors are always needed. If there aren’t on your I2C adapter board, hook 4.7k from each SDA and SCL towards 5V. It won’t kill the Teensy.
    Worked. Thanks. Now I need to figure out how to replace my 128x64 OLED with this 1602 on my guitar foot controller.

    Also it looks like the I2C already has pull-up resistors of 4.7k in the circuit. I have verified they are connected to the SDA and SDL pins. See attached.

    Click image for larger version. 

Name:	iic-i2c-twi-serial-interface-board-module.jpg 
Views:	89 
Size:	158.0 KB 
ID:	13612
    Last edited by SHIFT838; 04-17-2018 at 09:23 PM.

  6. #6
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    26
    Does this mean I need a dedicated adapter board to use I2C with external devices?

  7. #7
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,828
    Quote Originally Posted by blakeAlbion View Post
    Does this mean I need a dedicated adapter board to use I2C with external devices?
    It is one of those things where the answer is it depends on the board and your Teensy.

    If your board needs 5v power and 5v I2C signals, then yes you need a voltage level shifter.

    If your board needs 5v power, you are using a Teensy 3.2 or 3.5, and it can use 3.3v I2C signals, then you may need 4.7K pull-up resistors. If you are using a breadboard, you can just put the resistors in the extra pins on the bread board for the SCL/SDA pins (a pull-up resistor is one that is connected on one end to your power source, which is 3.3v, and on the other end is connected in parallel to the pin). On the other Teensys that aren't 5v tolerant, it may work if the device you are connecting to actually does I2C at 3.3v. You may also need to connect inline resistors to bring the power down to 3.3v.

    If your board needs 3.3v power, you might need at least 2.2K pull-up resistors. You can use 4.7K resistors, and generally it should work. But as you add more resistance (either with larger resistors or by having multiple pull-up resistors), it might impact using the higher speed I2C modes.

    If you are the stage where you are soldering, you could always take 4 jumper wires and add the pull-up resistors in the middle of the wire. Then just use these wires. While it would work, it may be on the fragile side. I tend to like getting the small prototype boards from this seller. I use the smaller boards to add 4 female right angle pins on each side, 4 pieces of wire to join each side, and adding in the pull-up resistors. Instead of right angle pins that you plug jumper wires into, you just cut 4 jumper wires in half, and solder each jumper cable to the board. Then you use just like you would normal jumper cables:


    Back when I used level shifters, I would use the middle sized pieces from that seller to incorporate the shifter. Or I would use the larger boards that the seller created, and incorporate the shifter into the board.

    Alternatively if you get those small breadboards (such as the ones with 2 sets of parallel 17 rows of pins), you can put the pull-up setup in that board, and possibly the level shifter.

    If you have a mixture of 3.3v and 5v I2C devices, you can put the 3.3v devices first, then put the voltage level shifter, and then connect the 5v devices.

  8. #8
    Member
    Join Date
    Sep 2020
    Location
    Massachusetts
    Posts
    26
    Thanks, so I2C is a wildcard. Just using 12C for Teensy-to-Teensy communications would not require any extra resistors or buffers, would it?

  9. #9
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,828
    Quote Originally Posted by blakeAlbion View Post
    Thanks, so I2C is a wildcard. Just using 12C for Teensy-to-Teensy communications would not require any extra resistors or buffers, would it?
    The trouble is there are so many devices that implement I2C.

    Unfortunately for Teensy 3.x/LC <-> Teensy 3.x/LC I2C, you WILL need to add pull-up resistors. You need at least one set of pull-up resistors on the I2C bus. This assumes the Teensies are just connected directly with no other devices.

    I think I recall Paul having a recent comment that you might not need the pull-up resistors for 4.x I2C (but high speed I2C might not work). I do recall at one point I2C slave mode did not work for Teensy 4.x, but I've never used I2C slave mode, so I can't say if it currently works or not.

Posting Permissions

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