Jan 13, 2013

Getting Seeedstudio Grove Serial LCD to work...

This is the story of when I attempted to get the Seeedstudio Grove Serial LCD v 1.1 working with trivial examples: the problems encountered and how I handled them.

First: Getting Windows 7 to talk Arduino

The first problem was unexpected, I have managed to connect my windows 7 64-bit machine to the Arduino before, but today it refused. After some head scratching I realised I could not just "search for drivers", but also manually specify which driver to use. (Even though Windows doesn't recommend me to do this.) I found the manufacturer FTDI and selected "their" USB Serial. (I guess if was in the list since I had managed to install the driver previously.)

Well, correction. It seemed to work. If I tried to upload a sketch it failed, indication that the COM-port was busy.
Open Windows Device Manager, find the "unknown device" and manually indicate your arduino-1.xx\drivers-folder.
Now Device Manager says I have an "Arduino UNO R3 (COM5) in my Ports section. Yeah!
I tried uploading and "empty" sketch, and it worked!

Second: Wiring

While doing this I am looking at the step-by-step description on the Seeedstudio wiki.They suggest using their Arduino shield and the correct 4 wire cable, I have neither. But I have the Bus Pirate Cable which as general female cable-ends. .
I connected the 4 pins on the serial backpack according to the Bus Pirate suggested colors.

 


                  

Third: Initial coding

Ok, now it's time to start testing the sample code.

Getting the library

I downloaded SerialLCD_v1.0b library for Arduino1.0 like suggested, unzipped contents to a new sub-folder to Arduino/libraries. Copy and paste some code and attempt compile.

It couldn't find SerialLCD.h.

Quickly I realized that the Arduino IDE is not lika the C-compilers I usually use at work, it needs to be restarted to find that a new library has been appeared. After restart I could browse File → Examples → SerialLCD. I selected the HelloWorld example as a good programmer and attempted Compile.

  SerialLCD.h:28:24: error: WProgram.h: No such file or directory

Getting the sample to work.

I found a lead at stackoverflow.com, where else. From Arduino 1.00 they changed the name of the header-file WProgram.h to Arduino.h. (I would have kept a file with the old name just including the new one for avoid braking old code...)

Next compile attempt yields:
   SerialLCD.h:66: error: expected class-name before '{' token
Which is the line where class SerialLCD inherits from NewSoftSerial, I guess I hadn't installed that either...

At http://arduiniana.org/libraries/newsoftserial/ I found a offical-looking statement:

NewSoftSerial is in the core!  Starting with Arduino 1.0 (December, 2011), NewSoftSerial has replaced the old SoftwareSerial library as the officially supported software serial library.  This means that if you have 1.0 or later, you should not download this library.  To port your code to 1.0, simply change all NewSoftSerial references to SoftwareSerial.

Well,  not simply it turns out, but not too hard. First changing #include-statement and search+replace in SerialLCD h and cpp file and re-compile.
   SerialLCD.cpp:26:22: error: WProgram.h: No such file or directory
Aha. The cpp-file also contained #includes,. I just commented them out, since the ones in the SerialLCD.h should suffice. However that was not correct. They needed to be there, otherwise it wouldn't work. (I would guess that the Arduino pre-processor has some limitations, but it didn't seem worth dwelling on.)

Recompile and we get the next error
   SerialLCD.cpp:54: error: 'BYTE' was not declared in this scope
It seems another difference with Arduino 1.0 versus 0.x is that the print-method is now polymorphic and understand the type of the argument, so there is no need to explicitly specify this. Search-replace ,BYTE) with just ) seemed to fix this.

It compiles. I now have a binary sketch!

Upload!
But, shouldn't something happen?
I was expecting the promised "Hello World" display.

If I read the wiki it says there is a method "power", which the sample doesn't invoke. Perhaps...
   'class SerialLCD' has no member named 'backlight'

Is my library old or something?

When looking at "Comparision between various versions" I found in the remarks section:
For use of V1.1b with Arduino 1.0 only SerialLCD libraries for Arduino 1.0 is needed.

Let's look at that.

The right version turns out to make all the difference. It no longer had the faulty include or believed that print needed an extra parameter. (Well theres a few hours of my life I'll never get back.)

I kept the Arduino and LCD connected as before. (Tx-pin on backpack connected to receiving pin on Arduino.) Upload and it said hello, world!

So if you would encounter the troubles I had with the software, just download the right library!



But now it do seems to work. So I guess the day has to be considered to be a success after all.


/L

5 comments:

  1. Thanks a lot with you re help (this article) i ve arrived to make work my lcd driver.

    ReplyDelete
  2. Thanks a lot with your help but I have an only problem:
    SerialLCD.h:65: error: expected class-name before '{' token
    I installed NewSoftSerial but the error remains.
    Please help..

    ReplyDelete
    Replies
    1. I had same issue (see below) but by messing a bit around I got it to compile. I changed the
      #include
      to:
      #include

      Note the subtle difference (small case w). Now I need to find how to make it work - but it compiles. Look here for more info:
      http://www.seeedstudio.com/forum/viewtopic.php?f=17&t=2797

      Delete
  3. I get the same problem as Mattia. If you have any ideas please let us know. Tried to change the SerialLCD.h file which contained no line breaks. Any ideas?

    ReplyDelete
  4. Thanks for this article as it directed me to my issue as well. Just needed to change Rx and Tx around and there was magic!

    ReplyDelete