[SOLVED] MJKDZ brand I2C Controller working with 1602 LCD

Recently I bought a cheap I2C controller and 16x2 display off of eBay, and since there seemed to be a lot of documentation online, I thought it would be an easy thing to hook up to my Uno. Instead, it took me weeks to figure it out. (Don't laugh, I'm new at this.) I noticed that there wasn't that much documentation about my specific I2C board, so I decided to help change that by posting the results of my work.

The display: a QC1602A 16x2 character display.
http://www.ebay.com/itm/170817946781?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649
This seems to be pretty popular, and is fairly well documented.

The I2C Adapter: MJKDZ brand I2C LCD1602
http://www.ebay.com/itm/140906400906?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649
Cheap, but not nearly as popular as it's similar cousins, so there isn't nearly as much information on this device. There is a website printed on the board. Don't bother, it's all in Chinese, and using Google Translate, I can confirm that what is there is totally useless. The name of the chip has been filed off for some unknown reason as well.

First of all, getting the I2C board properly connected wasn't hard. This 5v device connects to the Arduino just like any other I2C device. 4 pins: Ground, 5V power, A4/SDA and A5/SCL. Because things weren't working (for other reasons, but I had no idea the time), I tried to hook it up straight, and then I did it again using 4.7K Ohm pull-up resistors to improve signal quality. Both methods worked, so don't be so concerned with the pull-up resistors unless you are experiencing problems.

Next, testing to see if the I2C board itself works and responds to I2C commands is important. I recommend an I2C scanner, because this will tell you if the MJKDZ board is acknowledging I2C commands. I got mine at this website: Gammon Forum : Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino about half way down the page. There's a lot of great I2C information there. When I ran my I2C scanner, it told me that the device has an I2C address of 0x20. This is interesting, because the eBay seller claimed the address was 0x27, which is totally not true. So it happens to be very important to run an I2C scanner on your device to confirm the address, because no sketch will work correctly if you don't have the right address.

Excited that my I2C board was working, I hooked up my 16x2 display, and loaded up an I2C "hello world" sketch and.... nothing. I tried all the sketches I could find on Google, and still, nothing. Sometimes, the back light would turn on and off, and sometimes, the screen would have strange flashing and gibberish. At first I thought it was a connection issue, so I tested the continuity of every wire, but everything was fine. I also tried turning the tiny screw on the blue potentiometer, as that adjusts the contrast on the display. Still, nothing. I spent many days searching the internet and trying everything I could get my hands on, but nothing seemed to work until yesterday. Here is what is needed for sketches to work:

Step 1: Remove all LCD libraries from your Arduino IDE. Check both the user specific ones, as well as in the Arduino install folder. Zip them up and save them somewhere else if you think you might need them again, otherwise, delete.

Step 2: Install the new and improved LCD library by F Malpartida from here: https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home This person has done some awesome work for the Arduino community.

Step 3: The sketch I got working I found at the bottom of this website: http://arduino-info.wikispaces.com/LCD-Blue-I2C Again, a very useful website!
I had to modify the sketch a little bit to make it work with a 16x2 display with an address of 0x20. Below is the modified code:

/* YourDuino.com Example Software Sketch
 16 character 2 line I2C Display
 NEW TYPE Marked "Arduino-IIC-LCD GY-LCD-V1"
 terry@yourduino.com */
/*-----( Import needed libraries )-----*/ 
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574A 
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  7
#define En_pin  4
#define Rw_pin  5
#define Rs_pin  6
#define D4_pin  0
#define D5_pin  1
#define D6_pin  2
#define D7_pin  3

#define  LED_OFF  0
#define  LED_ON  1

/*-----( Declare objects )-----*/  
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  lcd.begin (16,2);  // initialize the lcd 
// Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,NEGATIVE);
  lcd.setBacklight(LED_ON);
}// END Setup

void loop()   /*----( LOOP: RUNS OVER AND OVER AGAIN )----*/
{

// Reset the display  
  lcd.clear();
  delay(1000);
  lcd.home();
  
// Print our characters on the LCD
  lcd.backlight();  //Backlight ON if under program control
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(0,1); //Start at character 0 on line 1
  lcd.print("16 by 2 Display");
  delay(8000);
} // END Loop

I pressed upload and it worked the first time! After all that hard work, it now seemed so easy. I think the secret is that the pins on the I2C device aren't standard, so may need to be remapped, which is what I think happens in the code above. This would also explain why those pins on the MJKDZ board have no labels. For me as a new Arduino user, it was quite a hassle, but it all worked in the end, and I learned lots, so I can say that this was $5.23 well spent. I hope this post helps any other new owners of the MJKDZ I2C LCD1602 boards save some time figuring things out the hard way.

Glad you got it going, well done.

And thanks for you kind comments (which I also think are applicable to the contributors of the library).

Hi,

Thanks for the great write up. I used the above sample code and library to test my 16x2 display, but all I'm getting is a row of blinking blocks (picture attached). My displays and i2c backpacks are same as yours (ebay purchased). any advice ?

Thanks in advance

That is because the LCD is not being initialised correctly. Probably due to wrong pin mapping - I2C backpack pins to LCD pins. That is something that has to be configured in the library with those defs.

Thank you very much- I am in the same situation and the I2C Scanner returns 0 devices found - My I2C is busted?

I2C - mjkdz
SDA- 4
SDL -5

5v-V
GND-G

I2C scanner. Scanning ...
Done.
Found 0 device(s).

You are not detecting any I2C devices so: it is not correctly wired or it is broken.

fm:
You are not detecting any I2C devices so: it is not correctly wired or it is broken.

To add in some more details - Using a UNO , Wiring seems to be ok - and 5v input also seems fine.
Was a new I2C, thanks anyways will have some more check- or any other way way to confirm the I2C is busted?

Try putting a 2k2 pullup on SCL and SDA.

Tried the 2k2 pull up and no response.... =( any other way i can confirm the I2C is busted?

Hi,

Thanks for the great thread.

I have the same problem with MJKDZ I2C Controller working with display: CY1602-A 16x2 character display1602 (http://www.eachbuyer.com/16x2-character-lcd-display-module-with-blue-blacklight-700.html).

I have tried: putting a 1,8 k 2 pullup on SCL and SDA, address 0x20, improved LCD library by F Malpartida, SDA- 4/ SDL -5/ 5v-V/ GND-G and several sketches, but all I'm getting is a flicker backlight (picture attached). Does anyone have any advice?

Thanks in advance

Bad pin mapping. Take a look at the library wiki, it has a mapping and configuration section that will help you use you LCD. If it blinks, your I2C address is good.

pulsarus,
If you are out of ideas, and are unable to determine the pin wiring of your i2c chip to the hd44780 interface,
attached is a sketch I wrote that will try to figure it all out by guessing.
It will locate the i2c chip's address then try several of the most common configurations.
I will say that while I've not seen any damage occur using incorrect configurations, it is possible
that using an incorrect configuration could damage the hardware.

It uses the serial port along with the serial monitor in the IDE to
control the "guessing".
See the comments in the sketch for how set things up and how to use it.

Give it a try and let me know if it detects the proper constructor for you.


fm,
I'm working on some updates for the library that are not quite finished yet.
This sketch is one of the updates.

--- bill

i2cLCDguesser.zip (4.3 KB)

Hi Bill, it sounds great. I was trying to find some time to refactor the I2C class hierarchy, support for the Adafruit backpack and improvements both in the LCD support and wiki but the job that pays the bill is keeping me too busy lately.

Hi,
thanks for the reply.

when I use the sketch, I get the following error message:
"t_backlightPol' does not name a type.
sketch_may15b:164: error: 't_backlightPol' does not name a type
sketch_may15b:178: error: too many initializers for 'i2cdata'
sketch_may15b:178: error: too many initializers for 'i2cdata'
sketch_may15b:178: error: too many initializers for 'i2cdata'

Remove the stock library of the arduino IDE and replace it by this one.

I have made it, but I have the same error.

Have you replaced the new library by the old one and installed it in the library directory of the Arduino IDE?
You will need to remove completely the old library and any other LCD library you may have, such as the LiquidCrystal_I2C.
If you are using the IDE version1.5, you will also need to move the documentation in the library somewhere else.

Yes, I have replaced the new library by the old one and I installed it in the library directory of the Arduino IDE. I'm using only this one: LiquidCrystal_V1.2.1 and Arduino IDE version 1.0.

Are you trying to compile any of the examples that come with the library?

Uhhh. Sorry guys.
fm's library that I'm working with has been slightly modified.
I corrected the misspelled "t_backlighPol" in my version of the library and didn't test
my test sketch on a stock release. :blush:

pulsarus,
I updated the sketch in the earlier post to allow it work no matter how
the backlight type is spelled.
Just re-download the test sketch from my previous post and it should compile now.

Sorry about that.

--- bill