Arduino and I2c LCD

Discussion in 'Software and Programming' started by chucketn, Feb 13, 2015.

Help Support HMEM by donating:

  1. Feb 13, 2015 #1

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I purchased an I2c serial interface and another 1602 LCD for my Arduino experiments. Unfortunately the I2c module came with no data sheet. I found a picture of the interface mounted on a 1602 LCD but the I/o pins of the LCD are not marked. I can make an educated guess as to which pin on the interface goes to pin 1 on the LCD, but I would like confirmation before I solder them together.
    I have attached pix of the interface and the interface mounted on a 1602 LCD. Is pin 1 of the interface toward the jumper and pin 16 toward the serial pins?

    Chuck

    I2C adapter.jpg

    450px-1602I2C_4.jpg
     
  2. Feb 13, 2015 #2

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I think I have verified the I/o pins as #1 being toward the serial connections. I found that the resistance between the first and 3d pin from that end, varies with the contrast adjust(big blue pot).

    Chuck
     
  3. Feb 13, 2015 #3

    sssfox

    sssfox

    sssfox

    Well-Known Member

    Joined:
    Mar 4, 2012
    Messages:
    183
    Likes Received:
    26
  4. Feb 13, 2015 #4

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    Thanks Steve. I bought two of the I2c converters, and so far cannot get either working.

    Chuck
     
  5. Feb 13, 2015 #5

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    That's correct.... pin 1 is the one on serial end, with square box on the silkscreen

    Then the serial pins connect to 5V GND and to A4 (SDA) and A5 (SCL). From there you still need to define all the digital pins in your sketch. Inlucde a I2C lcd library in your sketch too
     
  6. Feb 14, 2015 #6

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    So far I've tried 3 or 4 I2c scanners, and 3 I2c LCD sketches, and no LCD output. The Scanners put out gibberish on the Serial Monitor.

    Chuck
     
  7. Feb 14, 2015 #7

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    Try sainsmart's I2C lcd library and their example sketch:

    http://arduino.arigato.cz/I2C_LCD_BackPack_for_1602_and_2004/LCD_16x2_BackPack_v003.ino

    http://www.sainsmart.com/zen/documents/20-011-916/IIC1602.zip

    Like I said, the sketch still has to define the I2C address and the LCD pins like so:

    #define I2C_ADDR 0x27 // I2C address of PCF8574A
    #define BACKLIGHT_PIN 3
    #define En_pin 2
    #define Rw_pin 1
    #define Rs_pin 0
    #define D4_pin 4
    #define D5_pin 5
    #define D6_pin 6
    #define D7_pin 7
     
  8. Feb 14, 2015 #8

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    My I2c Serial setup still doesn't work with the 'Hello World' example sketch.
    I have tried ox20 and 0x27 addresses, no go. LCD flashes and lights the top row, contrast works, but no readable characters. Digits on the LCD are just white squares.
    If I add the declare statements above, where do I put them in the sketch?
    Pics of setup.
    Chuck

    DSCF0249.jpg

    DSCF0250.jpg
     
  9. Feb 14, 2015 #9

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I added the declare statements above, no difference. I will try deleting and re-installing the LCD I2c library.

    Chuck
     
  10. Feb 14, 2015 #10

    TorontoBuilder

    TorontoBuilder

    TorontoBuilder

    John

    Joined:
    Jan 4, 2013
    Messages:
    357
    Likes Received:
    82
    Im not sure what to suggest next... until my I2C backpack arrives I wont be able to try this myself.
     
  11. Feb 14, 2015 #11

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    Very frustrating, to say the least! I need a break...

    Chuck
     
  12. Feb 14, 2015 #12

    canadianhorsepower

    canadianhorsepower

    canadianhorsepower

    Well-Known Member HMEM Supporter

    Joined:
    Oct 22, 2011
    Messages:
    1,671
    Likes Received:
    320
    Last edited: Feb 14, 2015
  13. Feb 15, 2015 #13

    sssfox

    sssfox

    sssfox

    Well-Known Member

    Joined:
    Mar 4, 2012
    Messages:
    183
    Likes Received:
    26
    Chuck,

    A break isn't a bad thing, sometimes it's a necessity.

    I was out all day and missed your posts.

    Did you specify the size of the LCD in your sketch?

    I don't have a 16x2 with an I2C interface on it, but I have a 20x4.
    I'll hook it up in the morning and see if I have the same problem as you.
    I would've been able to do it tonight, but I had a computer issue a couple of months ago and had to reinstall everything. I started with stuff I use and add other programs as I need them. I haven't done any Arduino programming since it broke, so the development environment isn't on there right now.

    Also, could you post your sketch?
    Just copy the text and paste it into a post.

    Steve Fox
     
  14. Feb 15, 2015 #14

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    I watched the above tutorial. I will study it some more. Lots of info there. Finally found out what the jumper was for.
    I also downloaded the Sainsmart LCD library and replaced the libraries I had installed. At first, the results were the same. Then I noticed the address for the LCD in the sketch was 0x38. I had seen somewhere that the LCD address was 0x27, so I tried that. The display flashed as it hadn't before, but still did not display 'Hello World'. I changed the address to 0x21 and display stopped flashing.
    This leads me to believe the address of the LCD is none of the above. Does anyone have a working I2C Scanner that I can use to determine the address of the I2C module? None that I have tried have worked, unless I'm not doing it right.

    Chuck
     
  15. Feb 15, 2015 #15

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    Here's a screen shot of the serial monitor output from the !2c scan. What does it tell me?

    chuck

    I2C_scan.png
     
  16. Feb 15, 2015 #16

    canadianhorsepower

    canadianhorsepower

    canadianhorsepower

    Well-Known Member HMEM Supporter

    Joined:
    Oct 22, 2011
    Messages:
    1,671
    Likes Received:
    320
    that to me is bad language "baud rate not set wright"
     
  17. Feb 15, 2015 #17

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    Thank you Luc! I set the baud rate to 9600 in the scanner sketch and it worked! Found my I2c at address 0x39. I'll set that in the 'Hello World' Sketch and see what happens.

    Chuck
     
    canadianhorsepower likes this.
  18. Feb 15, 2015 #18

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    Had to modify the scanner sketch to output addresses in Hex. Found both of my I2c Modules are addressed 0x27. Supposed to be able to change them but haven't found out how yet.
    Still having no luck getting the I2cExample to work, though I now see the random char trying to display. All I get is a square with all pixels enabled randomly appearing. Trying to write a sketch that displays readable characters on the lcd.

    Chuck
     
  19. Feb 15, 2015 #19

    canadianhorsepower

    canadianhorsepower

    canadianhorsepower

    Well-Known Member HMEM Supporter

    Joined:
    Oct 22, 2011
    Messages:
    1,671
    Likes Received:
    320
    Chuck
    check the tronix link that I posted. go to 3;14 and it explains how to change the address

    are you including (wire.h) in your program ???


    just curious what exactly are you trying to do!!!!

    good luck
     
    Last edited: Feb 15, 2015
  20. Feb 15, 2015 #20

    chucketn

    chucketn

    chucketn

    Senior Citizen

    Joined:
    Dec 17, 2009
    Messages:
    1,300
    Likes Received:
    154
    Occupation:
    Fully retired
    Location:
    Near Jonesborough, TN
    The end goal is add a keypad to Chuck F's RT sketch. Right now, I'm trying to learn how to use the I2c serial module with a 1602 LCD. I bought 2 of the modules, and a LCD. Got the modules, but the extra LCD hasn't come in yet. The LCD I'm using came in the Adafruit accessory kit. It has only one set of output pins, and I had already soldered header pins to it so I am plugging the LCD and the I2c module into a breadboard. I cannot get either I2C module to display anything but blocks with all pixels lit using the Sainsmart library and the I2c LCD example. I finally got a serial address scanner to work to verify the modules addresses, but no character display.
    I'll go back to that tutorial you linked and play with changing the address.

    I do have a 20x4 LCD with 2 sets of output pins. One set has a header soldered in. Can I solder one of the serial modules to the other without causing problems? I can't mount that LCD on the breadboard I have with the header on it, and mount the serial module too.

    Chuck

    Edit: Yes, the example sketch has the Wire.h in it.
     
    Last edited: Feb 15, 2015

Share This Page