2004 20x4 I2C Serial LCD Module (HCMODU0010)

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

2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by admin » Fri May 24, 2013 12:05 pm

Image
Image
Above image showing LCD connected to an Arduino Uno with a V4.0 sensor shield and 4 way anti-reverse cable (additional items not supplied with LCD)

I2C 2004 Serial 20 x 4 LCD Module:


This the larger version of our 16x4 LCD display. Its 24 character by 4 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 from our support (see below).



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




FAQ:

What is the I2C address of this display?

Depending on the version of the daughter board fitted to your display it will have an I2C address of either 0x27 or 0x3F



I have run the demo sketch but I'm not seeing any characters displayed on the screen, is it faulty?

The most likeliest cause is of this issue is the displays contrast being set too low. To adjust the contrast there is an adjustment pot on the underside of the display. This may require adjusting for the screen to display text correctly.



My display is just showing solid black squares, is my display faulty?

This may be one of three things:

1) The displays contrast is too high, see previous question.

2) The display is uninitialised due to the sketch or library being incorrect, or a wrong I2C address. If using with an Arduino please ensue that you use the library and demo sketch available in the first post. If you have downloaded a library from elsewhere you will also need to remove it from your library folder.

3) It is possible for the I2C daughter board to bend and come in contact with the LCD module if enough pressure is applied to it. Please check that the daughter board is not pressing against the back of the display.



The backlight is not working, is it faulty?

On the daughter board which is fitted to the rear of the display there is a 2 pin header which should also have a jumper fitted to it. Removing the jumper will break the supply to the displays backlight. Sometimes this jumper can work loose in shipping. If the jumper is missing please check the packaging. If it's not in the packaging it can sometimes get lodged underneath the daughter board.



When I run the demo sketch I a 'lcd' was not declared in this scope error.

Locate the following 2 lines in the sketch and uncomment one of them depending on the I2C address of your display. To uncomment a line just remove the two forward slashes (//) at the beginning of the line.
  1. //LiquidCrystal_I2C lcd(0x27,20,4);
  2. //LiquidCrystal_I2C lcd(0x3F,20,4);




Pinout:
1.....GND
2.....VCC (+5V)
3.....SDA
4.....SCL



Example sketch:
  1. /* FILE:    ARD_LCD_HCMODU0010_I2C_Hello_World_Example
  2.    DATE:    24/05/13
  3.    VERSION: 0.1
  4.  
  5. This is a simple example of how to use the Hobby Components 20 x 4 line
  6. I2C LCD module (HCMODU0010). To use this module you will require the
  7. appropriate LiquidCrystal_I2C library, which can be downloaded from our support
  8. forum:
  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. This software may not be used directly for the purpose of selling products that
  27. directly compete with Hobby Components Ltd's own range of products.
  28.  
  29. THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS LTD MAKES NO WARRANTIES, WHETHER
  30. EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  31. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
  32. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
  33. INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
  34. REASON WHATSOEVER.
  35. */
  36.  
  37.  
  38. /* Include the SPI/IIC Library */
  39. #include <Wire.h>
  40. #include <LiquidCrystal_I2C.h>
  41.  
  42. /* Create some custom graphic characters to make a simple border */
  43. uint8_t TopLeftCorner[]  = {0x00,0x00,0x0f,0x08,0x0b,0x0a,0x0a,0x0a};
  44. uint8_t TopRightCorner[]  = {0x00,0x00,0x1e,0x02,0x1a,0x0a,0x0a,0x0a};
  45. uint8_t BottomLeftCorner[]  = {0x0a,0x0a,0x0b,0x08,0x0f,0x00,0x00,0x00};
  46. uint8_t BottomRightCorner[]  = {0x0a,0x0a,0x1a,0x02,0x1e,0x00,0x00,0x00};
  47. uint8_t VerticalBar[]  = {0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a};
  48.  
  49. /* Initialise the LiquidCrystal library. Note that the displays will have a default I2C
  50.     address of either 0x27 or 0x3F. Uncomment one of the lines below depending on
  51.     the address of your module. */
  52.  
  53. //LiquidCrystal_I2C lcd(0x27,20,4);
  54. //LiquidCrystal_I2C lcd(0x3F,20,4);
  55.  
  56. void setup()
  57. {
  58.   /* Initialise the LCD */
  59.   lcd.begin();
  60.   /* Transfer the custom characters into the LCD's memory */
  61.   lcd.createChar(0, TopLeftCorner);
  62.   lcd.createChar(1, TopRightCorner);
  63.   lcd.createChar(2, BottomLeftCorner);
  64.   lcd.createChar(3, BottomRightCorner);
  65.   lcd.createChar(4, VerticalBar);
  66. }
  67.  
  68. /* Main program loop */
  69. void loop()
  70. {
  71.   /* Make sure the backlight is turned on */
  72.   lcd.backlight();
  73.  
  74.   /* Use the custom graphic characters to draw a border */
  75.   lcd.setCursor(0, 0);
  76.   lcd.write(0); //Write the top left graphic
  77.   lcd.print("==================");
  78.   lcd.write(1); //Write the top right graphic
  79.   lcd.setCursor(0, 1);
  80.   lcd.write(4); //Write the vertical bar graphic
  81.   lcd.setCursor(0, 2);
  82.   lcd.write(4); //Write the vertical bar graphic
  83.   lcd.setCursor(19, 1);
  84.   lcd.write(4); //Write the vertical bar graphic
  85.   lcd.setCursor(19, 2);
  86.   lcd.write(4); //Write the vertical bar graphic
  87.   lcd.setCursor(0, 3);
  88.   lcd.write(2); //Write the bottom left graphic
  89.   lcd.print("==================");
  90.   lcd.write(3); //Write the bottom right graphic
  91.  
  92.   /* Display some text inside the border */
  93.   while (1)
  94.   {
  95.     lcd.setCursor(2,1);
  96.     lcd.print("HOBBY COMPONENTS");
  97.     lcd.setCursor(2,2);
  98.     lcd.print("**HELLO WORLD**");
  99.     delay(500);
  100.     lcd.setCursor(2,1);
  101.     lcd.print("                ");
  102.     lcd.setCursor(2,2);
  103.     lcd.print("               ");
  104.     delay(500);
  105.   }
  106. }


Arduino Library:
HCARDU0023_LiquidCrystal_I2C.zip
EDIT (16/01/16): New version now works with Arduino IDE version 1.6.7


Datasheet:
HD44780.pdf
You do not have the required permissions to view the files attached to this post.

greennd

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by greennd » Sat Jul 06, 2013 4:35 pm

Trying out my 20 x 4 LCD module.

a) it lights up -
row 1 is 20 white rectangles on blue with each rectangle being 5 x 8 (?) white dots
row 2 - nothing
row 3 (as row 1)
row 4 nothing.

If I verify the example code from the forum I get the following error messages

errors message start>>>>>

hobbycomponents_LCD:51: error: invalid conversion from 'int' to 't_backlighPol'
hobbycomponents_LCD:51: error: initializing argument 3 of 'LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t, uint8_t, t_backlighPol)'
/Users/nigel/Documents/Arduino/libraries/LiquidCrystal/LiquidCrystal_I2C.h: In function 'void setup()':
/Users/nigel/Documents/Arduino/libraries/LiquidCrystal/LiquidCrystal_I2C.h:154: error: 'int LiquidCrystal_I2C::init()' is private
hobbycomponents_LCD:57: error: within this context
hobbycomponents_LCD.ino: In function 'void loop()':
hobbycomponents_LCD:74: error: call of overloaded 'write(int)' is ambiguous
/Users/nigel/Documents/Arduino/libraries/LiquidCrystal/LCD.h:479: note: candidates are: virtual size_t LCD::write(uint8_t)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:49: note: size_t Print::write(const char*)

error message end.

I've downloaded the liquid crystal libraries as per forum and placed in documents\ardunio\libraries
the in documents\arduino\ is a folder called hobbyocomponents_lcd which holds hobbycomponents_LCD.ino

HELP! (please)

many thanks

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

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by andrew » Sat Jul 06, 2013 6:00 pm

Hi,

It is perfectly normal for the display to do this when its uninitialised. I have just checked the library and example sketch, and its compiling fine on my set-up so it's likely there is something odd with your Arduino environment that's causing it not to compile. The place that you have put the library appears to be correct. I suggest checking that you haven't left any other versions of the libraries in there. If you can't see anything, temporarily move everything in your /Documents/Arduino/libraries/ folder to a safe place and just put the library downloaded from this forum in there. Also check that there's nothing in the C:\arduino\libraries folder that you may have left in there.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

greennd

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by greennd » Sat Jul 06, 2013 7:33 pm

many thanks for the prompt (beyond speedy) reply. I've cleared out libraries, etc etc and re installed. Only items in (mac os x) documents/arduino/libraries are readme.txt and LiquidCrystal_i2c.

In liquidcrystal_i2c are examples folder and info folder and keywords.txt and liquidCrystal_i2c.cpp and liquidCrystal_i2c.h. (its v2.0)

I've re-copied the example code on the forum and saved it - this now verifies with no errors

However ...

the LCD panel is, as before connected to sensor shield via the 4 wire latched cables and to the GND. VCC etc on the LCD daughter board, but it does not light up at all. I've tried adjusting the potentiometer on the daughter board but makes no difference. In essence it appears 'dead'

The Arduino is getting power via USB and the LED on the sensor shield is lit up (one in front) of the i2c interface.

As always help much appreciated.

greennd

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by greennd » Sat Jul 06, 2013 8:06 pm

update to my last post:

I've got a pot wired to analogue 4, and when I've just loaded simple sketch to read values on A0 - A4 (each has a pot) I noticed that when I opened A4 to a value of 1023 the LCD lit up - so that's that problem solved. Obviously analog A4 is being used by the LCD for power.

back to testing the sketches, will let you know of outcome.

thanks

greennd

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by greennd » Sat Jul 06, 2013 8:31 pm

further update:

If I remove the connection from my potentiometer to A4 I loose all power to the LCD
I've powered off the arduino and turned it back on, have run test sketches to make sure arduino is ok (eg digital read on 12) and that works of.

So to recap,

I can now verify the code (sample "hobby components - hello world", but no power to the LCD unless I connect my potentiometer to A4 and leave it open.
Sketches verify and download but still not showing on the LCD.

I assume the power issue is to do with " PIN 3 SDA Connect to Arduino analogue PIN 4.
How do I get to reset this so its not dependent for power on a potentiometer (or others imagine).


sorry for the trouble.

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

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by andrew » Sun Jul 07, 2013 7:58 am

Analogue pin 4 does not power the back light, as with the LCD, the backlight is powered from the VCC and GND pins and the state of the backlight (on or off) is controlled in software. Although when first powered up the LCD is in an un-initialised state, and no communication to the LCD, the backlight usually defaults to being on.

When running the sketch, the two Analogue pins on your board are actually reconfigured as serial digital (SPI) IO pins and are used to communicate serially with the device. Their voltage level should not affect the state of the backlight directly. I also recommend disconnecting your external pot as whist these pins are in the SPI mode you risk damaging your LCD and board. Don’t apply any external voltages to these pins whilst they are in this mode.

I am having trouble locating you on our system; did you buy this hardware from us? If so could you either PM or email us your order number if you purchased it from our website, or your eBay user name if you got them via eBay. This will help us determine exactly what hardware you have so that we can replicate your setup.
Can I also confirm that the example sketch posted above not only compiles correctly, but downloads to your Arduino without any errors?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Guest

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by Guest » Sun Jul 07, 2013 9:56 am

Hi:

re purchase: Hobby Components o/n [removed by admin] (for the LCD) and [removed by admin] for the sensor shield.

marks on unit are LCM1602 IIC, Hoya, Funduino, LD1, 111330, and on the main board are J204A with QC sticker implies QC pass on 2013 06.

example code verifies with no problems, and is received by ardunio uno ok.

changes to code eg Delay in teh while loop do have an effect, ie by altering the delay in the unit lighting up. (on/off/on off etc)
LDA1 Led is on


Having toned down the brightness (doh !) i get

on row 1 - eight blank cells and 2x '0' and on row 3 16 x '0' and 4 blank cells
If I change

lcd.setCursor(0, 0);
lcd.write(0); //Write the top left graphic
lcd.print("==================");

to read
lcd.setCursor(0, 0);
lcd.write(0); //Write the top left graphic
lcd.print("==");

I get on row 1 eighteen blank cells and 2 x "0' in columns 19 and 20
(in row column numbers above I've started at 1 to be the top row, and not used 0,0)

if I replace say the second "=" and the second to last "=" in the lcd.print("=================="); statement the 'X''s are replaced with a blank cell

can send photos of results if that would help

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

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by andrew » Sun Jul 07, 2013 2:52 pm

Thanks for the information. I’ve pulled an LCD out of stock with the same batch date and the example sketch works fine. The symptoms you have now are typical of a wrong library version, but I have confirmed that the library version in this forum is fine with the current screens. So long as this is the version of library you are using there should be no problems with the software and shouldn’t require any modification to work.

Is it possible for you to connect the display directly to the Uno, bypassing the sensor shield? The connections would be as follows:
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

greennd
Posts: 1
Joined: Sun Jul 07, 2013 9:57 am

Re: 2004 20x4 I2C Serial LCD Module (HCMODU0010)

Post by greennd » Wed Jul 10, 2013 6:19 pm

:) :D

Hi Andrew --- I've got an LCD with "Hobby components ** Hello World ***" flashing on and off. - via the sensor shield.

Here's what I did:
cleaned out any docs in documents\arduino\libraries so had empty library.
installed libraries from https://bitbucket.org/fmalpartida/new-l ... /wiki/Home and got no joy.

Started again, and looked for the library on this forum, and then realised, if I logged on to the forum I could see the files attached to the forum so downloaded the HCARDU0023_LiquidCrystal_I2C_V2_1 and then imported that library into a clean and empty library. Deleted old sketches for the LCD (probably not a step that was required), copied and pasted sketch from this forum and 'started again'.

So the key was use HCARDU0023_LiquidCrystal_I2C_V2_1 and not the ones from malpartida/new-liquidcrystal ....

thanks for all the help and support.

Post Reply

Return to “Display”