Go Down

Topic: Multiple I2C LCD's (Read 4382 times) previous topic - next topic

hemmi25

I am unable to get multiple I2C displays working.  I am using the LCDi2cNHD.h library.  When I try 2 LCD's, everything displays on the second LCD.  Here is a simple code.  I know the I2C addresses are correct, because if I test each one individually they work correctly.  Any help?  Thanks

Code: [Select]
#define VERSION "1.1"
#include <Wire.h>
#include <inttypes.h>

#include <LCDi2cNHD.h>                   
LCDi2cNHD lcd = LCDi2cNHD(2,16,0x50>>1,0);
LCDi2cNHD lcd2 = LCDi2cNHD(2,16,0x4C>>1,0);

uint8_t rows = 2;
uint8_t cols = 16;



void setup() {

  lcd.init();     
  lcd2.init();   

}


void loop()
{

     lcd.print("Hello World!");     
     lcd2.print("Hello World2!");     
 
}


bHogan

Just as a quick experiment, you might try this I2C LED lib:
http://www.xs4all.nl/~hmario/arduino/LiquidCrystal_I2C/

Since it conforms to the same API, it should be easy to try.
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

hemmi25


Just as a quick experiment, you might try this I2C LED lib:
http://www.xs4all.nl/~hmario/arduino/LiquidCrystal_I2C/

Since it conforms to the same API, it should be easy to try.


I tried that library, however it does not seem to work at all with my Newhaven Displays LCD.  Has anyone ever got multiple i2c lcd's working?

hemmi25

I was able to get 2 I2C lcd's working.  I gave up on the libraries, and just used wire.h.  This code works without issue.




Code: [Select]
#include <Wire.h>

int lcd_addr = 0x50;
int lcd_addr2 = 0x4C;

void setup(){

  delay(1000);

  Wire.begin();
   
  lcd_addr = lcd_addr >> 1;
  lcd_addr2 = lcd_addr2 >> 1;

 
  Wire.beginTransmission(lcd_addr);
  Wire.send(0xFE);
  Wire.send(0x51);
  Wire.endTransmission();

  Wire.beginTransmission(lcd_addr2);
  Wire.send(0xFE);
  Wire.send(0x51);
  Wire.endTransmission();
 

  delay(2000);

 
  Wire.beginTransmission(lcd_addr);
  Wire.send("This is LCD1");
  Wire.endTransmission();
   
  Wire.beginTransmission(lcd_addr2);
  Wire.send("This is LCD2");
  Wire.endTransmission();

}



void loop(){
   
}

asselinpaul

Have you tried to follow this tutorial: http://www.ladyada.net/products/i2cspilcdbackpack/
I got two i2C lcd working with the code.
Are you using Standard HD44780 LCDs or another type?
Paul

hemmi25


Have you tried to follow this tutorial: http://www.ladyada.net/products/i2cspilcdbackpack/
I got two i2C lcd working with the code.
Are you using Standard HD44780 LCDs or another type?
Paul



No I have not tried that library.  I have everything working now with the wire library.  I may try this library on a future project.  Thanks

robtillaart

Quote
I have everything working now with the wire library.

Please post your working code for later reference,

tia rob
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

penjoseph

#7
Jul 29, 2015, 12:46 pm Last Edit: Jul 30, 2015, 07:00 am by penjoseph
Have successfully connected
2x i2c piggyback - IIC Module
coupled with
2x 16x2LCDs - JHD162A
to Arduino Leonardo.

Both i2c piggybacks had the address 0x27.
http://playground.arduino.cc/Main/I2cScanner

Changed one piggyback's address by shorting A0 pcb pad (among A0, A1, A2) to get 0x26 . Did not use pull-up resistors since internally these piggybacks have 4.7k resistance. Connected the Vcc, Gnd, SDA & SCL in parallel to both i2c LCDs. Length of the cable is 1m from Arduino.

Used F. Malpartida's LCD library -
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads



penjoseph

#8
Jul 29, 2015, 12:51 pm Last Edit: Jul 30, 2015, 06:55 am by penjoseph
Test code:

Code: [Select]
#include <Wire.h>  // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd1(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the 1st LCD I2C address
LiquidCrystal_I2C lcd2(0x26, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the 2nd LCD I2C address

void setup()   
{
  Serial.begin(9600);

  lcd1.begin(16,2);   // initialize the 1st lcd for 16 chars 2 lines, turn on backlight
  lcd2.begin(16,2);   // initialize the 2nd lcd for 16 chars 2 lines, turn on backlight

//-------- Write characters on the 1st & 2nd displays ------------------
 // NOTE: Cursor Position: (CHAR, LINE) start at 0 
  lcd1.setCursor(0,0);
  lcd1.print("Hello, world!");
  lcd2.setCursor(0,0);
  lcd2.print("Hello, world!");
  delay(2000);
  lcd1.setCursor(0,1);
  lcd1.print("I'm 1st 16x2LCD");
  lcd2.setCursor(0,1); 
  lcd2.print("I'm 2nd 16x2LCD");
}


void loop()   
{
 }
 
 

floresta

According to Reply #2 he is using a NewHaven display.  The NewHaven controllers are not identical to the HD44780U and do not always work with libraries written for the Hitachi controller and its clones.

Don




penjoseph

#10
Jul 30, 2015, 06:31 am Last Edit: Jul 30, 2015, 07:10 am by penjoseph
Oh ok ! Well I thought my experiment might be of use to someone trying to connect multiple i2c piggybacked JHD162A 16x2LCDs.

JHD162A uses Samsung  KS0066 controller which is Hitachi HD44780 compliant.

Go Up