Go Down

Topic: Arduino GPS Shield by iteadstudio.com (Read 42146 times) previous topic - next topic

BlackDice

Is there a working code from PJ_123?
I'm using this code but I'm not be able to write the data on a SD card  :~
Can anyone help me or upload a working program?
BlackDice

pRabbit

BlackDice-

Have you tried the "CardInfo" example in the SD library to see if your card is working?  Are you using a Mega?

For me the SD card example "CardInfo" in the examples works great on an Uno.  On the Mega, the SPI is on a different set of pins (D50-D53 on Mega rather than D10-13 on the Uno).  The itead GPS shield doesn't reach the D50-D53 SPI pins on the Mega so I had to run jumper wires from D50-52 on the Mega to D11-13 on the itead GPS sheild, I configured D11-13 as inputs in software but still used pin D10 as chip select (CS).  After that the Mega was able to access the SD card.

I took it a step farther and got it working on the Due, which required wiring up to the SPI connector in the middle of the board (why is this pins when everything else is sockets?  What a pain).  For the Due there is some good reading on Arduino.cc on the extended functionality of the Due SPI: http://arduino.cc/en/Reference/DueExtendedSPI.

gwcohn

Using the code in reply #5, change the references for SoftwareSerial to NewSoftSerial and change the GPS shield baud rate to 9600.

Make sure you have the jumpers and the RX and TX reference in the code correct.

I have the rx jumper on 3 and the tx jumper on two using an arduino UNO.

That agrees with this line of code: NewSoftSerial nss(2, 3);//tx and rx pins in my itead GPS shield

Take a look at your serial terminal and the rx chars and sentences should be incrementing.  If not, you may have your jumpers wrong on the GPS board.

It may take about 10 seconds to acquire three or more satellites before the lat and lon starts getting populated.

My house has a wood and built up roof so it works fine inside.  If you have any kind of metallic roofing, it may prevent you from receiving signals from the satellite.

#include <NewSoftSerial.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 3(rx) and 4(tx).
*/

TinyGPS gps;
NewSoftSerial nss(2, 3);//tx and rx pins in my arduino GPS shield

static void gpsdump(TinyGPS &gps);
static bool feedgps();
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);

void setup()
{
  Serial.begin(9600);
  nss.begin(9600);//baud rate for the GPS shield
 
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS));
  Serial.println();
  Serial.println("Sats HDOP Latitude Longitude Fix  Date       Time       Date Alt     Course Speed Card  Distance Course Card  Chars Sentences Checksum");
  Serial.println("          (deg)    (deg)     Age                        Age  (m)     --- from GPS ----  ---- to London  ----  RX    RX        Fail");
  Serial.println("--------------------------------------------------------------------------------------------------------------------------------------");
}

void loop()
{
  bool newdata = false;
  unsigned long start = millis();
 
  // Every second we print an update
  while (millis() - start < 1000)
  {
    if (feedgps())
      newdata = true;
  }
 
  gpsdump(gps);
}

static void gpsdump(TinyGPS &gps)
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
 
  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);
  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);
  gps.f_get_position(&flat, &flon, &age);
  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);
  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

  print_date(gps);

  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2);
  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);
  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);

  gps.stats(&chars, &sentences, &failed);
  print_int(chars, 0xFFFFFFFF, 6);
  print_int(sentences, 0xFFFFFFFF, 10);
  print_int(failed, 0xFFFFFFFF, 9);
  Serial.println();
}

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

static void print_float(float val, float invalid, int len, int prec)
{
  char sz[32];
  if (val == invalid)
  {
    strcpy(sz, "*******");
    sz[len] = 0;
        if (len > 0)
          sz[len-1] = ' ';
    for (int i=7; i<len; ++i)
        sz = ' ';
    Serial.print(sz);
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1);
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(" ");
  }
  feedgps();
}

static void print_date(TinyGPS &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long age;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  if (age == TinyGPS::GPS_INVALID_AGE)
    Serial.print("*******    *******    ");
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d   ",
        month, day, year, hour, minute, second);
    Serial.print(sz);
  }
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  feedgps();
}

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

static bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}

Docedison

SoftwareSerial became a part of the IDE in Ver 1.0 it is the official replacement for the older NewsoftSerial and it works just fine with an Uno a pro-mini and several bare chips and at least 2 different GPS devices on my bench.

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

ubruns


...
On the Mega, the SPI is on a different set of pins (D50-D53 on Mega rather than D10-13 on the Uno).  The itead GPS shield doesn't reach the D50-D53 SPI pins on the Mega so I had to run jumper wires from D50-52 on the Mega to D11-13 on the itead GPS sheild, I configured D11-13 as inputs in software but still used pin D10 as chip select (CS).  After that the Mega was able to access the SD card.


Code: [Select]
Used the following wiring:
G    D10 - D53  M
P    D11 - D50  E
S    D12 - D51  G
     D13 - D52  A


After that I loaded the example sketch "CardInfo" and changed the following lines:
Code: [Select]
const int chipSelect = 53;   
....
pinMode(53, OUTPUT);     // change this to 53 on a mega


The SD card is a 8GB card, repartioned with a 1.9GB primary FAT16 partition.

Can't get it to work.... init failed.

Anyone suggestions ?

Ballibum

Hi,
i have also trouble with the GPS Shield of iteadstudio. When i'm using the code of http://forum.arduino.cc/index.php?PHPSESSID=tgd8eml0krmg4vvuhq0enuckk3&topic=113603.msg1018040#msg1018040 in combination with an arduino uno everything works fine. But when i want to use it with my arduino mega, i get nothing:

Code: [Select]
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0
CHARS=0 SENTENCES=0 CSUM ERR=0


So maybe some of the pins are wrong:
here is picture of my connection (the code is with the pin 3 and 4):

thanks for helping me

Frédéric_Plante

Sorry had busy time lately

Is there any thing coming out of you serial monitor when you hook the jumper to 0 and 1?
As we fight our way northward into the great unknown, only that one thing remains certain...

Ballibum

No, i can not upload it when i am using pin 0 and 1. And when i put the shield to the mega after uploading, i get also no informations only a empt serial monitor.
thanks for helping me

Ballibum

What can i change on my design, so that this network works with my arduino mega?i need the mega, becaus i want to work with more than one component

Frédéric_Plante

#54
Aug 24, 2013, 07:05 pm Last Edit: Aug 24, 2013, 07:15 pm by Frédéric_Plante Reason: 1
I was telling the him to use pin 0 and 1 to simply see if his shield was transmitting any thing.

If you use Mega, I would suggest to use secondary sérial port instead of software one. In this case pin 14 to 19 are 4th 3rd and 2nd physical serial port use those. How ever since you are using this iteadstudio shield you wont have to use the on board jumpers. Just use Dupont jumper wire to bring your signal to the pair of pin you want to use as serial port, and use the  example you can find here http://arduino.cc/en/Tutorial/MultiSerialMega, as reference to start your project.

And remember that the SPI port on the Mega is found at pin 50 to 53 so you will have to deal with that if you plan on using the SDCard reader. It might not look very good but removing the pin 10 to 13 from you shield and run Dupont jumper wire from the top of your shield to the SPI port of the MEGA could be a solution, but you will curse later if you want to run your shield on a UNO or the new Yùn. So think twice before cutting.
As we fight our way northward into the great unknown, only that one thing remains certain...

Ballibum

HI thanks for your help. Have you got a schema or a graphic, how i have to set up the connection between the mega and the gps-shield? I am only a arduino rookie.
thanks

Frédéric_Plante

#56
Aug 25, 2013, 05:02 pm Last Edit: Aug 25, 2013, 10:01 pm by Frédéric_Plante Reason: 1
First let's start with the hardware part. Look at the picture I send at the bottom of this post.

As you can see on the picture, you have the Tx row and the Rx row. You must use a Dupont Jumper wire to link those row to the Serial port 1 on the Mega. One of the pin of Tx row goes to the Rx pin(19) on the Mega, and one of the pin Rx row goes to the Tx pin(18) on the Mega. You can take any pin of each two Rows, since each pin of each Row are interconnected. Also Remove the 2 jumpers from this section of the GPS board.



By the way, the middle Row are Male connector individualize that lead to the pin 0 to 7. You can use them as simple male connector for those pin. Since you use serial port1, this Row has no use in you project, at least not concerning the GPS part.

Here:

ftp://imall.iteadstudio.com/IM120417017_Arduino_GPS_shield/DS_IM120417017_ArduinoGPSshield.pdf

they say :

Quote
The INT0 is the broke out of the external interrupt pin of GPS module,
if not use, please set the jumper to OFF as the following figure.
The INT1 is the broke out of the 1PPS output. When the GPS module
has tracked to the GPS satellite, this pin will send a pulse per second.


So if you want to use External Interrupt for you GPS set INT0 to ON. And if you want to use the 1PPS function on the GPS set INT1 to ON, otherwise leave them OFF. Use the 2 jumper you previously remove to set these 2 functions ON or OFF

IMPORTANT!!! They also remind that:

Quote
When install GPS shield to Arduino, please check the operation
voltage level of development board. If the voltage is 3.3V
(IFLAT32,Leaf maple), set the Operation Level Setting switch to 3.3V.
If the voltage is 5V(Arduino), set the Operation Level Setting switch to
5V.




I see, from your picture, that the proper voltage is set on your GPS board, So unless you use a 3,3volts system, DON'T change it. Cause you might blow your GPS.


That was the hardware part. Now the software.

I choose the Serial Port1 because the example found http://arduino.cc/en/Tutorial/MultiSerialMega, a repeater program, use this port setting. You can use any of the 3 ports on the Mega, but if you don't use Port1, you will need to modify the code accordingly.

You might have to set the pace to 38400 bps, if it's what you GPS need, in the example. To know check what the default is set at for your GPS board. But if you haven't change it, it should be 38400 bps according to the documentation listed above.

Maybe, set the same pace for serial port0 It should not hurt.

Your test code should look like this

Code: [Select]


void setup() {
                     // Put the proper GPS communication speed down in those 2
 Serial.begin(38400);    // This is the port the Mega use to communicate with you computer
 Serial1.begin(38400);  // This is where your GPS is hook
}

void loop() {
 // read from GPS, send to IDE Serial Monitor:
 if (Serial1.available()) {
   int inByte = Serial1.read();
   Serial.write(inByte);
 }
 
 // read from IDE Serial Monitor, send to GPS:
 if (Serial.available()) {
   int inByte = Serial.read();
   Serial1.write(inByte);
 }
}



Finaly, upload the example to your Mega. Once it's done it should send the GPS incoming data to your serial monitor. But make sure to put the proper pace in the IDE Serial Monitor otherwise it's just gonna show you weird stuff.

If this Work you in business. You can add commands to your routines until you have the program you want or until it get so complicated that you won't understand what is happening inside. :P

Also I checked the Tinygps example from http://arduiniana.org/libraries/tinygps/

One thing is certain about this example, You must change all the parts about the software serial "ss" to hardware "Serial1".

So i look like this:

Code: [Select]


#include <TinyGPS.h>

TinyGPS gps;

void setup()
{
 Serial.begin(115200);
 Serial1.begin(4800);                                     //This line has been change
 
 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 (Serial1.available())                                     //This line has been change
   {
     char c = Serial1.read();                                     //This line has been change
     // 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);
}


I also remove the reference to the serial software libraries, And the point where that libraries was call. This save room because there is one less libraries to load.


Oh! Are you outside, or near a Windows that is pointing East or West? Cause if you are in you basement there are good chance your GPS unit catch nothing from satellite.


If's you have any question I will be pleased to help more, but I think this explanation is completed.
As we fight our way northward into the great unknown, only that one thing remains certain...

Ballibum

Hi thanks for your great answear, i will test it, when you answeared my next question:
Your write this:
Quote
Quote
When install GPS shield to Arduino, please check the operation
voltage level of development board. If the voltage is 3.3V
(IFLAT32,Leaf maple), set the Operation Level Setting switch to 3.3V.
If the voltage is 5V(Arduino), set the Operation Level Setting switch to
5V.

So I see, from the picture, that the proper voltage is set on you board, So unless you use a 3,3volts system, DON'T change it. Cause you might blow your GPS.


I use an arduino so, why i have to use 3,3V - on my testsystem with the uno i am using 5 V, so the switcher stands on 5V.
Thanks a lot

Frédéric_Plante

#58
Aug 25, 2013, 07:51 pm Last Edit: Aug 25, 2013, 08:02 pm by Frédéric_Plante Reason: 1
Quote
I use an arduino so, why i have to use 3,3V - on my testsystem with the uno i am using 5 V, so the switcher stands on 5V.


Some system, as they say, run and only support on 3,3v. In this case you set the switch to 3,3volts. In the case of Arduino Uno and Mega, the Arduino give 5v, so it need a unit that will bring the voltage down to 3,3v.

If you set that switch to 3,3v, the Arduino will send 5 volt to your GPS and burn it, and you will cry.

Just to make sure I put the picture of how the switch should be.
As we fight our way northward into the great unknown, only that one thing remains certain...

Ballibum

Okay, i have test your code, but nothing happens.

Go Up