SainSmart 20 x 4 LCD wanting to use I2C from Arduino Uno

worsethenu:
Hey everybody! Happy New Year! My new sainsmart 20x4 LCD showed up today and all I got was the LCD? No documentation and no cable for connecting it to the arduino. Could someone tell me what type of connector I need so I can make a cable? Thanks!

You will get a more reliable answer if you post a better description or a link to the actual device.

Don

Haha, sorry. good call.

worsethenu:
Hey everybody! Happy New Year! My new sainsmart 20x4 LCD showed up today and all I got was the LCD? No documentation and no cable for connecting it to the arduino. Could someone tell me what type of connector I need so I can make a cable? Thanks!

Happy new year.

I use LiquidCrystal_I2C.h. You could make up a cable using standard 0.1" 4 pin females, but I just tore off four conductors from a 40-way ribbon with females already included.

The 40-way worked great. Thanks for the tip!

Hey guys, finally got the sainsmart lcd2004 sheild wired up (5v,gnd, SDA(pin 20), SCL (pin 21)) into the mega2560. When I run the hello world code (which apprears in the examples section of the IDE) below (directly from the new LiquidCrystal v1.2.1) all it does is flash very dimly. If I unplug the SDA and SCL it lights up and is clearly getting power. Any ideas?

0x3F came from the I2C scanner program I ran. There are no errors compiling.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define BACKLIGHT_PIN 21

LiquidCrystal_I2C lcd(0x3F); // Set the LCD I2C address

//LiquidCrystal_I2C lcd(0x3F, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address

// Creat a set of new characters
const uint8_t charBitmap[][8] = {
{ 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
{ 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
{ 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
{ 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
{ 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
{ 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
{ 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
{ 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }

};

void setup()
{
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

// Switch on the backlight
pinMode ( BACKLIGHT_PIN, OUTPUT );
digitalWrite ( BACKLIGHT_PIN, HIGH );

lcd.begin(20,4); // initialize the lcd

for ( int i = 0; i < charBitmapSize; i++ )
{
lcd.createChar ( i, (uint8_t *)charBitmap );

  • }*

  • lcd.home (); // go home*

  • lcd.print("Hello, ARDUINO "); *

  • lcd.setCursor ( 0, 1 ); // go to the next line*

  • lcd.print (" FORUM - fm ");*

  • delay ( 100000 );*
    }
    void loop()
    {

  • lcd.home ();*

  • // Do a little animation by writing to the same location*

  • for ( int i = 0; i < 4; i++ )*

  • {*

  • for ( int j = 0; j < 20; j++ )*

  • {*

  • lcd.print (char(random(7)));*

  • }*

  • lcd.setCursor ( 0, 1 );*

  • }*

  • delay (2000);*
    }

We have the same library and the display should probably work the same. The display is disconcerting on start-up and you might think it is faulty. The light comes on and then goes goes off, then comes on fully operational.

Here is the start of a clock. Note that I don't define the backlight pin.

//Arduino 1.0+ Only
//Arduino 1.0+ Only

#include <LiquidCrystal_I2C.h>
#include "Wire.h"
#define DS1307_ADDRESS 0x68

LiquidCrystal_I2C lcd(0x27,20,4);  

void setup(){
  Wire.begin();
  Serial.begin(9600);
  lcd.init();  
    delay(1000);
 lcd.clear();
      lcd.backlight();  //Backlight ON if under program control
      lcd.setCursor(0,0); 
  // Print a message to the LCD.
 lcd.print("Today it is");
 
}

void loop(){
  printDate();
  delay(1000);

}

Thanks for the reply! I gave it shot but it did not work.

I changed this:
#include "Wire.h"
to
#include <Wire.h>

The line below however now throws the error: invalid conversion from 'int' to 't_backlighPol'
LiquidCrystal_I2C lcd(0x27,20,4);

I've been trying a bunch of different things and i can get the LCD to fully light and blink the cursor if the only thing in the loop is lcd.setCursor(X,Y); if I put anything else in the loop the LCD either does not illuminate or dims by 50+%.

I didn't realise I had "wire.h" and not <wire.h>. I can only conclude it makes no difference!

(EDIT)

I've changed it and it works the same.

Also Dafes looks the same as mine, except he is using 16x4 instead of 20x4. The backlight bit is the same.

Hi hopes this helps:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd(0x27,16,4);  // set the LCD address to 0x27 for a 16 chars and 4 line display



void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
lcd.print("Test");
}

void loop() {

 
}


void Test()
{
  lcd.print("Test");
}

I'have tried this with the followign I2C Libary´s
http://www.exp-tech.de/service/library/2004%20LiquidCrystal_I2C.rar
http://www.exp-tech.de/service/library/LiquidCrystal_I2C2004V1.rar

Hey Guys.
Firstly: Thanks for all the great info about the SainSmart LCD2004.
I got it working following Andrews advice.

But now I have a problem:

I'm trying to use the Wireless SD Shield:

w/ the Serial LCD described in this topic.

I can get the LCD to work, but not the SD.
fm says:
"Just create two objects (variables) initialising them correctly and they will work. "

can anyone please explain that to me?
The only wires coming off the LCD2004 are:

GND
VCC
SDA
SCL

and I currently have them wired:

GND - arduino GND
VCC - arduino 5V
SDA - arduino A4
SCL - arduino A5

also the Wireless SD shield uses pin 4 as the SDCS (chip-select).

Any help is appreciated.
Thanks!

Hi guys,

I searched a lot to get it working..
I bought this LCD
(this one: http://www.amazon.it/gp/product/B007XRHBKA)

I'm running with:

  • Arduino UNO R3
  • IDE v 1.0.6
  1. I downloaded this library:

http://www.exp-tech.de/service/library/LiquidCrystal_I2C2004V1.rar
thanks dafes!

  1. I deleted from:
    _my installation path\arduino-1.0.6\libraries_
    the folder
    LiquidCrystal

  2. Extract in this location the LiquidCrystal_I2C2004V1 folder from the .rar file

  3. open the IDE

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F, 20, 4);  

void setup() {
  Serial.begin(9600);
  lcd.init();  
  lcd.clear();
}

void loop() {
  lcd.backlight();
  lcd.print("Here I am!");
}

It works!!

Hope it helps

I tried also with this library from fmalpartida, v1.2.1:
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

The code is a little bit different:

/*
** Example Arduino sketch for SainSmart I2C LCD2004 adapter for HD44780 LCD screens
** Readily found on eBay or http://www.sainsmart.com/ 
** The LCD2004 module appears to be identical to one marketed by YwRobot
**
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
**
** sain_lcd_2.ino
** Simplified and modified by Andrew Scott for Arudino 1.0.1, Arudino Uno R3.
** NOTE: I2C pins are A4 SDA, A5 SCL
** Don't forget to use the new LiquidCrystal Library.
*/



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

#define I2C_ADDR    0x3F  // Define I2C Address where the SainSmart LCD is
#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

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

void setup()
{
  lcd.begin (20,4);
  
  // Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);

  // Position cursor and write some text
  lcd.home ();                   // go to the first line, first character
  lcd.print("SainSmart I2C tester");  
  lcd.setCursor ( 0, 1 );        // go to the 2nd line
  lcd.print("It's Working!");
  lcd.setCursor ( 0, 2 );        // go to the third line
  lcd.print("Sainsmarts docs suck");
  lcd.setCursor ( 0, 3 );        // go to the fourth line
  lcd.print("Nice LCD Though. ");
}

void loop()
{

}

It works!!

Can't you just let this two year old thread rest in peace?

This is it's third resurrection after the original problem was solved in September of 2012.

Don

  1. I downloaded this library:
    http://www.exp-tech.de/service/library/LiquidCrystal_I2C2004V1.rar
    thanks dafes!

Thanks for this!! I've searched and searched and no one had links to a good, decent working Saint 2004 I2C lib.

This worked like a charm for me!

Never had such a headache with a display, I can not get it to work.
I found the address using the serial scan, 0x3F as also mentioned in this topic.
I'm using the 1.2.1 new LiquidCrystal lib.

The background light I can control, but can't get any characters on the display.

This code works for the backlight:

/*
** Example Arduino sketch for SainSmart I2C LCD2004 adapter for HD44780 LCD screens
** Readily found on eBay or http://www.sainsmart.com/ 
** The LCD2004 module appears to be identical to one marketed by YwRobot
**
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
**
** sain_lcd_2.ino
** Simplified and modified by Andrew Scott for Arudino 1.0.1, Arudino Uno R3.
** NOTE: I2C pins are A4 SDA, A5 SCL
** Don't forget to use the new LiquidCrystal Library.
*/



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

#define I2C_ADDR    0x3F  // Define I2C Address where the SainSmart LCD is
#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

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

void setup()
{
  lcd.begin (20,4);
  
  // Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);

  // Position cursor and write some text
  lcd.home ();                   // go to the first line, first character
  lcd.print("SainSmart I2C tester");  
  lcd.setCursor ( 0, 1 );        // go to the 2nd line
  lcd.print("It's Working!");
  lcd.setCursor ( 0, 2 );        // go to the third line
  lcd.print("Sainsmarts docs suck");
  lcd.setCursor ( 0, 3 );        // go to the fourth line
  lcd.print("Nice LCD Though. ");
}

void loop()
{

}

Does anybody got a clue what might be wrong? I have 2 of these displays and they both do the same.

hi. how can I dl #include <LCD.h> in my library thanks you

YOU GUYS

Thank you so much! I was up until four in the morning last night tinkering with this LCD! I ordered mine from aliexpress.com, and it came with the I2C serial interface adapter module (link here) and I could not get it to work.

This is the first result that comes up when you Google the error message "invalid conversion from 'int' to 't_backlighPol' [-fpermissive]", so I don't feel so bad posting on an old thread. For anyone else stumbling across this forum looking for answers:

You need to find the correct address to your LCD. Many are 0x27, but mine was 0x3F. There are instructions listed here previous that can explain how to do that.

You need the correct code! There's bad code out there. This one worked for me:

/*
** Example Arduino sketch for SainSmart I2C LCD2004 adapter for HD44780 LCD screens
** Readily found on eBay or http://www.sainsmart.com/ 
** The LCD2004 module appears to be identical to one marketed by YwRobot
**
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
**
** sain_lcd_2.ino
** Simplified and modified by Andrew Scott for Arudino 1.0.1, Arudino Uno R3.
** NOTE: I2C pins are A4 SDA, A5 SCL
** Don't forget to use the new LiquidCrystal Library.
*/



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

#define I2C_ADDR    0x3F  // Define I2C Address where the SainSmart LCD is
#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

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);
 
 // Switch on the backlight
 lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
 lcd.setBacklight(HIGH);

 // Position cursor and write some text
 lcd.home ();                   // go to the first line, first character
 lcd.print("Thank you!");  
 lcd.setCursor ( 0, 1 );        // go to the 2nd line
 lcd.print("It's Working!");

}

void loop()
{

}

I'll point out that this code worked for me despite the fact that my I was using the serial interface adapter module, with grnd to grnd, vcc to 5v, SDA to A4 and SCL to A5 (as listed here.

I did have to change the original working code in this forum for my LCD as it's only 16 x 2 and not 20 x 4, but that was simple; I just deleted the lines that set the cursor for anything lower than 2 and changed "20x4" in the code to "16x2".

If you're totally lost, feel free to message me! I'm brand new to this but I'll help if I can.

Thanks again, everyone!

Good Morning Everyone
I downloaded the new files from here used arscott instructions from Sep 2, 2012 at 4:40 pm and it worked perfectly. @

In order to find the correct address i used @Aaron_dyer instructions from Sep 05, 2012, 07:28 pm

Soooo my question is

Now that i want to update my other sketch to display on LCD I had to copy over basically every file in the folder which I got from here here

How do I minimize the amount of folders needed?

So what am i saying. I had one project going on and I could get the LCD to work. I then created the new example and library from here to get it working but I cant just copy and paste a few files cause they are all connected to eachother. If I miss one i get an error.