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
    • Experts & Guidance
    • 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
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs Adding GPS functionality to the BG96 on the Telus LTE-M IoT Starter Kit
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: james.flynn
  • Date Created: 14 Dec 2018 4:55 PM Date Created
  • Views 850 views
  • Likes 3 likes
  • Comments 1 comment
  • internet of things
  • avnet design
  • embedded computing
  • iot design
Related
Recommended

Adding GPS functionality to the BG96 on the Telus LTE-M IoT Starter Kit

james.flynn
james.flynn
14 Dec 2018


Previously, I developed an example program using the Telus LTE-M IoT Starter Kit (available from Avnet) using the Mbed O/S.  This effort is detailed in the Blog post https://www.element14.com/community/blogs/JimFlynn/2018/09/25/using-the-mbed-os-to-build-an-azure-iot-client.  Recently, a request was made to add GPS functionality to this solution and demonstrate how to add and use it. The Quectel BG96 has extensive GNSS functionality so I extend my previous example with a new one that adds GNSS support.image

 

The BG96 has extensive GNSS support (it supports geo-fencing which is pretty cool), but for this example, I limited the example to to simply obtaining and reporting the current GPS location.  Hopefully with the example software and BG96 documentation (BG96 documentation is available here) it wouldn't be to tough to add other capabilities if desired. For purposes of the example program, I obtain the GPS Location of the module and report it back to Azure with each telemetry message. 

 

Adding support for GNSS involved modifying the BG96 Device Driver (link) by adding functions to power the GNSS on/off and get the current GPS location (Lines 577 and 588 in the driver). I also added a class to allow access to the device driver.  The Mbed OS implements a 'NetworkInterface' class that is used by the operating system to interact with the driver but this class doesn't know anything about the added GNSS support, so I created a class (bg96_gps) that provides access to the GNSS functions.  It is a pretty simple class that only implements a gpsPower and gpsLocation capabilities using a pointer to the installed BG96 Driver.  If you wanted to add geo-fencing for example, you would simply add another set of functions to the class that implemented that along with the appropriate functions in the driver itself.

 

With the new gp96_gps class, using the GPS capabilities involves:

 

1. Creating the object and a structure for GNSS:

/* create the GPS elements for example program */
gps_data gdata; 
bg96_gps gps; 

 

2. Starting and obtaining the GNSS information:

    printf("[ start GPS ] ");
    gps.gpsPower(true);
    printf("Successful.\r\n[get GPS loc] ");
    fflush(stdout);
    gps.gpsLocation(&gdata);
    printf("Latitude = %6.3f Longitude = %6.3f date=%s, time=%6.0f\n\n",gdata.lat,gdata.lon,gdata.date,gdata.utc);

 

To power off the GNSS system, you would simply call gpsPower(false). The gps_data type is defined in the BG96 device driver as:

 

typedef struct gps_data_t {
    float utc;      //hhmmss.sss
    float lat;      //latitude. (-)dd.ddddd
    float lon;      //longitude. (-)dd.ddddd
    float hdop;     // Horizontal precision: 0.5-99.9
    float altitude; //altitude of antenna from sea level (meters) 
    int fix;        //GNSS position mode 2=2D, 3=3D
    float cog;      //Course Over Ground ddd.mm
    float spkm;     //Speed over ground (Km/h) xxxx.x
    float spkn;     //Speed over ground (knots) xxxx.x
    char date[7];   //data: ddmmyy
    int nsat;       //number of satellites 0-12
    } gps_data;

 

This structure contains all the information you will receive from a call for GPS Location data.

 

This newly released example is available from https://github.com/Avnet/azure-iot-mbed-client/releases  as release v1.1.  With this additional GPS functionality can add a new level of sensor data that can be reported and hopefully, some great new product opportunities.

  • Sign in to reply

Top Comments

  • ejeyaseelan
    ejeyaseelan over 4 years ago +1
    is there a way for the application to first make a connection to the Azure iot hub even when the gps is not quite ready? when firing up the gps, cold indoors, it can take upto 45 mins or more, for the…
  • ejeyaseelan
    ejeyaseelan over 4 years ago

    is there a way for the application to first make a connection to the Azure iot hub even when the gps is not quite ready?

     

    when firing up the gps, cold indoors, it can take upto 45 mins or more, for the initial connection to the cloud, wondering if there is an easier work around to this somehow.

     

    Or, during development time, maybe a flag can be set during compile time to inform the application to report fake or manual (default lattitude, longitdue on bootup) and once more than x number of satellites are reported in line of sight, or a guaranteed fix is obtained, the application starts to reporting that.

     

    also perhpas, a user button press, to notify the application to bypass waiting for a gps fix.

     

    all of that to say, once the app boots up, it makes an initial connection to cloud and sends out an initial heartbeat that its alive and well etc

     

    just an idea.

    • Cancel
    • Vote Up +1 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

  • X
  • Facebook
  • linkedin
  • YouTube