The Internet of Things on AWS – Official Blog

Building a connected car physical prototype with AWS IoT services

The automotive industry is undergoing a remarkable transformation. Driven by software innovation, the concept of a car has transcended its traditional role as a mode of transportation. Vehicles are evolving into intelligent machines with advanced driver assistance systems (ADAS), sophisticated infotainment, and connectivity features. To power these advanced capabilities, car companies need to manage data from different sources, which requires a solution for collecting data at scale. This is where AWS IoT services come into play. Having the data in the cloud opens new possibilities like building data analysis tools, enabling predictive maintenance, or using the data to power generative AI services for the end user.

Solution overview

This post will guide you in using a Raspberry Pi-powered car model to build a scalable and enterprise-ready architecture for collecting data from a fleet of vehicles to fulfill the different use cases shown in figure 1.

Use cases

Figure 1 – Use cases

Overall architecture

Figure 2 shows a comprehensive overview of the full architecture:

overall architecture

Figure 2 – Overall architecture

Hardware and local controller

For the hardware, you will use this simple kit which provides all the mechanical and electronic components you need. A Raspberry Pi is also required. The instructions for building and testing the kit are available at the manufacturer’s website and will not be described in this blog post.

Smart car kit for Raspberry Pi

Figure 3 – Smart car kit for Raspberry Pi

The vehicle is controlled via a web interface written in React using WebSocket. In the local web app, it is possible to view the camera stream, adjust the speed, control the direction of movement, and control the lights. It’s also possible to use a game controller for a better driving experience.

local car controller

Figure 4 – Local car controller

The use of the physical prototype makes it possible to effectively simulate the capabilities of the services described above by demonstrating their applicability to the use cases in a practical way.

Data collection and visualization

The data generated by the vehicle is sent to the cloud via AWS IoT FleetWise using a virtual CAN interface.

Each data metric is then processed by a rule for AWS IoT and stored in Amazon Timestream. All the data is displayed in a dashboard using Amazon Managed Grafana.

Data collection

Figure 5 – Data collection

Walkthrough

All the detailed steps and the full code are available in this GitHub repository. We recommend that you download the full repo and follow the step-by-step approach described in the Readme.md file. In this article we describe the overall architecture and provide the commands for the main steps.

Prerequisites

  • An AWS account
  • AWS CLI installed
  • Smart car kit for Raspberry Pi
  • Raspberry PI
  • Basic knowledge of Python and JavaScript

Step 1: Hardware and local controller

You will install the software to control the car and the Edge Agent for AWS IoT FleetWise on the Raspberry Pi by completing the following steps. Detailed instruction are in the accompanying repo at point 6 of the Readme.md file.

  1. Set up the virtual CAN interface
  2. Build and install your Edge Agent for AWS IoT FleetWise
  3. Install the server and the application for driving and controlling the car

Architecture after Step 1

Figure 6 – Architecture after Step 1

Step 2: Basic cloud infrastructure

AWS CloudFormation is used to deploy all the necessary resources for Amazon Timestream and Amazon Managed Grafana. The template can be found in the accompanying repo inside the Cloud folder.

Architecture after Step 2

Figure 7 – Architecture after step 2

Deploy Amazon Managed Grafana (AWS CLI)

The first component you will deploy is Amazon Managed Grafana, which will host the dashboard showing the data collected by AWS IoT FleetWise.

In the repository, in the “Cloud/Infra” folder you will use the CloudFormation 01-Grafana-Instance.yml template to deploy the resources using the following command:

aws cloudformation create-stack \
--stack-name macchinetta-grafana-instance \
--template-body file://01-Grafana-Instance.yml \
--capabilities CAPABILITY_NAMED_IAM

Once CloudFormation has reached the CREATE_COMPLETE state, you should see the new Grafana workspace.

Amazon Managed Grafana Workspace

Figure 8 – Amazon Managed Grafana workspace

Deploy Amazon Timestream (AWS CLI)

Amazon Timestream is a fully managed time series database capable of storing and analysing trillions of time series data points per day. This service will be the second component you deploy that will store data collected by AWS IoT FleetWise.

In the repository, in the “Cloud/Infra” folder you will use the 02-Timestream-DB.yml template to deploy the resources using the following command:

aws cloudformation create-stack \
--stack-name macchinetta-timestream-database \
--template-body file://02-Timestream-DB.yml
--capabilities CAPABILITY_NAMED_IAM

Once CloudFormation has reached the CREATE_COMPLETE state, you should see the new Timestream table, database, and related role that will be used by AWS IoT FleetWise.

Step 3: Setting up AWS IoT Fleet

Now that we’ve set up the infrastructure, it’s time to define the signals to collect and configure AWS IoT FleetWise to receive your data. Signals are basic structures that you define to contain vehicle data and its metadata.

For example, you can create a signal that represents the battery voltage of your vehicle:

Signal definition
-	Type: 				 Sensor
-	Data type: 			 float32
-	Name: 				 Voltage
-	Min:				 0 		
-	Max:				 8
-	Unit:				 Volt 
-	Full qualified name: Vehicle.Battery.Voltage

This signal is used as standard in automotive applications to communicate semantically well-defined information about the vehicle. Model your prototype car according to the VSS specification. This is the structure you will use in the prototype. This structure is coded as json in the signals.json file in the Cloud/Fleetwise folder in the repo.

Vehicle model in VSS format

Figure 9 – Vehicle model in VSS format

Step 1: Create the signal catalog (AWS CLI)

  1. Use the following command using the structure coded into signals.json as described above.
aws iotfleetwise create-signal-catalog --cli-input-json file://signals.json
  1. Copy the ARN returned by the command.

If you open the AWS console on the AWS IoT FleetWise page and select the Signal catalog section from the navigation panel, you should see the newly created Signal catalog.

Signal Catalog

Figure 10 – Signal catalog

Step 2: Create the vehicle model

The vehicle model that helps standardize the format of your vehicles and enforces consistent information across multiple vehicles of the same type.

  1. Open the file json and replace the <ARN> variable with the ARN copied in the previous command.
  2. Execute the command :
    aws iotfleetwise create-model-manifest --cli-input-json file://model.json
  3. Copy the ARN returned by the command.
  4. Execute the command:
    aws iotfleetwise update-model-manifest --name  <name of the model> --status ACTIVE

If you open the AWS console on the AWS IoT FleetWise page and select the Vehicle models section from the navigation panel, you should see the newly created vehicle model.

Vehicle model: Signals

Figure 11 – Vehicle model: Signals

Step 3: Create the decoder manifest

The decoder manifest allows the decoding of binary signals from the vehicle to be decoded into a human readable format. Our prototype uses the CAN bus protocol. These signals must be decoded from a CAN DBC (CAN Database) file, which is a text file containing information for decoding raw CAN bus data.

  1. Open the file decoder.json and replace the <ARN> variable with the ARN copied in the previous command.
  2. Execute the command to create the model:
    aws iotfleetwise create-model-manifest --cli-input-json file://model.json
  3. Execute the command to enable the decoder:
    aws iotfleetwise update-decoder-manifest --name <name of the decoder> --status ACTIVE

If you open the AWS console on the AWS IoT FleetWise page and select the Vehicle models section from the navigation panel, you should see the newly created decoder manifest.

Vehicle model: Signals

Figure 12 – Vehicle model: SignalsDecoder Manifest

Step 4: Create the vehicle(s)

AWS IoT FleetWise has its own vehicle construct, but the underlying resource is an AWS IoT Core thing, which is a representation of a physical device (your vehicle) that contains static metadata about the device.

  1. Open the AWS console on the AWS IoT FleetWise page
  2. In the navigation panel, choose Vehicle
  3. Choose Create vehicle
  4. Select the vehicle model and associated manifest from the list boxes

Vehicle properties

Figure 13 – Vehicle properties

Step 5: Create and deploy a campaign

A campaign instructs the AWS IoT FleetWise Edge Agent software on how to select and collect data, and where in the cloud to transmit it.

  1. Open the AWS console on the AWS IoT FleetWise page
  2. In the navigation panel, choose Campaigns
  3. Choose Create Campaign
  4. For Scheme type, choose Time-based
  5. For campaign duration, choose a consistent time period
  6. For Time period enter 10000
  7. For Signal name select the Actual Vehicle Speed
  8. For Max sample count select 1
  9. Repeat steps 7 and 8 for all the other signals
  10. For Destination select Amazon Timestream
  11. For Timestream database name select macchinettaDB
  12. For Timestream table name select macchinettaTable
  13. Choose Next
  14. For Vehicle name select macchinetta
  15. Choose Next
  16. Review and choose Create

Figure 14 – Create and deploy a campaign

Once deployed, after few seconds, you should see the data inside the Amazon Timestream table

Amazon TimeStream

Figure 15 – Amazon Timestream table

Once data is stored into Amazon Timestream, it can be visualized using Amazon Managed Grafana.

Amazon Managed Grafana is a fully managed service for Grafana, a popular open source analytics platform that lets you query, visualise, and alert on your metrics.

You use it to display relevant and detailed data from a single vehicle on a dashboard:

Amazon Grafana

Figure 16 – Amazon Managed Grafana

Clean Up

Detailed instructions are in the accompanying repo at the end of the Readme.md file.

Conclusion

This solution demonstrates the power of AWS IoT in creating a scalable architecture for vehicle fleet data collection and management. Starting with a Raspberry Pi-powered car prototype, we’ve shown how to address key automotive industry use cases. However, this is just the beginning, the prototype is designed to be modular and extended with new capabilities. Here are some exciting ways to expand the solution:

Fleet Management Web App: Develop a comprehensive web application using AWS Amplify to monitor an entire fleet of vehicles. This app could provide a high-level view of each vehicle’s health status and allow for detailed individual vehicle analysis.

Live Video Streaming: Integrate Amazon Kinesis Video Streams libraries into the Raspberry Pi application to enable real-time video feeds from vehicles.

Predictive Maintenance: Leverage the data collected through AWS IoT FleetWise to build predictive maintenance models, enhancing fleet reliability and reducing downtime.

Generative AI Integration: Explore the use of generative AI services like Amazon Bedrock to generate personalized content, predict user behavior, or optimize vehicle performance based on collected data.

Ready to take your connected vehicle solution to the next level? We invite you to:

  • Explore Further: Dive deeper into AWS IoT services and their applications in the automotive industry. Visit the AWS IoT documentation to learn more.
  • Get Hands-On: Try building this prototype yourself using the detailed instructions in our GitHub repository.
  • Connect with Experts: Have questions or need guidance? Reach out to our AWS IoT specialists.
  • Join the Community: Share your experiences and learn from others in the AWS IoT Community Forum.

About the Authors

Leonardo Fenu is a Solutions Architect, who has been helping AWS customers align their technology with their business goals since 2018. When he is not hiking in the mountains or spending time with his family, he enjoys tinkering with hardware and software, exploring the latest cloud technologies, and finding creative ways to solve complex problems.

Edoardo Randazzo is a Solutions Architect specialized in DevOps and cloud governance. In his free time, he likes to build IoT devices and tinker with gadgets, either as a potential path to the next big thing or simply as an excuse to buy more Lego.

Luca Pallini is a Sr. Partner Solutions Architect at AWS, helping partners excel in the Public Sector. He serves as a member of the Technical Field Community (TFC) at AWS, specializing in databases, particularly Oracle Database. Prior to joining AWS, he accumulated over 22 years of experience in database design, architecture, and cloud technologies. In his spare time, Luca enjoys spending time with his family, hiking, reading, and listening to music.