dfrobot i2c lcd displays made in china

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.

EX‑CommandStation is designed to accommodate a display. You don’t need a display since the Control Station is often hidden away under the layout. However, if you like the idea of a nice visual display for your panel, just about any I2C (serial to parallel interface) display will work. We recommend either a 20 character by 2 line or 4 line display. The code is easily configurable in order to change the display settings, as well as add or change what is printed on the display.
Do NOT modify any code related to displays without contacting us. We use our own included code, NOT an external library you have to download. The code was written to support LCD and OLED displays and to fit on a Mega and an Uno. It has a custom font table and the LCD macro works to output diagnostics even if there is no display. If your display is not supported, let us know and we can take a look.
The LCD displays require a “backpack” that converts the raw display to I2C. I2C allows us to use just 2 lines (SDA (serial data) and clock (SCL)) to send text to the display. Without this board, we wouldn’t have enough pins, especially on an Uno, to use a display.
You MUST make sure to order TWO (2) parts for your LCD Displays. You need the display AND a backpack based on the PCF7584 controller chip. Some displays come with this already soldered together. Make sure before you buy!
Here is an example of a 20 x 4 LCD screen. They come in different colors like blue and green. The controller board (backpack) is shown before soldering it to the back of the display. Soldering is very simple since you just match the two boards together and quickly solder the pins. Though there are 16 of them.
Find the 4 characters that start with 0x and add the address for your I2C backpack after it. We default to 3F, but your display may be 27. The text would read 0x27 if that was the case.
OLED displays come in more varieties than LCD displays. The library to run them also takes more memory. Therefore, OLED displays won’t work with an UNO and you will require a Mega. Here are some examples of OLED displays:
Physically connecting an I2C OLED display to your EX‑CommandStation is relatively straight forward, with SDA connecting to the CommandStation’s SDA pin, SCL to SCL, VCC to 5V, and GND to GND.

Time to open up the new toys I got from China, DFRobot LCD Keypad Shield (DFR0009)! As I said, I ordered this from China’s ebay equivalent, Taobao.com, got this for 30 RMB ($5 USD), pretty cheap for a LCD display panel, let alone this is a shield with keypad! In the US, it is being sold for $15!!! Anyway, the link is follow if anyone is interested. Maybe I will do a post about ordering stuffs directly from China. I spent like $50 total and stocked up my electronic inventory with all kinda of new shields, joysticks…
Using this shield is pretty much the same as all other LCD display. It uses Digital Pins: 4, 5, 6, 7, 8, 9 for LCD data and 10 for LED back light. Analog Pin 0 (A0) is used for the keypad. Pressing down various buttons (except Reset) will result in different A0 values, the default unpressed value for mine is 1023. So here’s the code on how to use this thing.

Lastly, the code part where the real understanding begins. So, basically I have used two libraries one for the sensor and the other for the LCD 1602 I2C display. Then let us start:
I wrote the whole code together hope you may not find it too difficult.void setup() {dht.begin();// initialize the sensorlcd.backlight();// turn on lcd backlightlcd.init();// initialize lcd}void loop() {lcd.clear();lcd.setCursor(0,0);// set the cursor on the first row and columnlcd.print("Humidity=");lcd.print((float)dht.readHumidity());//print the humiditylcd.print("%");lcd.setCursor(0,1);//set the cursor on the second row and first columnlcd.print("Temp=");lcd.print((float)dht.readTemperature());//print the temperaturelcd.print("Celsius");delay(2000);lcd.clear();}

Holding the serial module with the I2C interface at the left hand end, there are 16 pins at the lower edge. The first of these is ground, and the second of these is +5v. Another option is to use the lower two pins on the I2C interface for power, but I found it more convenient to use the pins as described above.
I2C interface. On the serial module, the top pin is SCL (clock) and it goes to the Arduino A5. The second pin down is SDA (data) and it goes to the Arduino A4.
LCD print interface. There are 6 connections between the serial module and the LCD Keypad shield, all of them between pins with no labels. I will identify them on the LCD module by counting from Right to Left, with the first pin as 1. There are 2 blocks of 8, so they go from 1 to 16. I identify them on the I2C serial module by counting from Left to Right, there are also 16 of these. In addition I give each wire a label, which is the equivalent pin on the Arduino that is normally associated with that function, in the case of a direct connection without the serial module.
Keypad interface: This uses a single wire from the LCD module pin on the lower side labelled "A0", to pin A0 on the Arduino. At least that was pretty easy!
Ms.Josey
Ms.Josey