Skip to main content

One post tagged with "AWS IoT Core"

View All Tags

Watch Your Fleet Move LIVE - Asset Tracking with Amazon Location & IoT Core

ยท 6 min read
Cloud & AI Engineering
Arina Technologies
Cloud & AI Engineering

Asset tracking is essential in modern logistics and supply chain operations. Knowing where assets such as trucks or delivery vehicles are located can significantly enhance operational efficiency, reduce costs, and prevent losses. In this detailed walkthrough, we'll explore Amazon Location Service, its use cases, and how to set up a fully functional asset tracking application integrated with AWS IoT Core.


๐ŸŽฏ What is Amazon Location?โ€‹


Amazon Location is a managed service from AWS that allows developers to add location data and functionality such as maps, geocoding, routing, geofencing, and tracking into their applications. It sources data from trusted global providers like Esri, HERE, and OpenStreetMap.


Key Features:โ€‹


  1. Maps & Geospatial Visualization
  2. Real-Time Tracking
  3. Geofence Monitoring
  4. Cost-effective location solutions

Use cases include:


  1. Fleet tracking
  2. Delivery route optimization
  3. Asset protection
  4. Consumer app geolocation

๐Ÿ“Œ Use Casesโ€‹


Geofencing and Proximity-Based Alertsโ€‹


  1. Use Case: Setting up virtual boundaries (geofences) around specific areas and triggering actions or notifications when devices or users enter or exit these zones.
  2. Benefit: Security alerts (e.g., unauthorized entry into a restricted area), location-based marketing (e.g., promotional offers to customers), and workflow automation (e.g., clocking in/out field employees). A retail store could notify users when they enter a geofence around the store.

Real-time Asset Tracking and Managementโ€‹


  1. Use Case: Businesses with fleets of vehicles, equipment, or personnel can track their real-time locations on a map.
  2. Benefit: Improved operational efficiency, optimized routing, enhanced security, and better resource allocation. For example, dispatching the nearest available driver for a delivery.

Route Planning and Optimizationโ€‹


  1. Use Case: Calculating optimal routes for navigation considering traffic, road closures, and preferred transport modes.
  2. Benefit: Reduced travel time, lower fuel costs, improved delivery efficiency, and better user guidance.


๐Ÿงฑ Architecture Overviewโ€‹


To better understand the technical setup and flow, let's break down the detailed architecture used in this asset tracking solution. This architecture not only supports real-time tracking but also historical location data, scalable device input, and geofence event handling.


Core Components:โ€‹


  1. Amazon Location Service: Provides maps, geofences, and trackers.
  2. AWS IoT Core: Acts as the entry point for location data using MQTT.
  3. Amazon Kinesis Data Streams: Streams live device location data for processing.
  4. AWS Lambda: Used for transforming data and invoking downstream services like Amazon Location or notifications.
  5. Amazon SNS: Sends real-time alerts or notifications to subscribed users (e.g., when a geofence is breached).
  6. Amazon Cognito: Authenticates users for frontend access and API interactions.
  7. Amazon CloudFront + S3: Hosts the web-based frontend application securely and globally.

Data Flow:โ€‹


  1. A GPS-enabled device or simulation sends a location update to AWS IoT Core using MQTT.
  2. The update is routed to Kinesis Data Streams for real-time processing.
  3. An AWS Lambda function processes the Kinesis records and forwards the location to the Amazon Location Tracker.
  4. If the location triggers a geofence event, another Lambda function can be used to publish a message to Amazon SNS.
  5. SNS sends out a notification to subscribers, such as mobile users, application dashboards, or administrators.
  6. The frontend web application, hosted on S3 + CloudFront, visualizes live and historical positions by querying Amazon Location services directly using the credentials from Amazon Cognito.

The architecture consists of Amazon Location for geospatial services, AWS Lambda for processing events, and Amazon SNS to send notifications to end users.


Sample Architecture Diagram


๐Ÿ›  Setting Up the Projectโ€‹


To demonstrate Amazon Location's capabilities, we'll build a web application that displays current and historical locations of assets. We'll simulate an IoT device and stream location updates to AWS using MQTT.


1. Clone the Sample Projectโ€‹


git clone https://github.com/aws-solutions-library-samples/guidance-for-tracking-assets-and-locating-devices-using-aws-iot.git --recurse-submodules
cd guidance-for-tracking-assets-and-locating-devices-using-aws-iot

2. Install Frontend Dependenciesโ€‹


cd amazon-location-samples-react/tracking-data-streaming
npm install

3. Deploy Location Infrastructureโ€‹


chmod +x deploy_cloudformation.sh && export AWS_REGION=<your region> && ./deploy_cloudformation.sh

4. Deploy IoT Core Resourcesโ€‹


cd ../../cf
aws cloudformation create-stack --stack-name TrackingAndGeofencingIoTResources \
--template-body file://iotResources.yml \
--capabilities CAPABILITY_IAM

๐Ÿ–ผ Configuring the Frontendโ€‹


Get the CloudFormation stack outputs:


aws cloudformation describe-stacks \
--stack-name TrackingAndGeofencingSample \
--query "Stacks[0].Outputs[*].[OutputKey, OutputValue]"

Set values in configuration.js accordingly:


export const READ_ONLY_IDENTITY_POOL_ID = "us-east-1:xxxx...";
export const WRITE_ONLY_IDENTITY_POOL_ID = "us-east-1:xxxx...";
export const REGION = "us-east-1";
export const MAP = {
NAME: "TrackingAndGeofencingSampleMapHere",
STYLE: "VectorHereExplore"
};
export const GEOFENCE = "TrackingAndGeofencingSampleCollection";
export const TRACKER = "SampleTracker";
export const DEVICE_POSITION_HISTORY_OFFSET = 3600;
export const KINESIS_DATA_STREAM_NAME = "TrackingAndGeofencingSampleKinesisDataStream";

Start the frontend locally:

npm start

Navigate to http://localhost:8080 to see your live map.


๐ŸŒ Hosting on CloudFrontโ€‹


1. Create S3 Bucketโ€‹


  1. Go to S3 Console > Create Bucket
  2. Use a unique bucket name

2. Build Frontendโ€‹


npm run build

3. Upload to S3โ€‹


aws s3 cp ./build s3://<your-bucket-name>/ --recursive

4. Create CloudFront Distributionโ€‹


  1. Origin: S3 Bucket
  2. Create a new OAC (Origin Access Control)
  3. Enable WAF protections

5. Update S3 Bucket Policyโ€‹


Paste in the policy suggested by CloudFront for the OAC.


Access your site at:


https://<your-distribution>.cloudfront.net/index.html

๐Ÿ”„ Extend with Real Devicesโ€‹


This tutorial used MQTT message simulation. For real-world scenarios:

  1. Use GPS-enabled IoT devices
  2. Integrate with certified hardware listed in the AWS Partner Device Catalog

โœ… Summaryโ€‹


In this blog, we:

  1. Introduced Amazon Location Service
  2. Simulated IoT data with AWS IoT Core
  3. Visualized tracking in a React app
  4. Hosted it with Amazon S3 + CloudFront

This powerful combination enables real-time tracking for logistics, delivery, field ops, and more.


๐Ÿ™Œ Final Thoughtsโ€‹


Whether you are building internal logistics tools or customer-facing tracking apps, Amazon Location and AWS IoT Core offer a scalable, cost-effective foundation. Try building this project and tailor it to your business use case!


๐Ÿ”š Call to Actionโ€‹


Choosing the right platform depends on your organizations needs. For more insights, subscribe to our newsletter for insights on cloud computing, tips, and the latest trends in technology. or follow our video series on cloud comparisons.


Need help launching your app on AWS? Visit arinatechnologies.com for expert help in cloud architecture.


Interested in having your organization setup on cloud? If yes, please contact us and we'll be more than glad to help you embark on cloud journey.


๐Ÿ’ฌ Comment below:
How do you plan to use Amazon Locations?