element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Unable to use Serial LCD with GPS
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 7 replies
  • Subscribers 418 subscribers
  • Views 785 views
  • Users 0 members are here
  • lcd
  • serial
  • gps
  • arduino
Related

Unable to use Serial LCD with GPS

e14 Contributor
e14 Contributor over 13 years ago

Hello,

  I have a Sparkfun GPS shield that works fine for me when I use the Serial Monitor for output. By default, the Sparkfun GPS shield connects to pins 2 and 3 on the Arduino board.

  When I try to get the output on a serial LCD (a Sparkfun serial LCD), I get no output... I am using pin 7 to connect Arduino to the Serial LCD. In the code below, if I comment out the lines that involve the LCD, the GPS works fine - it prints out the latitude and longitude to the Serial output. But I cannot use the GPS with the LCD! I just see the message "Wait for lock..." from the setup() function and then nothing happens...

  I have also tried using the other setting on the Sparkfun board - changing the DLINE setting to UART (so that the GPS uses pins 0 and 1), but then I do not even get the message from the setup() function...

  Any help much appreciated!

 

  Ravi

----------------------------------------------------------------------------------------------

 

#include <SoftwareSerial.h>

#include <TinyGPS.h>

 

#define RXPIN 2

#define TXPIN 3

 

#define TERMBAUD  115200

#define GPSBAUD  4800

 

TinyGPS gps;

 

SoftwareSerial uart_gps(RXPIN, TXPIN);

 

SoftwareSerial LCD(4,7); // RX, TX

 

void getgps(TinyGPS &gps);

 

void setup() { 

  Serial.begin(TERMBAUD); 

  uart_gps.begin(GPSBAUD); 

  LCD.begin(9600);

  clearScreen();

  LCD.print("Wait for lock...");

 

  Serial.println("");

  Serial.println("GPS Shield QuickStart Example Sketch v12");

  Serial.println("       ...waiting for lock...           ");

  Serial.println(""); 

}

 

void loop() {

  while(uart_gps.available()) {    

      int c = uart_gps.read();   

      if(gps.encode(c)) {    

        getgps(gps);        

      }

  }

}

 

void getgps(TinyGPS &gps)  { 

  float latitude, longitude; 

  gps.f_get_position(&latitude, &longitude);

   

  clearScreen();

 

  LCD.write(0xFE); // command flag

  LCD.write(128); // write to line 1

  LCD.print("Lat = ");

  LCD.print(latitude, DEC);

 

  LCD.write(0xFE); // command flag

  LCD.write(192); // write to line 2

  LCD.print("Long = ");

  LCD.print(longitude, DEC); 

 

  Serial.print("Lat/Long: ");

  Serial.print(latitude,5);

  Serial.print(", ");

  Serial.println(longitude,5);  

}

 

void clearScreen() {

  LCD.write(0xFE);

  LCD.write(0x01);

}

  • Sign in to reply
  • Cancel
  • mcb1
    0 mcb1 over 13 years ago

    One thought is to rename SoftwareSerial LCD to SoftwareSerial myLCD so that the Arduino isn't confused with a normal LCD.

    obviously every LCD.print needs tochange to myLCD.print

     

    I'd also be inclined to drop the Termbaud down from 115200 to something less.

     

    You haven't said whay happens if you comment out the gps bits. Do you get the lcd?

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 13 years ago in reply to mcb1

    Mark,

         I tried all that and it did not help... No, I do not get the lcd if I comment out the line

     

                        gps.f_get_position(&latitude, &longitude);

     

      I just read somewhere that if I create more than one SoftwareSerial object, only the last one created will function and that the right way to work with more than one SS object is:

     

    if (myPort.available() > 0)

    {

    c = myPort.read();

    // do something with c here

    }

     

      But then isn't there a problem with missing out on GPS data? Don't know - I should try this...

     

      Ravi

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 13 years ago in reply to e14 Contributor

    Ravi

         I tried all that and it did not help... No, I do not get the lcd if I comment out the line

                         gps.f_get_position(&latitude, &longitude);

    I actually meant try commenting out everything related to the gps serial including the setting up.

     

      I just read somewhere that if I create more than one SoftwareSerial object, only the last one created will function and that the right way to work with more than one SS object is:

    According to the Arduino site and the link the NewSoftSerial has been incorporated into ver1.xx so what version IDE are you using?

    If you are using ver023 then you need to use NewSoftSerial to do more than one.

     

    Personally I tend to use the I2C LCDs rather than serial ones.

     

    Mark

     

    Message was edited by: Mark Beckett to correct the confusion ...thanks William

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 13 years ago in reply to mcb1
    According to the Arduino site and the link the NewSoftSerial has been incorporated into ver1.xx so I presume you are using version 1 something.

     

    Using Chrome, the above was: Pasted, selected, and quoted.  Same as in Firefox 22.0.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 13 years ago in reply to mcb1

    Oh, all right, let us give a shout out to Microchip's PIC 16F1827.  Which is used in the Serial LCD Kit LCD #117 as found on  http://phanderson.com/lcd106/lcd107.html.

     

    My question is: How much longer do we have to wait for Microchip to bring out an Arduino style IDE for some of their products?  Texas Instruments did it.  Why not Microchip?

     

    And by the way, there are plenty of PICs which can be made into I2C slaves, eh.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 13 years ago in reply to billabott

    William

    Corrected ..cheers

     

    Got the quoting bit now ...see our other thread.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 13 years ago in reply to billabott

    Allow me to answer my own question.  I stumbled across the following web page circa 2009:

    http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en547558

     

    Possibly interesting reading if you have the time:

    http://ww1.microchip.com/downloads/en/DeviceDoc/CHAM_PIC_USER_MANUAL_V1_0.pdf

     

    Furthermore, I had forgotten that Microchip came out with the chipKIT line in May 2011.

    http://www.microchip.com/pagehandler/en-us/chipKIT-Development-Platform.html

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube