Serial.Available() is returning zero why ?

hi am connecting an itead GPS module : http://imall.iteadstudio.com/im120417017.html

my code is :

#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9); // RX, TX
const int baud =9600;
//const int sentlen =256;
void setup()
{
Serial.begin(9600);

}

void loop()
{
// make a string for assembling the data to log:
char index = 0;
char temp = 0;
String dataString = "";

while(true)
{

if(mySerial.available())
{
temp = mySerial.read();
dataString += String(temp);
Serial.print(dataString);
dataString = "";

}
}

}


mySerial.available() always return false why ? do i miss something in the configuration of the shield ?

thanks

Make sure that the voltage on the RX0 port is high enough. If it's too much lower than 5V you're going to get nothing.

SoftwareSerial mySerial(8, 9); // RX, TX

Are you sure that the shield uses these pins for serial comms ?
Where is mySerial.begin() in your program ?

Please use code tags.

How to use this forum

What Arduino do you have?

Dump the while(true) loop. The loop function is there to do the looping for you. It's even possibly part of your problem. You'll also have to declare those local variables outside the loop function to prevent them getting re-initialised on every itteration of the loop.

Mr Nick Gammon , I have arduino Uno

See reply #2.

Where is mySerial.begin() in your program ?

Mr Nick Gammon , I changed my code to be the simple test code that comes with the library it's (which contain serial.begin(38400)) , it's :

#include <SoftwareSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/

TinyGPS gps;
SoftwareSerial ss(8, 9);

void setup()
{
  Serial.begin(38400);
  ss.begin(38400);
  
  Serial.print("Simple TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
}

void loop()
{
  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (ss.available())
    {
      char c = ss.read();
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print("LAT=");
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
  }
  
  gps.stats(&chars, &sentences, &failed);
  Serial.print(" CHARS=");
  Serial.print(chars);
  Serial.print(" SENTENCES=");
  Serial.print(sentences);
  Serial.print(" CSUM ERR=");
  Serial.println(failed);
  if (chars == 0)
    Serial.println("** No characters received from GPS: check wiring **");
}

[\code]

but i have the following output :


by Mikal Hart

CHARS=351 SENTENCES=0 CSUM ERR=0
CHARS=721 SENTENCES=0 CSUM ERR=0
CHARS=1101 SENTENCES=0 CSUM ERR=0
CHARS=1464 SENTENCES=0 CSUM ERR=0
CHARS=2381 SENTENCES=0 CSUM ERR=0
CHARS=2743 SENTENCES=0 CSUM ERR=0
CHARS=3113 SENTENCES=0 CSUM ERR=0
CHARS=3473 SENTENCES=0 CSUM ERR=0


what's the problem here , I am using a wifi antenna does this may be the reason ?

Using an antenna for what? Does your GPS send at 34800 baud?

   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/

TinyGPS gps;
SoftwareSerial ss(8, 9);

What are pins 8 and 9 connected to?

8,9 are connected to the gps ... i forgot to tell u i modified this

Why does the baud rate you are using for ss not match that mentioned in the comment at the top of the code ?

 It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).

...

  ss.begin(38400);

Problem #1, I think.

i used 38400 because it's written in the data sheet of my gps shield, however i tried 4800 and the output gave me errors

Can you please provide a link to the GPS shield that you are using and give details of the errors you saw when using 4800 baud

the same following output , but with ERR = number not zero :

CHARS=351 SENTENCES=0 CSUM ERR=0
CHARS=721 SENTENCES=0 CSUM ERR=0
CHARS=1101 SENTENCES=0 CSUM ERR=0
CHARS=1464 SENTENCES=0 CSUM ERR=0
CHARS=2381 SENTENCES=0 CSUM ERR=0
CHARS=2743 SENTENCES=0 CSUM ERR=0
CHARS=3113 SENTENCES=0 CSUM ERR=0
CHARS=3473 SENTENCES=0 CSUM ERR=0

Eng_boody:
8,9 are connected to the gps ... i forgot to tell u i modified this

How? You might be better off using hardware serial for the GPS at that baud rate.

You could have the GPS pushing data into the Rx pin on the Arduino and use the Tx pin for echoing information to the PC.

i get the same following message but with error not equal zero but equals a number ;

CHARS=351 SENTENCES=0 CSUM ERR=0
CHARS=721 SENTENCES=0 CSUM ERR=0
CHARS=1101 SENTENCES=0 CSUM ERR=0
CHARS=1464 SENTENCES=0 CSUM ERR=0
CHARS=2381 SENTENCES=0 CSUM ERR=0
CHARS=2743 SENTENCES=0 CSUM ERR=0
CHARS=3113 SENTENCES=0 CSUM ERR=0
CHARS=3473 SENTENCES=0 CSUM ERR=0