pcf8574 i2c lcd module made in china
SMALL ISSUE: I"ve used a npn transistor for backlight, the library is written for a pnp transistor. This means that the command lcd.setBaclight(LOW) turns the backlight on and lcd.setBacklight(HIGH) switchs the backlight off.
First, thanks for posting this – it enabled me to quickly bring up a 2 LCD project I’m working on. However, I found I needed the communication to the LCDs to go much faster. This project operates at a 10Hz refresh rate, and I was spending 40ms of that just writing to the LCDs. After a bit of datasheet study, I found that one can write a stream to the PCF8574. That is: Start Addr Data Data … Stop will result in the data output being updated on each data byte without having to resend the address for each nibble. The result on a one-byte write to the LCD is 5 I2C character times instead of 8 for a single character write. A stream of many chars can be sent. For a 5-character write to the LCD, the result is 21 I2C byte times versus 40, nearly doubling the throughput to the LCD.
2 addresses. Communication with one address will mimic the PCF8574 but allow much higher clock rate to get around the 100khz limitation of the PCF8574, while communication with the other address will do a byte-write to the LCD in 2 I2C character times, and write N bytes in N+1 I2C character times. If this backpack is operated at 400khz instead of 100 khz, the result will be an 8x speed improvement over the original implementation.
I have to say that after some time working properly the LCD started to display strange characters. Before that the right characters were blinking while the LED backlight was always ON.
Ithink I have to order new I2C modules since I have another 16x02 LCD working good with the traditional 4 data wires connection. This is the module I"m gonna buy: I2C module
but for getting product into the USA, the backpacks are available for $1 USD shipped, and LCD+Backpack already soldered starts at $2 USD shipped from many low cost vendors. The low cost vendors are from china and may take a while to get.
In this one we’ll use it to connect a Keypad to an Arduino and again save some pins, and also have a quick overview on what and how the i2c protocol works.
I2C stands for “Inter-Integrated Circuit“, it allows to connect multiple modules or “slave”, and requires only 2 wires no matter the amount of connected modules, on an Arduino you can have up to 128 slave devices.
Those address are in hex values (ex. ox20), and most module give you the possibility to change the address by either soldering some pads or using dip switches like the I2C Expander module we used.
I2C uses two pins or signals, one is SCL and the other is SDA. Most Arduinos have only one I2C bus, one exception would be the Arduino Due which has two seperate I2C bus.
The main difference between those two modules, is their pinouts, the LCD Backpack pinout is made to fit on an LCD with additional outputs for the backlight.
Since both the I2C port Expander and the I2C LCD Backpack are pretty much the same, couldn’t I just use the LCD Backpack to connect the Bourns encoder?
But if your project can make due with only 7 I/O pins then you can use the LCD Backpack as an I2C Expander since those other pins are properly connected.
So instead of using 7 Pins on the Arduino, were’s using the I2C protocol and using only 2 Pins to read the Keypad as well as display the results on the LCD screen.
This LCD I2C interface adapter can be added to a 16 x 2 or 20 x 4 character LCD display with a standard parallel interface to make it I2C compatible. It can also be repurposed for other I2C to parallel tasks.
By default, the industry standard HD44780 compatible 16 x 2 and 20 x 4 character LCD displays require 4 or 8 parallel data lines to drive them along with a couple of pins for chip select and chip enable. This consumes a lot of pins on the MCU. This adapter board reduces the data pin requirements to only 2 pins which can also be shared with other I2C devices.
The backlight can be controlled ON/OFF, but the intensity is not directly controllable though the I2C interface. Some modules have a jumper on the board that supplies Vcc power to the backlight. That jumper can be removed and a voltage applied to the header pin nearest the ‘LED’ markings on the board to provide power to the backlight separately. Note: Some modules do not have this header / jumper installed, instead the solder pads have a trace connecting them. It is possible to cut the trace between the pads and add header pins if desired.
The PCF8574 is a generic I2C to 8-bit I/O device and the module can be repurposed for other uses besides driving LCD modules. Max I2C clock frequency is 100kHz which makes it most suited to lower speed applications.
VCC = Connect to 5V. This can come from the MCU or be a separate power supply. Some LCD may operate at 3.3V and this module can also operate at 3.3V
The pin-out of the header which is soldered to the LCD follows for reference, but in general you don’t need to worry about it as the I2C interface board and software library takes care of this interface unless you are adapting the module for another use. These pins are listed starting at the I2C header end of the board.
To use the adapter with an LCD, you will need to insert the 16-pin header into the 16 solder pad holes on the back of the LCD and solder them in place on the front side. The pins are long and can be cut off before or after soldering.
Soldering the module on is easy to do, but if you already have other pins in those holes, they will need to be removed first before this board can be added. The picture below shows the adapter mounted to the back of an LCD2004 4 x 20 character LCD.
This is the same module used on our I2C compatible LCD displays we sell and is well supported using the LiquidCrystal_I2C.h and similar libraries. For using the board with software, you can check out one of the LCDs below that already have this module installed.
The PCF8574 itself is a general purpose 8-bit I/O expander for the I2C bus. The reverse engineered schematics are provided here mainly for those who may want to adapt the module to other applications. The I2C bus on this module is limited to a 100kHz clock frequency.
I recently acquired, via eBay, a 40X4 HD44780 based LCD screen that has a daughter-board on the back that provides an I2C interface, labled “LCD2004“. This permits interfacing with only two wires (SDA/SCL) plus ground and 5-volts. This particular board is sold by a Chinese company, SainSmart.com. SainSmart provides its own version of the Arduino LiquidCrystal library and some example code. Unfortunately, both the library are for the old version of the Arduino IDE and will not compile with the current Arduino 1.0 version.
To get the I2C display to work I did some reverse engineering. The LCD2004 board utilized the PCF8574 I/O expander. This nifty little chip provides eight bits of parallel I/O addressable by a I2C bus address – 0x00 to 0x27. SainSmart tied all address leads to Vcc, so the LCD2004 board’s I2C address is permanently fixed at hex 27. This is rather limiting since no additional LCD2004s can be added to the bus. Anyway, you simply address the board and write an eight bit value which is then presented on the output pins of the PCF8574, which, in this case, are connected to the HD44780 based LCD screen.
After some reverse engineering to determine which PCF8574 pins were connected to which LCD pins, I was able to use F Malpartida’s NewLiquidCrystal library to write a functional test program. The unit works quite nicely and my code and schematic can be obtained in my BitBucket Repository.
The SainSmart LCD2004 board is identical to one offered by YwRobot and SainSmart’s provided example code is even marked with Ywrobot. Possibly SainSmart merely markets the Ywrobot board under their name, or possibly they cloned it. Furthermore, both Ywrobot may have obtained its design from DFrobot. DFRobot may have been the original board designer given their more professional approach of decent documentation, but given China’s disregard for intellectual property rights, who knows for sure? Also, DFRobot has and active forum with timely responses by their engineers, and a wiki, which is another plus for their professionalism. DFRobot’s board and SainSmart’s significantly differ, physically, so if SainSmart copied DFRobot, it was only from their schematic and not the board design.
A more versatile I2C LCD board would be to use the design offered by F Malpartida. Her I2CLCDextraIO board allows you to define a unique address for each LCD, permitting a multi-display configuration with all controlled over one I2C bus. Her designs are freely available in her BitBucket repository if you’d like to make your own board. You can also buy her bare board or assembled unit from ElectroFUN.
On the Uno if the internal AVR pullups were not enabled then the LCD device would not be seen by the i2c scanner. Given you are seeing the slave device at the proper address, 0x3e, the pullups are likely strong enough to run the examples.
However, the internal pullups enabled by the Wire library on an UNO board, when using short wires (like you have) are good enough to run all the hd44780 library hd44780_I2Clcd i/o class examples like HelloWorld.
The hd44780_I2Cexp i/o class is for LCD devices that use a PCF8574 based backpack. Your device uses a AIP31068L chipset so it needs code that knows how to talk to that chipset.
I have seen a few Arduino lcd libraries that handle and processing and line wrapping but most of them do not handle vertical scrolling. Most just wrap back to the 0,0 position when they get beyond the bottom line.
Having spent more than a decade writing terminal emulation s/w (back in the 80’s) and having implemented code to do end of line processing and wrapping in arduino lcd libraries, here are some of my notes/observations:
In this one we’ll use it to connect a Keypad to an Arduino and again save some pins, and also have a quick overview on what and how the i2c protocol works.
I2C stands for “Inter-Integrated Circuit“, it allows to connect multiple modules or “slave”, and requires only 2 wires no matter the amount of connected modules, on an Arduino you can have up to 128 slave devices.
Those address are in hex values (ex. ox20), and most module give you the possibility to change the address by either soldering some pads or using dip switches like the I2C Expander module we used.
I2C uses two pins or signals, one is SCL and the other is SDA. Most Arduinos have only one I2C bus, one exception would be the Arduino Due which has two seperate I2C bus.
The main difference between those two modules, is their pinouts, the LCD Backpack pinout is made to fit on an LCD with additional outputs for the backlight.
Since both the I2C port Expander and the I2C LCD Backpack are pretty much the same, couldn’t I just use the LCD Backpack to connect the Bourns encoder?
But if your project can make due with only 7 I/O pins then you can use the LCD Backpack as an I2C Expander since those other pins are properly connected.
So instead of using 7 Pins on the Arduino, were’s using the I2C protocol and using only 2 Pins to read the Keypad as well as display the results on the LCD screen.
Overhere we will show you what is the I2C LCD 1602 Display and how it works, you can follow the next lesson to get how to use the I2C LCD 1602 Display with the micro bit.
The integration of an LCD display greatly facilitates the interactivity of the project you are developing, allowing the user to directly read some output parameters. These values can be either a simple text or numerical values read by the sensors, such as temperature or pressure, or even the number of cycles that the Arduino is performing.
However, these displays have a small problem. When they are connected to a microcontroller (such as Micro bit for example), these displays require virtually many connection PINs occupying practically almost all available IO and leaving the multiprocessor few outputs for any other devices and sensors. This problem has been solved thanks to the communication on the I2C bus.
The LCD1602 display has an integrated microchip that manages this type of communication, and then all of the input and output information are limited to only two PINs (excluding power supply). I2C is a type of serial bus developed by Philips, which uses two bidirectional lines, called SDA (Serial Data Line) and SCL (Serial Clock Line). Both must be connected via pulled-up resistors. The usage voltages are standard as 5V and 3.3V.
The blue potentiometer on the I2C LCD1602 (see the figure below) is used to adjust the backlight for better display.And there is a jumper on the board, if you take away this jumper , the backlight will aways be off.
Because the output power of the micro bit is limited, please connect the USB cable to the USB port on the micro bit when downloading the program. After the program is successfully downloaded to the board, connect the USB cable to the USB port on the expansion board, ensure the LCD display can work perfectly.
After downloaded this code to your micro bit, pull out the USB line and insert the USB line to the expansion board, you will see “OSOYOO”,”Hello” on the LCD screen, then the entire screen will be full of random numbers.
This definitely solves the first of my problems, but we still need 8 pins to control this keypad… or do we? No, we don’t, we need only 2 pins. That is to say if we use one of those PCF8574 I2C IO port expander modules. They are much more reliable, as well as quite cheap as well. all depending on where you buy them from, and how long you are willing to wait for shipping