Go Down

Topic: 16X2 LCD using I2C serial communication not working.... (Read 492 times) previous topic - next topic

vishal_3

I am using serial lcd module on 16x2 LCD for communicating through I2C communication but it is not working an error comes while compiling "Error compiling for arduino/genuino UNO"

here is the code I am using(p.s. hardware connections are alright)


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


LiquidCrystal_I2C lcd(0x27,16,2);

void setup() {
  // put your setup code here, to run once:
  lcd.begin(16,2);
  lcd.backlight();

}

void loop() {
  // put your main code here, to run repeatedly:
  lcd.setCursor(0,0);
  lcd.print("hello world!");

}

floresta

First of all you you will want to delete the setCursor instruction and move the print instruction to setup().  This will leave loop() blank between the brackets.

Then you will want to read some of the hundreds of forum posts concerning I2C LCDs.  In virtually any of the recent ones you will find recommendations to use the hd44780 library instead of whatever I2C library you are presently trying to use.

Don


vishal_3

First of all you you will want to delete the setCursor instruction and move the print instruction to setup().  This will leave loop() blank between the brackets.

Then you will want to read some of the hundreds of forum posts concerning I2C LCDs.  In virtually any of the recent ones you will find recommendations to use the hd44780 library instead of whatever I2C library you are presently trying to use.

Don


LCD is compatible with hd44780 driver but I am using a backpack for serial communication with Arduino that's why I am using  I2C library which is not working maybe because it is not compatible with the current version of Arduino I am using i.e 1.6.9. ?????

floresta

Once again:

"Then you will want to read some of the hundreds of forum posts concerning I2C LCDs.  In virtually any of the recent ones you will find recommendations to use the hd44780 library instead of whatever I2C library you are presently trying to use."

Pay attention to the second sentence.

Don

floresta

The basic problem is that each of the many "I2C" libraries out there is geared to a specific adapter (backpack).  You have to find the specific library that matches your adapter and then you have to specify the correct address and various other parameters.  Get any of these wrong and your device will not work.

The hd44780 library works with virtually any adapter and figures out the other parameters for you.

Don

vishal_3

The basic problem is that each of the many "I2C" libraries out there is geared to a specific adapter (backpack).  You have to find the specific library that matches your adapter and then you have to specify the correct address and various other parameters.  Get any of these wrong and your device will not work.

The hd44780 library works with virtually any adapter and figures out the other parameters for you.

Don
Okay, I am getting confused what hd44780 library you are talking about is that one that one that comes pre-installed with ide that LiquidCrystal library? but that library can't be used for serial communication or I2C communication.Tell me something about that and yes you are right for specific adapter there are multiple i2c libraries.One more thing in my first post read that error thing "Error compiling for arduino/genuino UNO" can you tell what this is about?

floresta

Quote
Okay, I am getting confused what hd44780 library you are talking about ...
It's the one with the name 'hd44780'.  I can't be any more specific than that, just use the library manager to find and install it.

The compiling error could be due to the fact that you are using one I2C library and providing constructor information in a format specified for another library.

You really should take a look at some of the previous forum posts on this topic.

Don

vishal_3

okay, Thanx I try to find some posts regarding this... :)

bperrybap

Here is the link to the hd44780 library package github page.
It has information about the library, how to install it, and the i/o classes.
See the main page for a summary, and the wiki for some additional information.
https://github.com/duinoWitchery/hd44780

The i/o class for i2c backpacks that use i/o expander chips like the PCF8574 is hd44780_I2Cexp

--- bill

vishal_3

Here is the link to the hd44780 library package github page.
It has information about the library, how to install it, and the i/o classes.
See the main page for a summary, and the wiki for some additional information.
https://github.com/duinoWitchery/hd44780

The i/o class for i2c backpacks that use i/o expander chips like the PCF8574 is hd44780_I2Cexp

--- bill
Thanks, got this library in library manager itself it is a good library working for all types of displays serial, general...:)
 

bperrybap

#10
Sep 28, 2017, 05:31 pm Last Edit: Sep 28, 2017, 07:07 pm by bperrybap
Just kind of an FYI, while I2C uses a serial protocol, when the term "serial" is used for a device interface, people usually mean asynchronous serial which uses 2 wires, one for transmitting and one for receiving and are configured using baud rates and start and stop bits.
This type of interface is for communication between 2 devices.

IC2 also uses two wires, one for clock and a bidirectional data line. It is actually a bus.
A single master device can communicate (transmit and receive) with many (100+) slave devices.

---bill

Go Up