I spent a couple of hours working on what should have been a couple of minutes of work....
The project started simple enough. Hookup the wires between the Nano and the I2C interface on the back of the LCD.
Color codes for the I2C 4 pin jumper cable:
GND = Orange
VCC = White
SDA = Blue
SCL = Black
What is SDA and SCL?
SDA = TX Data
SCL = RX Data (Clock)
What pins do I connect to the Arduino Nano?
Pin 23 (analog input 4) = SDA
Pin 24 (analog input 5) = SCL
Pin 27 = VCC / +5vdc
Pin 29 = GND
Why would I want to use I2C vs Parallel to connect to the LCD?
I2C only requires 2 data pins (4 pins total if you include +/- ) vs. a bunch more for a parallel interface. (I2C also supports additional devices on the same bus without needing more pins on the Arduino.)
So I spend a couple of minutes looking up the pin out information and connecting some jumpers. The next step is to download the appropriate I2C LCD libraries. (No problem, right?)
I perform a couple of Google searches and Adafruit (website and store) comes up some great info about downloading the library. I then notice that someone has built a faster library and Adafruit has provided a link to this new library. After having some initial issues I discover that I am not using the most up to date version of the library so I download 2012 version and that resolves a couple errors using v1.0.3 of the compiler. This gets me to the point where I download a sketch to with the LiquidTWI library to the Nano.
The LCD lights up and shows bunch of solid boxes for each character on line 1 of the 16x2 LCD.
- I scratch my head for a while thinking that maybe I have the SCL/SDA reversed or maybe I am using the wrong address for my I2C interface. (FYI... It is in fact 0x27)
- I start some more Google searches for Arduino I2C LCD YwRobot LM1602 Problem and similar keywords.
- After a couple of hours and multiple browser crashes (@#$% Safari @#$%) I am still stumped.
- I take a break to watch "The Walking Dead" with my family.
- I decide to order some additional I2C interfaces thinking that I let the smoke out of the backpack. (The chip smelled weird and looked discolored at one edge.)
- I decide to give it one more try before I give up all hope for the night... since it is not cool to be defeated by 4 simple wires.
Let there be some magic in my many searches and I stumbled across:
While I held out little hope I download another library based that thread since it seemed like it might be same type of issue I was facing:
I opened up the example and sent it to the Nano:
Looking at the thread it seems like the logic between the driver chip & the library(s) are potentially reversed. (There are a couple of different driver chips on similar boards in the market place.)
So at the end of the day (literally, it is 10pm Sunday night) I was able to get this working. This simple hello world example should have taken 10-15 minutes took about 3-4 hours to figure out. It is likely tied to the driver chip and the version of the I2C daughter board.
It will be interesting to see the results on the I2C boards that I just ordered. (Some from ebay/China and some from a US source.)
This seems like a lot of work for hello world. But it is better that I found this issue now vs. in the middle of code with the DDS or rotary encoder. :-)
73 de NG0R