Help me plz. TinyGPS with arduino micro

I use TinyGPS code with arduino uno and it’s works. but now i use it with arduino micro it doesn’t work
the result is that.

**** **** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0
No GPS data received: check wiring
**** **** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0
No GPS data received: check wiring
**** **** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 4, TXPin = 3;   // when i use arduino micro i change it static const int RXPin = 3, TXPin = 2;
static const uint32_t GPSBaud = 9600;

TinyGPSPlus gps;

SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);

  Serial.println(F("Sats HDOP Latitude   Longitude   Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum"));
  Serial.println(F("          (deg)      (deg)       Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail"));
  Serial.println(F("---------------------------------------------------------------------------------------------------------------------------------------"));
}

void loop()
{
  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

  printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
  printInt(gps.hdop.value(), gps.hdop.isValid(), 5);
  printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
  printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
  printInt(gps.location.age(), gps.location.isValid(), 5);
  printDateTime(gps.date, gps.time);
  printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);
  printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);
  printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);
  printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.value()) : "*** ", 6);

  unsigned long distanceKmToLondon =
    (unsigned long)TinyGPSPlus::distanceBetween(
      gps.location.lat(),
      gps.location.lng(),
      LONDON_LAT, 
      LONDON_LON) / 1000;
  printInt(distanceKmToLondon, gps.location.isValid(), 9);

  double courseToLondon =
    TinyGPSPlus::courseTo(
      gps.location.lat(),
      gps.location.lng(),
      LONDON_LAT, 
      LONDON_LON);

  printFloat(courseToLondon, gps.location.isValid(), 7, 2);

  const char *cardinalToLondon = TinyGPSPlus::cardinal(courseToLondon);

  printStr(gps.location.isValid() ? cardinalToLondon : "*** ", 6);

  printInt(gps.charsProcessed(), true, 6);
  printInt(gps.sentencesWithFix(), true, 10);
  printInt(gps.failedChecksum(), true, 9);
  Serial.println();
  
  smartDelay(1000);

  if (millis() > 5000 && gps.charsProcessed() < 10)
    Serial.println(F("No GPS data received: check wiring"));
}

// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
  unsigned long start = millis();
  do 
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}

static void printFloat(float val, bool valid, int len, int prec)
{
  if (!valid)
  {
    while (len-- > 1)
      Serial.print('*');
    Serial.print(' ');
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1); // . and -
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(' ');
  }
  smartDelay(0);
}

static void printInt(unsigned long val, bool valid, int len)
{
  char sz[32] = "*****************";
  if (valid)
    sprintf(sz, "%ld", val);
  sz[len] = 0;
  for (int i=strlen(sz); i<len; ++i)
    sz[i] = ' ';
  if (len > 0) 
    sz[len-1] = ' ';
  Serial.print(sz);
  smartDelay(0);
}

static void printDateTime(TinyGPSDate &d, TinyGPSTime &t)
{
  if (!d.isValid())
  {
    Serial.print(F("********** "));
  }
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year());
    Serial.print(sz);
  }
  
  if (!t.isValid())
  {
    Serial.print(F("******** "));
  }
  else
  {
    char sz[32];
    sprintf(sz, "%02d+7:%02d:%02d ", t.hour(), t.minute(), t.second());
    Serial.print(sz);
  }

  printInt(d.age(), d.isValid(), 5);
  smartDelay(0);
}

static void printStr(const char *str, int len)
{
  int slen = strlen(str);
  for (int i=0; i<len; ++i)
    Serial.print(i<slen ? str[i] : ' ');
  smartDelay(0);
}

Quite the most stupid post I have ever seen.

Read the rules

Post your code

Modify that abortion of a first post.

Edit and you did thanks.

Please put your code in its own window as seen in other posts. This can be done by placing

    [/color][code]  and [/code]
[color]

around the code or use the </> icon. This makes it easier for others to read.

How to use this forum

Give us a link to the TinyGPS and a photo of the wiring.

Weedpharma

thx u for suggsetion. sorry for my fault. it is my first post.

What are you doing. That "diagram" does not reflect what you said or the code. Using that diagram you should use Serial1 not Serial and do not use software serial at all.

Hi Hatakai

I understand your question. Nothing wrong with your question.

The problem is caused by the with Arduino Micro, as it shares Serial with USB. To check if your Micro is receiving the data use the following code:

void setup() {
  Serial.begin(115200); //This pipes to the serial monitor
  while(!Serial);
  Serial1.begin(9600); //This is the UART, pipes to sensors attached to board
  while(!Serial1);
}

void loop() {
  if ( Serial.available() ) {
    int inByte = Serial.read();
    Serial1.write( inByte );
  }
  if ( Serial1.available() ) {
    int inByte = Serial1.read();
    Serial.write( inByte );  
  }
}

The next step is to figure out how to modify TinyGPS/TinyGPS+ to work with the Arduino Micro.

Image embedded for our convenience:

Technique described here.

andrebruton:
The next step is to figure out how to modify TinyGPS/TinyGPS+ to work with the Arduino Micro.

He does not need to modify the library. His sketch is the problem. Actually, that library's examples have problems as well. They are not correctly structured and frequently break when modified.

@Hataki, you might try NeoGPS. All the examples will use Serial1 by default. NeoGPS is smaller, faster, more reliable and more accurate than all other GPS libraries. It is available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries. Even if you don't use it, there are lots of tips on the Troubleshooting page and the Installation page (see Choosing a Serial Port).

Cheers,
/dev

andrebruton:
I understand your question. Nothing wrong with your question.

Yes easy to do now he has edited it to something sensible, but originally it was a mess. That is why the forum rules say not to change the origional post except to add code tags and add new information in further posts.