Go Down

Topic: Multiple I2C LCD's (Read 6073 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: Nov 04, 2015, 01:46 pm by penjoseph
Have successfully connected
2x i2c piggyback - IIC Module
coupled with
2x 16x2LCDs - JHD162A
to Arduino Leonardo.

Installed this i2c Scanner sketch, connected the i2c LCD individually to Arduino Leonardo & noted each i2c address through Arduino IDE Serial Monitor - http://playground.arduino.cc/Main/I2cScanner
Both i2c piggybacks had the same address 0x27.

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


Slow Coach

penjoseph

#8
Jul 29, 2015, 12:51 pm Last Edit: Nov 04, 2015, 09:46 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); 
// Specify the 1st I2C chip address used for 1st LCD & its connection pins
// (addr, en,rw,rs,d4,d5,d6,d7,bl,blpol);

LiquidCrystal_I2C lcd2(0x26, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 
// Specify the 2nd I2C chip address used for 2nd LCD & its connection pins
// (addr, en,rw,rs,d4,d5,d6,d7,bl,blpol);


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()   
{
 }
 
 



.....edited on 4th Nov '15 as per floresta's following remarks of incomplete code description.
Slow Coach

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.
Slow Coach

KrisKasprzak

I have 2 20x4 with SDC, SLC, VCC, GND pins. Is there a way to set the address on teh LCD? I've not seen a hardware address setting.

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


If all are hooked to the Arduino in parallel, and if the displays are the same how will the code know which is which?
Thanks,

Kris

floresta

#12
Oct 27, 2015, 12:44 am Last Edit: Oct 27, 2015, 12:50 am by floresta
If you identify and/or post a link to the datasheet for your I2C adapter we may be able to determine if it is possible to set the address.  

Once you have have succeeded in setting two different addresses then you procede to the next step.

The code determines where to send the information by interpreting the two lines of code that you have posted.  The comment is incorrect which may be why you are confused.  The comment is also incomplete because the line of code (called a constructor) is also identifying the library, the pin connections, and the backlight polarity.

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


Don

KrisKasprzak

heres the lcd i have. it has no enable pin only sda and an slc pin.

heck most of these companies dont even post sample files or data sheets--ive looked but nothing. perhaps ill post this question on the sainsmart forom.


http://www.amazon.com/gp/product/B003B22UR0?psc=1&redirect=true&ref_=oh_aui_detailpage_o00_s00
Thanks,

Kris

bperrybap

I have 2 20x4 with SDC, SLC, VCC, GND pins. Is there a way to set the address on teh LCD? I've not seen a hardware address setting.

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


If all are hooked to the Arduino in parallel, and if the displays are the same how will the code know which is which?
The constructors are used to tell the library the hardware i2c address; it does not and cannot set the actual hardware i2c address used by the chip.
If the display modules use the same hardware i2c address, then there is no way to individually address them.
From looking at the picture of the display module that you have with the backpack soldered, it appears that there is no easy way to set the i2c address.
I have seen some i2c LCD backpacks like that before. Some have the solder jumpers on the back of the board and some don't have a way to set it all since the address pins are directly wired to GND or VCC, I consider both a poor design.

In order to change the address you will likely have to do some combinations of cuts, jumps, and soldering on the PCB or perhaps even directly to the chip.
What you need to do will depend on how the chip address pins are wired up on the PCB.
You will have to figure this out and then alter how at least one of the address pins is wired up to change the chip address
(The address pins are pins 1,2, and 3)
You will need to figure out if the address pins are directly wired to gnd or VCC or whether they go through a resistor to VCC or GND on the back of the board.

If resistors are used all you have to do is solder a wire to one of the address pins and solder the other end to VCC or GND depending on if you need the address line to be high or low.

If resistors are not used (which is likely) then it is a bit more difficult. You will have to isolate one of the pins (either cut the trace going to it, or lift the leg off the PCB) and then solder a wire to it and again solder the other end to VCC or GND depending on if you need the address line to be high or low.



--- bill

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy