GPS Tracker

TTN version: TTNv3
Activation: ABP
Device Class: Class A
Last updated: January 23, 2023

This article provides instructions for making a GPS tracker using Adafruit Feather 32u4 RFM95 LoRa Radio and NEO-6M. If you haven’t set up Adafruit Feather 32u4 yet, check out our Adafruit Feather 32u4 tutorial.

You can use this tracker for tracking for example your bike or suitcase. The tracker can run on battery power or can be powered from USB. This device can be also used as TTN mapper to map The Things Network coverage. Learn more about using the GPS Tracker as a TTN Mapper.

GPS_Tracker

Prepare

  • Adafruit Feather 32u4 RFM95 LoRa Radio
  • GPS module with NEO-6M (GY-NEO6MV2)
  • LiPoly 3,7 V battery (1200 mAh or more)
  • Switch ON-OFF-ON MTS-203 6 pins
  • LED green / red
  • Male U.FL connector (for Adafruit Feather 32u4)
  • 2x pigtail U.FL – SMA Female
  • LoRa 868 MHz antenna
  • GPS antenna
  • 13x wire
  • Box (3D model)
  • 4x screw
  • PC + micro USB cable

When using the 1200 mAh battery, the device lasts 22 hours on a single charge (measured at room temperature 25 °C).

 

GPS module GY-NEO6MV2

To determine the location, we will use the GPS module GY-NEO6MV2 with NEO-6M. The module requires a stabilized supply voltage in the range of 3.3 V to 5.5 V for its function.

GPS_Tracker_NEO

 

Assembly

Connect everything according to the schematics bellow.

Wire up the Adafruit Feather 32u4’s IO1 pin with pin 6.

The battery is connected to the two middle pins of the switch. Two left pins with 3,7 V are connected and one of this pins is connected to Feather’s pin BAT. This means that when the switch is in the middle position, the battery is disconnected from Feather, otherwise the battery is connected. Middle pin of switch with battery GND is connected to Feather’s GND. One right pin of switch with GND is connected to Feather’s pin A1. Second right pin of switch with GND is connected to Feather’s pin A0.

LED’s middle pin is connected to 220 Ω resistor that is connected to Feather’s 3V pin. LED’s pin with green colour is connected to Feather’s pin A4. LED’s pin with red colour is connected to Feather’s pin A5.

GPS module NEO-6M is connected using four wires. The first GPS module pin GND is connected to ground (GND pin on Feather), second GPS module pin Tx is connected to Feather’s pin Rx, the third GPS module pin Rx is connected to Feather’s pin Tx and the fourth GPS module pin VCC is connected to the supply voltage (3V pin on Feather).

GPS_Tracker_Schematics

Put everything in a small box and connect pigtails U.FL – SMA Female to GPS module and Adafruit Feather 32u4. Then screw on the antennas.

GPS_Tracker_Box

 

Arduino IDE setup

  1. Run Arduino IDE.
  2. In the Arduino IDE Library Manager search TinyGPSPlus by Mikal Hart and install it.
  3. Download as ZIP this Low-Power library by Rocketscream.
  4. In the Arduino IDE Sketch -> Include Library -> Add .ZIP Library… choose downloaded ZIP.

 

GPS Tracker test

To test your assembled GPS Tracker follow this instructions:

  1. Copy and paste this program to your Arduino IDE.
  2. Set the switch on the GPS Tracker to the middle (OFF) position.
  3. Connect Adafruit Feather 32u4 using micro USB cable to your computer.
  4. In Arduino IDE click on Upload button to upload program to your Adafruit Feather 32u4.
  5. In Arduino IDE click on Serial Monitor button and you should every second see this:GPS Serial Monitor
  6. LED should blink green and red.
  7. Set the switch on the GPS Tracker to one side (ON) .
  8. LED should blink green.
  9. You should see this in Serial Monitor every second:GPS Serial Monitor
  10. Set the switch on the GPS Tracker to the other side (ON) .
  11. LED should blink red.
  12. You should see this in Serial Monitor every second:GPS Serial Monitor

 

Program for sending coordinates to TTS

We have prepared program for sending latitude, longitude, altitude and hdop to TTS every +-15 seconds.

Program and TTS setup

  1. Copy and paste GPS Tracker program to your Arduino IDE.
  2. In program replace NWKSKEYAPPSKEY and DEVADDR with keys of your end device registred in TTS. Keys are in TTS -> Applications -> YourAppName -> YourEndDeviceName -> Overview -> Session information.
  3. In TTS -> Applications -> YourAppName -> Payload formatters -> Uplink change Formatter type to Custom Javascript formatter and to Formatter code copy and paste code bellow:
    function decodeUplink(input) {
       var data = {};
    
       data.latitude = (input.bytes[0] << 16) + (input.bytes[1] << 8) + input.bytes[2];
       data.latitude = (data.latitude / 10000)
    
       data.longitude = (input.bytes[3] << 16) + (input.bytes[4] << 8) + input.bytes[5];
       data.longitude = (data.longitude / 10000)
    
       data.altitude = (input.bytes[6] << 8) + input.bytes[7];
       data.altitude = data.altitude / 10
    
       data.hdop = input.bytes[8] / 10;
    
       return {
          data: data,
          warnings: [],
          errors: []
       };
    }
  4. Save changes.
  5. Set the switch on the GPS Tracker to the middle (OFF) position.
  6. Connect Adafruit Feather 32u4 using micro USB cable to your computer.
  7. In Arduino IDE click on Upload button to upload program to your Adafruit Feather 32u4.
  8. The LED should start flashing green and red.
  9. Set the switch on the GPS Tracker to the Tracking position (as shown bellow).
  10. The LED should start flashing green.
  11. If the GPS data are valid, then the LED flashes green at a longer interval and the data are sent to the TTS.
  12. In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Live data you should every +-15 seconds see this:

Operating modes

Description of parts

GPS_Tracker_TOP

USB power

The following section describes the operating modes of the GPS Tracker when powered from USB:

Charging

  • The switch is in the Charging position
  • The battery is charging
  • The LED flashes red
  • The GPS Tracker is not sending data to the TTS

 

OFF / Program update

  • The switch is in the OFF position
  • the battery is not charging
  • the LED flashes green and red
  • the GPS Tracker is not sending data to the TTS

 

Tracking

  • The switch is in the Tracking position
  • The battery is charging
  • The LED flashes green
  • The GPS Tracker sends data to the TTS

If the switch is in the Tracking position and the GPS data are valid, then the LED flashes green at a longer interval and the data are sent to the TTS.

 

Battery power

The following section describes the operating modes of the GPS Tracker when running on battery power:

Charging – Don’t use this mode!

  • The switch is in the Charging position
  • The LED flashes red
  • The GPS Tracker is not sending data to the TTS

 

OFF

  • The switch is in the OFF position
  • The GPS Tracker is OFF

 

Tracking

  • The switch is in the Tracking position
  • The LED flashes green
  • The GPS Tracker sends data to the TTS

If the switch is in the Tracking position and the GPS data are valid, then the LED flashes green at a longer interval and the data are sent to the TTS.

 

Program update

  1. Set the switch on the GPS Tracker to the middle (OFF) position.
  2. Connect Adafruit Feather 32u4 using micro USB cable to your computer.
  3. The LED should start flashing green and red.
  4. In Arduino IDE click on Upload button to upload program to your Adafruit Feather 32u4.
  5. The LED should start flashing green and red.