element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • 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
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Arduino Projects
  • Products
  • Arduino
  • Arduino Projects
  • More
  • Cancel
Arduino Projects
Blog Arduino, GPS, and Remote-Controlled Aircraft
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino Projects requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: CharlesGantt
  • Date Created: 24 Mar 2014 6:18 PM Date Created
  • Views 2436 views
  • Likes 4 likes
  • Comments 13 comments
Related
Recommended

Arduino, GPS, and Remote-Controlled Aircraft

CharlesGantt
CharlesGantt
24 Mar 2014

I recently picked up a new hobby that involves custom building muti-rotor helicopters and during this journey I have found a strong desire to map the flights of my quad copter. Unfortunately, a full sized handheld GPS is much too heavy to add to the payload of the quad copter and still retain respectable flight times. So I began searching for a small, lightweight GPS data logging solution that I could build myself with readily available, off the shelf components.

 

After a few days of research I settled on an Arduino and GPS shield combo with a cusom 3D printed case. Around the time I ordered the hardware I would need, a company called TinyCircuits contacted me and asked me if I would be interested in reviewing their products, and writing a few tutorials around their Tinyduino line of micro-development boards. I agreed and a few days later I had the company’s entire Tinyduino line sitting on my workbench.

 

image

 

Included in this kit was a fully functional micro-GPS shield that was not much larger than a quarter, an SD card shield, and an ArduinoArduino. When stacked together, the entire package is about 1-inch cubed, which makes the stack the perfect size for attaching to RC aircraft.  With everything I needed to develop my GPS logger I sat down at my bench to get the party started. I began researching and looking for sample code to help me speed up the build process, and during that search, I found a GPS data logger project that was built using the same TinyCircuits hardware I had on hand.



 

The GPS data logging project I found on Make.com was designed to track the author’s cat, but the code I needed to get my project off the ground would do the job whether it was tracking a cat or tracking the flight path of my quad copter. I realized that this project would be the perfect opportunity to write an article on how easy it is to build a project using the Arduino development environment and how easy it is to find, adapt and utilize existing code in your projects.

 

The TinyDuino series is pretty cool in the fact that you have a full Arduino Pro / Pro Mini packed onto a board the size of a quarter. I won’t go into great detail about the boards and what makes them so special, but if you would like further information on them, check out the full overview I wrote on TweakTown.com. Below is a list of everything you need to create a simple GPS Data Logger of your own using the Tiny Circuits hardware.

 

TinyCircuits PartsAlternate Arduino Parts From Newark
  • TinyDuino
  • TinyShield microSD
  • TinyShield GPS
  • TinyShield USB & ICP
  • TinyDuino Mounting Kit
  • 3D Printed Case
  • Code
  • Class 4 or higher 4GB microSD Card

Arduino Uno R3Arduino Uno R3

Arduino GPS ShieldArduino GPS Shield

 

 

image

 

There really is not much to building the GPS Data Logger other than stacking the shields in the correct order, uploading the code to the Arduino, and then getting outside and logging some data. The stack should be built in the following order.  The bottom most board should be the TinyDuino, which should then be followed by the TinyShield microSD board. Up next would be the TinyShield GPS which is followed by the TinyShield USB and ICP.

 

 

I chose to power my GPS Logger using a 18650 powered USB cellphone charger instead of the CR2023 or JST methods that the TinyDuino also supports. If you chose to go this route, you will need to arrange your stack with the TinyShield USB & ICP board placed between the TinyDuino and TinyShield GPS, I chose this route because I had several spare USB cellphone chargers laying around.

 

 

With everything stacked together, let’s prepare the TinyDuino for coding. Plug a microUSB cable into the TinyShield USB & ICP board, then select the appropriate USB port that the TinyDuino is now connected to. Once the correct port has been selected, we need to set the Arduino IDE to recognize the correct Arduino-compatible board. Since we are using a TinyDuino, we need to select Arduino Pro or Pro Mini (3.3V, 8MHz) w/ ATmega328. Once finished we should be ready to import some test code to the TinyDuino to test that everything is working correctly.

 

Before we upload any code we will need to make a minor change to the SoftwareSerial library in the Arduino IDE. You will need to replace the SoftwareSerial.cpp and SoftwareSerial.h Library files with the ones found in the GitHub repo for this tutorial. Replacing the files is quite easy and you simply need to navigate to Arduino>libraries>SoftwareSerial and rename the existing files to SoftwareSerial_cpp.bak and SoftwareSerial_h.bak and then download the new files into this directory.


Now that that is complete, lets upload some test code to make sure that everything was configured correctly and the TinyShield GPS module is sending raw NMEA data to the Tiny Duino. Upload the code that is embedded below (also found in the Git repo titled GPS_Test_Firmware.ino) and then open the serial terminal in Arduino and set the baud rate to 9600. You should see some weird strings that look like the pasted code below the GPS Test Firmware code.

 

GPS_Test_Firmware

/**********************************************************
* TinyCircuits Test Procedure
* Tiny-Circuits.com
*
* This is the test program for the GPS TinyShield (ASD2501)
*
**********************************************************/


#include <SoftwareSerial.h>


static const int GPS_ONOFFPin = A3;
static const int GPS_SYSONPin = A2;
static const int GPS_RXPin = A1;
static const int GPS_TXPin = A0;
static const int GPSBaud = 9600;
static const int chipSelect = 10;


// The GPS connection is attached with a software serial port
SoftwareSerial Gps_serial(GPS_RXPin, GPS_TXPin);


int led = 13;


void setup()
{
  // Init the GPS Module to wake mode
  pinMode(GPS_SYSONPin, INPUT);
  pinMode(GPS_ONOFFPin, OUTPUT);
  digitalWrite( GPS_ONOFFPin, LOW );
  delay(5);
  if( digitalRead( GPS_SYSONPin ) == LOW )
  {
     // Need to wake the module
    digitalWrite( GPS_ONOFFPin, HIGH );
    delay(5);
    digitalWrite( GPS_ONOFFPin, LOW );  
  }

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  Gps_serial.begin(9600);
}


void loop()
{
  if (Gps_serial.available())
     Serial.write(Gps_serial.read());
}


RAW GPS NMEA DATA

$PSRF150,1*3E
$GPGGA,,,,,,0,00,,,M,0.0,M,,0000*48
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,01,0error opening gps.txt
0,000,,02,00,000,,03,00,000,,04,00,000,*7C
$GPGSV,3,2,12,05,00,000,,06,00,000,,07,00,000,,08,00,000error opening gps.txt
,*77
$GPGSV,3,3,12,09,00,000,,10,00,000,,11,00,000,,12,00,000,*71
$GPRMC,,V,,,,,,,,,,N*53
$GPGGA,error opening gps.txt
,,,,,0,00,,,M,0.0,M,,0000*48
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,01,00,000,,02,00,000,,03,0error opening gps.txt
0,000,,04,00,000,*7C
$GPGSV,3,2,12,05,00,000,,06,00,000,,07,00,000,,08,00,000,*77
$GPGSV,3,3,12,09error opening gps.txt
,00,000,,10,00,000,,11,00,000,,12,00,000,*71
$GPRMC,,V,,,,,,,,,,N*53
$GPGGA,,,,,,0,00,,,M,0.0,M,,0error opening gps.txt
000*48
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,01,00,000,,02,00,000,,03,00,000,,04,00,000,*7C
error opening gps.txt
$GPGSV,3,2,12,05,00,000,,06,00,000,,07,00,000,,08,00,000,*77
$GPGSV,3,3,12,09,00,000,,10,00,000,,11error opening gps.txt
,00,000,,12,00,000,*71
$GPRMC,,V,,,,,,,,,,N*53
$GPGGA,,,,,,0,00,,,M,0.0,M,,0000*48
$GPGSA,A,1,,,,error opening gps.txt
,,,,,,,,,,,*1E

If the data that appears in the serial terminal does not look like this, then you will need to re-upload the SoftwareSerial files and upload the test code again.

 

Now that everything is working fine, we need to upload the actual GPS Data Logging code to the TinyDuino. I have pasted the code below, and remember to insert a properly formatted microSD (Read how to do this here ) card into the TinyShield microSD.

 

GPS Data Logger Code

/*
   This Arduino sketch will log GPS NMEA data to a SD card every second
   This code was written by Ken Burns, founder and CEO of TinyCircuits
*/


#include <SoftwareSerial.h>
#include <SD.h>




// The Arduino pins used by the GPS module
static const int GPS_ONOFFPin = A3;
static const int GPS_SYSONPin = A2;
static const int GPS_RXPin = A1;
static const int GPS_TXPin = A0;
static const int GPSBaud = 9600;
static const int chipSelect = 10;


// The GPS connection is attached with a software serial port
SoftwareSerial Gps_serial(GPS_RXPin, GPS_TXPin);




void setup()
{
  // Init the GPS Module to wake mode
  pinMode(GPS_SYSONPin, INPUT);
  pinMode(GPS_ONOFFPin, OUTPUT);
  digitalWrite( GPS_ONOFFPin, LOW );
  delay(5);
  if( digitalRead( GPS_SYSONPin ) == LOW )
  {
     // Need to wake the module
    digitalWrite( GPS_ONOFFPin, HIGH );
    delay(5);
    digitalWrite( GPS_ONOFFPin, LOW );  
  }


  // Open the debug serial port at 9600
  Serial.begin(9600);

  // Open the GPS serial port
  Gps_serial.begin(GPSBaud);

  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
}




int inByte = 0;         // incoming serial byte
byte pbyGpsBuffer[100];
int byBufferIndex = 0;


void loop()
{
  byte byDataByte;

  if (Gps_serial.available())
  {
     byDataByte = Gps_serial.read();

     Serial.write(byDataByte);
     pbyGpsBuffer[ byBufferIndex++ ] = byDataByte;

     if( byBufferIndex >= 100 )
     {
       byBufferIndex = 0;   
       File dataFile = SD.open("gps.txt", FILE_WRITE);

       // if the file is available, write to it:
       if (dataFile) {
        dataFile.write(pbyGpsBuffer, 100);
        dataFile.close();
      }
      // if the file isn't open, pop up an error:
      else {
        Serial.println("error opening gps.txt");
      }    
     }  
  }
}

 

Once the code is finished uploading, you should see the LED on the TinyDuino blink once every second. This is an indication that the TinyShield GPS is doing its job and polling its location every second and writing that point to the microSD Card. Now is the time to venture out unto the world and capture some data. Do this by unplugging the GPS Data Logger stack from your PC, and powering up the board by a CR2023, JST connected battery, or via the TinyShield USB & ICP like I have done. If you placed the TinyShield USB & ISP board on top of the stack you will need to remove it now to ensure that the GPS antenna gets a stong signal. If you need this board to power your stack, then move it to a position between the TinyDuino and TinyShield GPS.


You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


Unfortunately I have not hand a chance to take my TinyCircuits GPS Data Logger outside and gather data yet as we have had some fairly bad weather over the last few weeks. Every chance I get to venture outside on a sunny and nice day, I get caught up with another article, breaking news, or some other task that eats up my free time.  But for you, this tutorial will continue on and I will explain how to take the data that has been written to the SD card and show you how to import it into Google Earth for viewing.

 

When you are finished recording data, head to your nearest PC and open the SD card to view the filed stored inside. If you correctly formatted the SD card then you should only see one file that is titled gps.txt. Make sure you have extensions visible if using Windows, and then rename the file to gps.nmea. The current SD library can only write extensions up to three characters in length and is why the file is saved as a .txt instead of nmea.


Once you have the file renamed, open Google Earth and navigate to Tools>GPS and click GPS. There will be an option to upload a gps file. You can simply browse to the gps.nmea file you renamed, upload that file and Google Earth will plot the exact path that your GPS Logger took when it was gathering data. There are several other programs that can be used to visualize this data, but I will not list them here as a simple Google Search will give you pages of information on them.

 

image

 

Now that we have the GPS Data Logger working, we need to secure the stack together using the TinyDuino Mounting Kit. This will ensure that the stack stays securely connected during any impacts that might occur during flight.


image

 

With everything secure, we also need to enclose the stack inside the case so that it is safe from static discharges, moisture, and debris. You can head over to Thingiverse , or Github to download the custom enclosure I designed to house this project. It is designed to be affixed to a quad copter or any other ½” surface using nothing but Velcro straps that are commonly used to bind computer cables together. It could also be secured using zipties as well.


Video Here


image

 

I will update this post with video and tracking data from the first flight as soon as I get the final few parts in for the quad-copter I am currently building. They should be here within a week, so please check back for updates! Not much of any part of this project is of my own design except for the 3D printed case, and that is completely OK. I wrote this tutorial to demonstrate how easy it is to build almost any project with just a little knowledge, some pre-existing code, and a little creative design skills. I hope you enjoyed this project as much as I did, and I can not wait to update it with video and GPS data from some of my first flights with my new scratch-built quad-copter.

  • Sign in to reply

Top Comments

  • vd0gg1t
    vd0gg1t over 8 years ago +1
    Breaking News: Awesome Project! I can totally relate and have enjoyed the article immensely. I would like to update my outdoor electric timer switch to be blue toothed/wifi/smartphone enabled and tiny…
  • mcb1
    mcb1 over 7 years ago in reply to Former Member

    If I recall correctly, the Arduino IDE looks for the libraries relative to where it was launched from.

    so in your case it will head outwards from the .exe to /libraries/SoftwareSerial to find it.

     

    There is an option to include the path, but obviously anyone else using your code would need to duplicate the exact path.

    http://forum.arduino.cc/index.php?topic=37814.0

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 7 years ago in reply to mcb1

    Thanks to you both for trying to track this down. One thing that I notice is that the path to the SoftwareSerial files listed in the article is

    Arduino/libraries/SoftwareSerial (don't know if this is complete or not) and in my case the SoftwareSerial folder is at my

    E:/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SoftwareSerial. Maybe this is an environment variable problem?

    I downloaded the project from the Github repository and the IDE came from www.arduino.org/downloads..

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 7 years ago in reply to CharlesGantt

    CharlesGantt

    Understood.

    I'm away in a few weeks so if I don't reply please don't assume I'm ignoring you.

     

    It would be nice to see why it caused the error ...

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • CharlesGantt
    CharlesGantt over 7 years ago

    Thanks for helping out mcb1. At the moment I do not have the time to recreate this project, but I should be able to get to it in a few weeks. I also apologize for the broken images. I will try to get them fixed tonight.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 7 years ago in reply to Former Member

    Can you provide a link to where you downloaded the example.

     

    It could be code that wasn't intended for a lter version IDE, or simply how its used.

     

    I was able to compile it under the new and older versions of IDE.

    Can you copy the entire sketch and include it using the >> and Syntax highlighting with C++ options (so it looks like Charles original)

     

    It could be the library you have is caiusing the issue, so we might have another question.

     

    Like many projects the documentation is often less than ideal, which makes it hard for other people to use.

    Welcome to OSS ...

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • 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 © 2023 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.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube