Skip to content

Resources for my Microsoft Student Summit Africa session on using GPS to track animals

License

Notifications You must be signed in to change notification settings

jimbobbennett/gps-animal-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPS animal tracker

This repo contains resources for my Microsoft Student Summit Africa session on using GPS to track animals.

Most of this repo is demo code, showing how to capture and decode data from a GPS sensor using Python and a Raspberry Pi. This code was tested using a Raspberry Pi 4, and a Seeed Grove GPS Air530 sensor connected via a Grove Base hat.

You can find instructions on setting up this hardware, and configuring Raspberry Pi OS in the Pi GPS sensor section of the location tracking project in the IoT for Beginners curriculum.

GPS data is received from the sensor over UART as NMEA sentences. You can learn more about this data in the location tracking project in the IoT for Beginners curriculum

Structure of this repo

This repo has the following code samples in it:

  • device/print-gps-data - Code to read NMEA sentences from the GPS sensor print them to the console
  • device/decode-gps-data - Code to read NMEA sentences from the GPS sensor and decode them to get latitude and longitude
  • device/send-gps-data - Code to read NMEA sentences from the GPS sensor, decode them to get latitude and longitude, then send this to Azure IoT Hub
  • functions - An example Azure Functions app that will listen to the events sent to Azure IoT Hub, and use these to build geospatial records that are then saved in CosmosDB

Using this code

Clone this repo onto your Raspberry Pi, and on your PC or Mac if you want to run the functions.

The first 2 demos (print-gps-data anf decode-gps-data) just require a Raspberry Pi set up with the Grove GPS sensor. The code folders contain a requirements.txt file that will need to be installed with Pip to install the relevant packages. When run, the code will output with NMEA sentences, or GPS coordinates, depending on which demo you ran.

To run the send-gps-data demo, you will need an instance of Azure IoT Hub. You can find instructions on creating this service in the Create an IoT Hub documentation. Once created, create a device and get the connection string. This then needs to be added to a file called .env in the same folder as this demo:

CONNECTION_STRING=<Your IoT Hub device connection string goes here>

When run this will capture GPS coordinates and send these to your IoT Hub.

Once send-gps-data is running, you can run the functions demo using the Azure Functions Core Tools. This demo needs an instance of Cosmos DB, and you can find instructions on creating this in the Create an Azure Cosmos account, database, container, and items documentation. Once the account is created, create a database called animals, and a container called locations, with the partition key set to /animalid.

You will need to set the following in the local.settings.json file:

{
    "IOT_HUB_CONNECTION_STRING": "<The event hub compatible endpoint for your IoT Hub>",
    "COSMOSDB_CONNECTION_STRING": "<The connection string for your CosmosDB account>"
}

Additional resources

About

Resources for my Microsoft Student Summit Africa session on using GPS to track animals

Topics

Resources

License

Stars

Watchers

Forks