element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • 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 Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
  • Settings
Remote Monitoring & Control
  • Challenges & Projects
  • Project14
  • Remote Monitoring & Control
  • More
  • Cancel
Remote Monitoring & Control
Blog LoRa Experimental Environmental Sensors (LoRaXes) - GPS is Working
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Remote Monitoring & Control requires membership for participation - click to join
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 25 Jul 2019 4:52 AM Date Created
  • Views 916 views
  • Likes 7 likes
  • Comments 0 comments
  • mkr_1300_wan
  • remotemonitoringcontrolch
  • the things network
  • gps
Related
Recommended

LoRa Experimental Environmental Sensors (LoRaXes) - GPS is Working

ralphjy
ralphjy
25 Jul 2019
image

Remote Monitoring & Control

Enter Your Electronics & Design Project for a chance to win up to a $200 Shopping Cart of Product!

Back to The Project14 homepage image

Project14 Home
Monthly Themes
Monthly Theme Poll

 

Making some progress - I got the GPS hooked up to the MKR 1300 and transmitting data to The Things Network.

 

GPS Module

The GPS that I am using is a Neo-6M board with a ceramic antenna.

image

The module communicates with the MKR 1300 via a UART so the connections are just 4 wires: 3.3V, Gnd, Tx and Rx.

 

Test Setup

Here is my test setup.  The breadboard is just used to physically anchor the MKR 1300 so it doesn't get pulled around by the USB cable.

image

 

Software

The good news is that there is a good collection of open source software available on GitHub for Arduino with GPS.  I found a program for the MKR 1300 by Gonzalo Casas that uses the TinyGPS++ library and also formats data for use by the TTN Mapper: https://github.com/gonzalocasas/arduino-mkr-wan-1300/tree/master/mkrwan_03_gps_tracker .  This program is known to work with the Neo-6M.  So, the programming is straightforward - download and include the TinyGPS++ zip library written by Mikal Hart: https://github.com/mikalhart/TinyGPSPlus/releases and put in the correct appEui and appKey obtained from the application in the TTN console.

 

Initially nothing seemed to be working.  The MKR 1300 would not connect to the TTN network.  I finally figured out that I had to reset the MKR 1300 twice and then let the LoRa modem try multiple times to get a reliable connection to the gateway.  I'm not sure about resetting twice, but it appears that multiple connect tries are required because of the frequency (channel) hopping of the Things gateway.  I think it is a synchronization problem because when it does not connect it registers a very low signal strength (less than -110dBm).  I can get a good signal strength on the same channel on a later pass (about -45dBm for my current test setup).

 

With some software tweaks (and a double reset), I can consistently connect to TTN.

image

 

However, I was not getting any GPS data.  I waited for an hour with no success, moving the device location periodically.  I gave up for the night and the next morning I was happily surprised with location data spewing forth.  It turns out that TinyGPS library requires acquiring 4 satellites before sending GPS data (this requirement is needed to determine altitude).

image

 

And the data arrives successfully in the TTN console:

image

 

TTN Mapper

JP Meijers has written a TTN Mapper integration and a payload decoder to format the received data.  Integrations are programs that tie your TTN device to other applications or even external platforms like AWS, Azure, or Watson.  Here is a sample of available integrations.  I'll be using TTN Mapper to plot my GPS data, but I can already think of uses for IFTTT.

image

 

 

You just need to add the integration to your application.  In this instance my application is ttn_ry_gps and the process id for my device is mkr_wan_gps.

image

 

 

The other thing needed is the payload decoder which is added to your console application:

// Author:
// Copyright (c) 2016 JP Meijers
// Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0
// https://github.com/jpmeijers/RN2483-Arduino-Library
function Decoder(bytes, port) {
  // Decode an uplink message from a buffer
  // (array) of bytes to an object of fields.
  var decoded = {};
  // if (port === 1) decoded.led = bytes[0];
  decoded.lat = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2];
  decoded.lat = (decoded.lat / 16777215.0 * 180) - 90;
  decoded.lon = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5];
  decoded.lon = (decoded.lon / 16777215.0 * 360) - 180;
  var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
  var sign = bytes[6] & (1 << 7);
  if(sign)
  {
    decoded.alt = 0xFFFF0000 | altValue;
  }
  else
  {
    decoded.alt = altValue;
  }
  decoded.hdop = bytes[8] / 10.0;
  return decoded;
}

 

 

Device on TTN Map:

image

 

Zoomed in:

image

 

 

The one bothersome thing about this data is that while the average location is correct, the outliers in the data are 40-60 meters out.  I'll need to investigate what's going on.  I suspect I may be losing satellites periodically.  Hopefully the GPS performance will be substantially better outdoors.

  • Sign in to reply
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 © 2025 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

  • X
  • Facebook
  • linkedin
  • YouTube