Serial I2C LCD 1602 Module (HCARDU0023)

LCD, TFT, OLED, LED modules
Post Reply
admin
Site Admin
Posts: 865
Joined: Sun Aug 05, 2012 4:02 pm

Serial I2C LCD 1602 Module (HCARDU0023)

Post by admin » Fri Sep 07, 2012 7:15 pm

Image

Image

This 16 character by 2 line display has a very clear and high contrast white text upon a blue background/backlight. It also includes a serial I2C/IIC adaptor board pre-soldered to the back of the LCD. This means it can be controlled with just 2 I2C serial data pins (SDA & SCL) and so requires far less digital IO pins when controlled from a microcontroller. In total the module only requires 4 wires including 5V power and GND. Contrast adjustment is also provided by the daughter board via a potentiometer. If you plan to use this with an Arduino board you can download a compatible library and example sketch (see below).

posting.php?mode=edit&f=75&p=1132

Product Code HCARDU0023
Features 64mm x 14mm LCD display, supports IIC / I2C
Application DIY Arduino based project. Allows remote panel mounting. Requires only 2 IO pins.

  • PINOUT
    1.....GND
    2.....VCC (+5V)
    3.....SDA
    4.....SCL

Notes:

These modules are currently supplied with a default I2C address of either 0x27 or 0x3F. To determine which version you have check the black I2C adaptor board on the underside of the module. If there a 3 sets of pads labelled A0, A1, & A2 then the default address will be 0x3F. If there are no pads the default address will be 0x27.

The module has a contrast adjustment pot on the underside of the display. This may require adjusting for the screen to display text correctly.

If pressure is applied to the I2C daughter board it is possible for it to bend and come contact with the LCD module. Please ensure when the LCD is installed in your application that no external object is applying pressure to the back of the module.


Image



Arduino example
  1. * FILE:    ARD_LCD_HCARDU0023_I2C_Hello_World_Example.pde
  2.    DATE:    07/09/12
  3.    VERSION: 0.1
  4.  
  5. This is a simple example of how to use the Hobby Components I2C LCD module
  6. (HCARDU0023). To use this module you will require the appropriate library
  7. which can be downloaded from the modules section of our support forum at the
  8. following location:
  9.  
  10. http://forum.hobbycomponents.com
  11.  
  12. This code also demonstrates the correct pin assignment for the LCD. When you
  13. run this program you should see a greeting message appear on the display.
  14.  
  15.  
  16. DEVICE PINOUT (SPI Interface):
  17.  
  18. PIN 1: GND
  19. PIN 2: +5V
  20. PIN 3: SDA - Connect to Arduino analogue PIN 4
  21. PIN 4: SCL - Connect to Arduino analogue PIN 5
  22.  
  23.  
  24. You may copy, alter and reuse this code in any way you like but please leave
  25. reference to hobbycomponents.com in your comments if you redistribute this code. */
  26.  
  27.  
  28. /* Include the SPI/IIC Library */
  29. #include <Wire.h>
  30. #include <LiquidCrystal_I2C.h>
  31.  
  32.  
  33. /* Initialise the LiquidCrystal library. Note that the displays will have a default I2C
  34.     address of either 0x27 or 0x3F. Uncomment one of the lines below depending on
  35.     the address of your module. */
  36.  
  37. //LiquidCrystal_I2C lcd(0x27,16,2);
  38. //LiquidCrystal_I2C lcd(0x3F,16,2);
  39.  
  40.  
  41. void setup()
  42. {
  43.   /* Initialise the LCD */
  44.   lcd.begin();
  45. }
  46.  
  47. /* Main program loop */
  48. void loop()
  49. {
  50.   /* Make sure the backlight is turned on */
  51.   lcd.backlight();
  52.  
  53.   /* Output the test message to the LCD */
  54.   lcd.setCursor(0,0);
  55.   lcd.print("HOBBY COMPONENTS");
  56.   lcd.setCursor(0,1);
  57.   lcd.print("**HELLO WORLD**");
  58.  
  59.  
  60.   /* Do nothing */
  61.   while(1);
  62. }


Image

Libraries:
HCARDU0023_LiquidCrystal_I2C.zip
EDIT (16/01/16): New version now works with Arduino IDE version 1.6.7
EDIT (01/12/12): New version 2.1 available. This should work with all versions of SDK

Datasheets:
1602_Datasheet.pdf
PCF8574_Datasheet.pdf


FAQ:

My screen just displays one row of squares along the top line. Is it faulty?

Image

It is normal for the module when first powered up to display a row of solid squares as show above. If your display is still showing this after running your sketch then it is a sign that it is not initialising the module correctly for some reason. Normally this is caused by one of 3 things, a bad or incorrect connection to the I2C interface on the module, an incorrect I2C address (for our modules the default address is either 0x27 or 0x37), or by far the most common cause is using an incompatible version of the LiquidCrystal_I2C library. For our screens you should always use the version available for download in this post. If you have downloaded a version from elsewhere please also remember to delete it from your Arduino library folder(s) otherwise the Arduino IDE may still continue to use it.


The text of my screen is very faint

Under normal conditions text should be very clear and visible. If text on your module is hard to read this is normally caused by one of two things...

Firstly, this module requires the backlight to be on for text to be readable. If your backlight isn't on then check that there is a jumper fitted across the two pin header labelled 'LED' on the back of the module. This purpose of this jumper is to connect the 5V power to the backlight. Our modules are shipped with this jumper fitted but it is possible for it to shake loose during shipping. If the jumper is missing check the anti-static bag your module was shipped in.

If the backlight is on then see the next FAQ


My screen isn't displaying anything / my screen just displays two rows of solid squares

This could be caused by the screens contrast being set too low (no text) or too high (solid squares). On the back of the module there is a blue potentiometer, this adjusts the displays contrast. Normally our modules are shipped with it set to the ideal contrast position but in some cases it may need adjusting.



Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.
You do not have the required permissions to view the files attached to this post.

ScOut3R
Posts: 1
Joined: Thu Nov 29, 2012 9:50 am

Re: YwRobot Serial LCD 1602 Module (HCARDU0027)

Post by ScOut3R » Thu Nov 29, 2012 10:58 am

Dear admin,

i've tried to use the V2 library but i cannot unzip the file with the following error:
Inconsistent extfs archive
I've tried to download it multiple times but the error is the same.

Could you please check that the linked attachment is valid?

admin
Site Admin
Posts: 865
Joined: Sun Aug 05, 2012 4:02 pm

Re: YwRobot Serial LCD 1602 Module (HCARDU0027)

Post by admin » Fri Nov 30, 2012 9:12 am

Hi,

We recently moved this forum to a new host and it looks like the move has somehow corrupted some of the attachments. We will fix this later today.

Andrew

silentb0y

Re: YwRobot Serial LCD 1602 Module (HCARDU0027)

Post by silentb0y » Fri Mar 08, 2013 2:51 pm

Hi
I recently got this lcd screen but without the serial thing on it in the master starter kit but for some reason i can't write to it but everything else is working
I have watched numerous tutorials online to make sure i wired it correctly but i can't find the error.
Any ideas on what could be wrong.
All help is highly appreciated.

admin
Site Admin
Posts: 865
Joined: Sun Aug 05, 2012 4:02 pm

Re: YwRobot Serial LCD 1602 Module (HCARDU0027)

Post by admin » Sat Mar 09, 2013 12:42 pm

Hi,

We don't currently have any example code for this LCD that you can try out but we will set one up today and see if we can help you figure out what the problem is.

Andrew

EDIT:

I have now posted a new topic for this module which can be found here:

http://forum.hobbycomponents.com/viewto ... 2603#p2603

Please use the example sketch to test your LCD. The comments contain a pinout table which you can check your connections against. If you still are unable to get it working after this please post another message in that forum.


Andrew

wajrak
Posts: 2
Joined: Wed Jun 26, 2013 4:57 pm

Re: YwRobot Serial I2C LCD 1602 Module (HCARDU0023)

Post by wajrak » Wed Jun 26, 2013 7:07 pm

Hi,

This is my first post here so please, bare with me ;) As I do like service provided by Hobby Components store I will post some stuff to make other people life easy.
I just had my I2C Lcd delivered today and... well... It was a little bit of a struggle to get it up and runing, sample code did not work for me. So here's few tips that might save you few hours:

Lest analyse sample code provided by admin
PIN 3: SDA - Connect to Arduino analogue PIN 4
PIN 4: SCL - Connect to Arduino analogue PIN 5
This applies sometimes and for some Arduino boards, keep in mind that if you are using Arduino Mega, you will use pins 20 and 21 marked with same symbols as those on lcd (sda/scl). If you already did some research you will find out that some people says it should be Analog pins 4 and 5 or digital 20 and 21, a lot confusing stuff if you are new to electronics.
LiquidCrystal_I2C lcd(0x27,16,2);

This might be different for you, your display don't have to have 0x27 code, if you got the wrong code normal LCD will print gibberish instead of normal characters. You can scan your LCD for its code by simply runing I2C scanner which can be found here: http://playground.arduino.cc/Main/I2cScanner

Always make sure you are running the latest version of library, in our case you can check it up here:
https://bitbucket.org/fmalpartida/new-l ... /downloads
Also keep in mind this library overwrites the one that comes with Arduino which might cause some mess, its a good thing to get the original one renamed.

Now, some sample code that worked for me:
/*
** Example Arduino sketch for SainSmart I2C LCD Screen 16x2
** based on https://bitbucket.org/celem/sainsmart-i ... cdtest.ino
** by
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)

** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:
** https://bitbucket.org/fmalpartida/new-liquidcrystal 

** Modified – Ian Brennan ianbren at hotmail.com 23-10-2012 to support Tutorial posted to Arduino.cc

** Written for and tested with Arduino 1.0
**
** NOTE: Tested on Arduino Uno whose I2C pins are A4==SDA, A5==SCL

*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27 // <<----- Add your address here. Find it from I2C Scanner
#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

int n = 1;

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
  lcd.begin (16,2); // <<----- My LCD was 16x2

  
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home

  lcd.print("Wajrak");
}

void loop()
{
  // Backlight on/off every 3 seconds
  lcd.setCursor (0,1); // go to start of 2nd line
  lcd.print(n++,DEC);
  //lcd.setBacklight(LOW); // Backlight off
  delay(3000);
  lcd.setBacklight(HIGH); // Backlight on
  //delay(3000);
}
If you have any questions, please don't hesitate to ask, I covered a wide range of problems today (Installing/uninstalling libraries and missing some functions and parameters like POSITIVE) ;)
Oh and i do apologise for not posting code in

Code: Select all

 but the one from arduino looks way more clear. 
Cheers

Jock
Posts: 3
Joined: Tue Sep 24, 2013 6:52 am

Re: YwRobot Serial I2C LCD 1602 Module (HCARDU0023)

Post by Jock » Thu Sep 26, 2013 8:04 am

I just got this display and it's excellent - does "almost" everything I wanted, however there is one thing I can't quite figure out - what's the character set?

I'm trying to access the copyright symbol, "©" and trying to use char(169) but I get garbage. Bear in mind I'm very new to all this!

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: YwRobot Serial I2C LCD 1602 Module (HCARDU0023)

Post by andrew » Thu Sep 26, 2013 11:34 am

These type of 1602 LCD's tend to have a very limited character set and I don't believe that there is a copyright symbol. This will also be partly due to the fact that it is very difficult to display a legible copyright symbol with only 5 pixels width. As a solution you may want to look at our 2004 LCD sketch (http://forum.hobbycomponents.com/viewto ... =39&t=1368) which shows how to create your own custom characters. We have not tested this with the 1602 LCD but we would expect it to work.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Jock
Posts: 3
Joined: Tue Sep 24, 2013 6:52 am

Re: YwRobot Serial I2C LCD 1602 Module (HCARDU0023)

Post by Jock » Fri Sep 27, 2013 7:04 am

Thanks Andrew - I'll give it a try and let you know how it goes.

raschemmel@yahoo.com
Posts: 7
Joined: Wed Nov 06, 2013 6:38 am

Re: YwRobot Serial I2C LCD 1602 Module (HCARDU0023)

Post by raschemmel@yahoo.com » Fri Nov 15, 2013 3:41 pm

I just got the same display, exactly like the photo posted and couldn't find any code that worked on the net. I'm new at programming so
there's no way I could do it. I saw the photo of the one with the Hobby Components URL on it an thought I hit the jackpot
so I:
1. connected the pullups to A4 & A5
2. and downloaded the zip file and copied the Keywords.txt and LiquidCrystal_I2C.h to the My Documents\Arduino\Libraries\LiquidCrystal_I2C folder 3. opened the IDE and selected Sketch\add file and selected the "ARD_LCD_HCARDU0023_I2C_Hello_World_Example"

Result: numerous compile errors.
I'm so new at this I'm probably doing something wrong.

Any thoughts?

Post Reply

Return to “Display”