<h2>Introduction</h2><p>Automakers, fleet operators, and automotive suppliers are recognizing the potential of vehicle data to transform their business models and optimize their operations. However, implementing data-driven use cases is often challenging. Proprietary vehicle data formats, high costs of data ingestion and implementation complexity can slow down innovation.<a href="https://aws.amazon.com/iot-fleetwise/">AWS IoT FleetWise</a> is a service that makes it easier for automakers to collect, transform, and transfer vehicle data to the cloud. Once transferred, customers can use breadth and depth of AWS <a href="https://aws.amazon.com/big-data/datalakes-and-analytics/">analytics</a> and <a href="https://aws.amazon.com/machine-learning/">machine learning</a> services to extract value from the vehicle data. If you have no previous experience with AWS IoT FleetWise, please consider starting with the blog <a href="https://aws.amazon.com/blogs/iot/generating-insights-from-vehicle-data-with-aws-iot-fleetwise-part1/">Generating insights from vehicle data with AWS IoT FleetWise.</a> You will learn about use cases, technical capabilities, and a logical architecture for AWS IoT FleetWise. In the same blog, we also introduced an Electric Vehicle (EV) battery monitoring solution.</p><p>This post will walk you through building that EV battery monitoring solution with AWS IoT FleetWise. First, you will deploy an EV simulation on an <a href="https://aws.amazon.com/ec2/">Amazon Elastic Compute Cloud (Amazon EC2)</a> instance in your AWS account. Then, you will configure AWS IoT FleetWise to collect, transform, transfer, and store the CAN bus signals from the vehicle. Finally, you will query the collected data using the <a href="https://aws.amazon.com/timestream/">Amazon Timestream</a> service.</p><h2>Use case</h2><p>Lithium-ion batteries (LiBs) are widely used as energy storage systems for EVs. When operating EV fleets, continuous monitoring and protection of battery cells is an important consideration.</p><p>For EV manufacturers and fleet operators, the ability to detect and predict battery issues such as overcurrent, overcharge or overheating is crucial. For example, it can improve efficiency and safety of fleet operations by enabling timely planning for battery replacement. Another example is that it allows EV manufacturers to collaborate with battery suppliers on battery improvement initiatives, by evaluating the conditions of the battery in different scenarios.</p><p>The purpose of this blog is to demonstrate how you can use AWS IoT FleetWise to collect and transfer BMS parameters to the cloud. For that purpose, we will use an example of overcurrent detection use-case. After the data is transferred, it will be stored in a database, ready to be used for monitoring, alarming and ML model traning.</p><h2>Solution architecture</h2><p>The following diagram shows the architecture of the solution. We also indicate the scope of this blog post, that we will implement following the step-by-step walkthrough. The remaining part of the architecture will be covered in part 2 of this blog series.</p><div id="attachment_9825" class="wp-caption alignleft c4"><img aria-describedby="caption-attachment-9825" class="size-large wp-image-9825" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/09/image001-1-1024x590.png" alt="Solution Architecture" width="1024" height="590" /><p id="caption-attachment-9825" class="wp-caption-text">Solution Architecture</p></div><p>Please refer to <a href="https://aws.amazon.com/blogs/iot/generating-insights-from-vehicle-data-with-aws-iot-fleetwise-part1/">the previous part of this blog series</a> for a detailed description of the solution architecture.</p><h2>Implementation approach</h2><p>The following sample implementation utilizes two vehicles and two data collection campaigns.</p><h3>Vehicles</h3><p>The vehicles will be simulated by one Amazon EC2 instance each. The EC2 instance will run a <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/simulatedvehicle/canreplay/bin/can_replay.py">script generating CAN bus messages</a> to simulate BMS. Both vehicles will intentionally use slightly different CAN signal encodings to demonstrate the ability of AWS IoT FleetWise to provide unified access to heterogeneous vehicle fleets.</p><p><em>Side remark</em><strong>:</strong> the vehicle simulation can be easily adopted to reproduce any previously recorded CAN or OBD-II signals on a simulated environment. This can be useful in a prototyping phase of solutions based on AWS IoT FleetWise. For example, you could record CAN data from your vehicles using the tool of your choice. Once recorded, you could replay the vehicle data on a simulated environment for AWS IoT FleetWise testing. You can learn more about simulating your own vehicle data in <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/tree/main/simulatedvehicle/canreplay">the GitHub repository</a> .</p><h3>Data collection campaigns</h3><p>To learn how to configure the data collection features of AWS IoT FleetWise, you will set up two data collection campaigns:</p><ul><li>A data collection campaign for continuous, low frequency (1 second sampling rate) monitoring of EV battery pack current and battery cell temperature. For the sake of simplicity, we will include only one single battery cell in our example.</li><li>A conditional data collection campaign to collect a high-resolution (50 ms sampling rate) snapshot of multiple Battery Management System (BMS) signals. This campaign will only collect data under condition that the shunt current (represented by the signal <code>EVBatterySample.BMS.BatteryPack01.ShuntPlusCurrent_a</code>) is above 450 amperes, i.e. in overcurrent scenario.</li></ul><h2>Introducing the AWS IoT FleetWise logical data model</h2><p>To deploy a solution based on AWS IoT FleetWise, you will configure data collection, transformation, and transfer from your vehicle fleet. AWS IoT FleetWise provides <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_Operations.html">APIs</a> to achieve that. You can invoke these APIs by using the AWS Management Console, AWS SDKs, or AWS CLI.</p><p>Most of the APIs you will use in this blog follow the CRUD (Create, Read Update, Delete) paradigm. For example, you can use the API action <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_CreateCampaign.html#iotfleetwise-CreateCampaign-request-dataExtraDimensions">CreateCampaign</a> to configure a new data collection campaign, or <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_UpdateCampaign.html">UpdateCampaign</a> to change the status of the campaign.</p><p>The CRUD operations refer to the following key elements of the logical data model of AWS IoT FleetWise: <strong>Signal Catalog</strong>, <strong>Vehicle Model</strong>, <strong>Campaign</strong>, <strong>Vehicle</strong>, <strong>Fleet</strong> and <strong>DecoderManifest</strong>. The following diagram introduces these elements and explains their relationships:</p><div id="attachment_9822" class="wp-caption alignleft c4"><img aria-describedby="caption-attachment-9822" class="size-large wp-image-9822" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/09/image002-1-1024x551.png" alt="Logical data model" width="1024" height="551" /><p id="caption-attachment-9822" class="wp-caption-text">Logical data model of AWS IoT FleetWise</p></div><p>Please follow the guidelines in this blog to learn how to create each of these data model elements using the <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/Welcome.html">AWS IoT FleetWise APIs</a> .</p><p>In this blog you will use AWS CLI to interact with AWS IoT FleetWise APIs. You can also use the <a href="https://console.aws.amazon.com/iotfleetwise/home?region=us-east-1#/">AWS IoT FleetWise Management console</a> to manage AWS IoT FleetWise.</p><h2>Deploying the solution</h2><h3>Open AWS CloudShell</h3><p>Please click on <a href="https://console.aws.amazon.com/cloudshell/home">this link</a> to open <a href="https://aws.amazon.com/cloudshell/">AWS CloudShell</a> (a browser-based shell). Please ensure to change your AWS region to one of the regions supported by AWS IoT FleetWise (e.g. Europe Frankfurt or US East Virginia).</p><h3>Clone the repository</h3><p>Please clone the GitHub repository with the resources for this blog by running the following commands:</p><div><pre class="lang-bash">git clone https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring</pre></div><h3>Create Amazon EC2 keypair</h3><p>Please run the following command to create and store a new Amazon EC2 keypair. You will use it to establish an SSH connection to an Amazon EC2 instance with vehicle simulation in a later step.</p><div><pre class="lang-bash">aws ec2 create-key-pair --key-name fleetwiseblogec2key | \jq -r .KeyMaterial > fleetwiseblogec2key.pemchmod 0600 fleetwiseblogec2key.pem</pre></div><h3>Deploy a solution for vehicle simulation</h3><p>In this step, you will deploy an <a href="https://aws.amazon.com/cloudformation/">AWS CloudFormation</a> stack to set up the simulation for two vehicles. This stack will provision the required resources in your AWS account.</p><p><em><strong>Deploying this solution may incur costs on your AWS bill, e.g., for Amazon EC2, AWS IoT and Amazon Timestream services. Please remember to remove these resources by deleting the AWS CloudFormation stack to avoid unintended costs. You will find instructions for deleting the stack at the end of this blog.</strong></em></p><div><p>Please change the directory:</p><pre class="lang-bash">cd aws-iot-fleetwise-evbatterymonitoring</pre><p>Please deploy the stack.</p><pre class="lang-bash">aws cloudformation deploy --template-file simulatedvehicle/ec2simulation/template.yaml --stack-name vehiclesimulation --disable-rollback --parameter-overrides Ec2KeyPair=fleetwiseblogec2key IoTCoreRegion=$AWS_REGION --capabilities "CAPABILITY_NAMED_IAM"</pre></div><p>Please continue with the guidelines of this blog while the deployment of AWS CloudFormation stack runs (approx. 20 minutes). If you experience problems with the stack deployment, please consider <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/troubleshooting.md">the troubleshooting guidelines</a>.</p><p>You can use “New tab” function in AWS CloudShell “Actions” menu to create a new tab for next steps .</p><h3>Configure CLI</h3><p>To use AWS CLI v2 to access AWS IoT FleetWise, complete the following steps to configure the AWS CLI model.</p><pre class="lang-bash">wget https://docs.aws.amazon.com/iot-fleetwise/latest/developerguide/\samples/iotfleetwise-preview.zipunzip iotfleetwise-preview.zipaws configure add-model --service-name iotfleetwise \ --service-model file://iotfleetwise-preview.json</pre><h3>Create AWS CLI input files</h3><p>To improve the readability of this blog, we will provide input to <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html">AWS CLI</a> commands in JSON format. To create these JSON files specialised for your account and region, run the following commands which will do that task for you:</p><div><pre class="lang-bash">cd ~/aws-iot-fleetwise-evbatterymonitoring/cloud./prepare_templates.shcd cli-inputs</pre></div><h3>Create an AWS IAM role</h3><p>First, we will create an <a href="https://aws.amazon.com/iam/">AWS Identity and Access Management (IAM)</a> role for the AWS IoT FleetWise service with the right permissions to write to the Amazon Timestream database:</p><div><pre class="lang-bash">aws iam create-role --role-name AWSIoTFleetWiseServiceRole\ --assume-role-policy-document file://1_setup/trustpol.jsonaws iam create-policy --policy-name AWSIoTFleetwiseIAMUserPolicy \ --policy-document file://1_setup/policy.jsonaws iam attach-role-policy --cli-input-json file://1_setup/policy_attach.json</pre><p>Please review the AWS IAM role <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/1_setup/policy.json">policy</a> to learn more about the necessary permissions.</p><h3>Initial AWS IoT FleetWise configuration</h3><p>In this step, you configure AWS IoT FleetWise with the IAM role you created earlier and the Amazon Timestream database and table names. You need to perform this configuration once for the respective AWS region before you can use AWS IoT FleetWise.</p><div><pre class="lang-bash">aws iotfleetwise register-account \ --cli-input-json file://1_setup/account_registration.json# Check if registration is successfullaws iotfleetwise get-register-account-status</pre></div><p>You can learn more about the initial configuration by reviewing the input file <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/1_setup/account_registration.json">account_registration.json</a> . Please review to <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_RegisterAccount.html">RegisterAccount</a> API for details.</p><h3>Create signal catalog</h3><p>The <strong>signal catalog</strong> is a definition of standardized vehicle signals. To create a new signal catalog, please run the following command:</p><div><pre class="lang-bash">aws iotfleetwise create-signal-catalog\ --cli-input-json file://2_signal_catalog/create-signal-catalog.json</pre></div><p>You can learn about the structure of the signal catalog by reviewing the input file <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/2_signal_catalog/create-signal-catalog.json">create-signal-catalog.json</a> . Please refer to the <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_CreateSignalCatalog.html">CreateSignalCatalog</a> API for details.</p><h3>Create vehicle model manifest</h3><p>Let’s review the concept of a vehicle model in AWS IoT FleetWise. The purpose of vehicle model is to enforce consistent data structure across multiple vehicles of the same type, so that you can process data from fleets of vehicles. With AWS IoT FleetWise, we use the term “signal” referring to the vehicle data.</p><p>For example, a fleet operator may have a fleet of two vehicles types – EVs and electric scooters. Both EVs and scooters may generate some common data (also called “vehicle signals”). An example for that is “current vehicle speed”. However, the EVs may generate signals which are not applicable for the scooters, for example tire pressure. To differentiate between data schemas for EVs and electric scooter, the fleet operator can create two vehicle models in AWS IoT FleetWise.</p><p>The <strong>model manifest</strong> formally describes the schema of the data to be collected from a specific type of vehicle. Please review the model manifest examples in files <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/3_model_manifest/vehicle-model1.json">vehicle-model1.json</a> and <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/3_model_manifest/vehicle-model2.json">vehicle-model2.json</a> .</p><p>Please note that a newly created model manifest must be activated before further use. Once activated, no further changes of the model manifest are possible. To create and activate model manifests for two vehicle models, please run the following commands.</p><pre class="lang-bash"># Model 1aws iotfleetwise create-model-manifest\ --cli-input-json file://3_model_manifest/vehicle-model1.jsonaws iotfleetwise update-model-manifest --status ACTIVE --name blog-modelmanifest-01# Model 2aws iotfleetwise create-model-manifest\ --cli-input-json file://3_model_manifest/vehicle-model2.jsonaws iotfleetwise update-model-manifest --status ACTIVE --name blog-modelmanifest-02</pre><p>Please refer to the <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_CreateModelManifest.html">CreateModelManifest</a> documentation for details.</p><p>Please note that while there is overlap between the signals for both models, some signals are only available for the specific model. For example, “EVBatterySample.BMS.Relay01.Status” is only available for the <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/3_model_manifest/vehicle-model1.json#L13">first model</a>, not the <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/3_model_manifest/vehicle-model2.json#L13">second model</a>. This is to demonstrate how you can model heterogeneous vehicle fleets while providing consistent access to the common signals.</p><h3>Create decoder manifest</h3><p>The decoder manifest describes the decoding rules for signals of a particular vehicle. To create and activate decoder manifests, please run the following commands:</p><pre class="lang-bash"># Decoder manifest 1aws iotfleetwise create-decoder-manifest\ --cli-input-json file://4_decoder_manifest/decoder-manifest1.jsonaws iotfleetwise update-decoder-manifest --status ACTIVE --name blog-decodermanifest-01# Decoder manifest 2aws iotfleetwise create-decoder-manifest\ --cli-input-json file://4_decoder_manifest/decoder-manifest2.jsonaws iotfleetwise update-decoder-manifest --status ACTIVE --name blog-decodermanifest-02</pre><p>You can learn about the model manifest by reviewing the input files <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/4_decoder_manifest/decoder-manifest1.json">decoder-manifest1.json</a> and <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/4_decoder_manifest/decoder-manifest2.json">decoder-manifest2.json</a>.</p><p>Please note that encoding for the signal “EVBatterySample.BMS.BatteryPack01.ShuntPlusCurrent_a” is different between <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/4_decoder_manifest/decoder-manifest1.json#L137">the first</a> and <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/4_decoder_manifest/decoder-manifest2.json#L138">the second</a> decoder manifest. This is to demonstrate how AWS IoT FleetWise creates an abstraction of decoding from the vehicle model. This allows you to handle different encodings while providing consistent access to vehicle signals.</p><p>Please review <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_DeleteDecoderManifest.html">CreateDecoderManifest</a> API for details. Please note that you can also use the <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_ImportDecoderManifest.html">ImportDecoderManifest</a> API to create a decoder manifest using a DBC file.</p><h3>Create a vehicle</h3><p>The vehicle is an instance of a vehicle model, representing a physical vehicle. To create vehicles, please run the following commands:</p><pre class="lang-bash">aws iotfleetwise create-vehicle --cli-input-json file://5_vehicle/vehicle01.jsonaws iotfleetwise create-vehicle --cli-input-json file://5_vehicle/vehicle02.json</pre><p>You can learn about the vehicle by reviewing the input files <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/5_vehicle/vehicle01.json">vehicle01.json</a> and <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/5_vehicle/vehicle02.json">vehicle02.json</a> . Please review the <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_CreateVehicle.html">CreateVehicle</a> API for details.</p><h3>Create a fleet and associate vehicles with the fleet</h3><p>With AWS IoT FleetWise, you can target a campaign either towards a specific vehicle or a fleet, i.e. a set of vehicles. To create an example fleet and associate both vehicles with the fleet, please run the following commands:</p><pre class="lang-bash">aws iotfleetwise create-fleet --cli-input-json file://6_fleet/fleet.jsonaws iotfleetwise associate-vehicle-fleet --fleet-id blog-fleet\ --vehicle-name blog-vehicle-01aws iotfleetwise associate-vehicle-fleet --fleet-id blog-fleet\ --vehicle-name blog-vehicle-02</pre><p>You can learn about the fleet by reviewing the input file <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/6_fleet/fleet.json">fleet.json</a> . Please review the <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_CreateFleet.html">CreateFleet</a> and <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_AssociateVehicleFleet.html">AssociateVehicleFleet</a> API for details.</p><h3>Initiate data collection campaigns</h3><p>In this section, you will implement two typical use cases for vehicle data collection. For this purpose, you will create two data collection campaigns.</p><p>To initiate a data collection campaign with AWS IoT FleetWise, create a new campaign by calling <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_CreateCampaign.html">CreateCampaign API</a> and then approve the campaign calling <a href="https://docs.aws.amazon.com/iot-fleetwise/latest/APIReference/API_UpdateCampaign.html">UpdateCampaign API</a> . By approving the campaign, you instruct AWS IoT FleetWise to send the configuration for data collection campaigns and decoders to the vehicles. Based on this configuration, the AWS IoT FleetWise Edge Agent starts collecting, transforming, and transferring data to the AWS.</p><p>Let us take a look at the individual campaigns.</p><p><strong>Campaign 1: continuously collect battery pack current and cell temperature</strong></p><p>This campaign will use a time-based collection scheme, i.e. the Edge Agent will continuously collect vehicle data and transfer it to the cloud in the specified time period. To create this campaign, please run the following commands:</p><pre class="lang-bash">aws iotfleetwise create-campaign \ --cli-input-json file://7_campaign/continious-monitoring-campaign.json# Please wait 15 seconds before running the next command to allow for campaign creation to completeaws iotfleetwise update-campaign --action APPROVE\ --name continious-monitoring-campaign</pre><p>You can learn more about this campaign by reviewing <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/7_campaign/continious-monitoring-campaign.json">continious-monitoring-campaign</a> .</p><p><strong>Campaign 2: conditionally collect a high-resolution (50 ms sampling rate) snapshot of multiple Battery Management System (BMS) signals.</strong></p><p>An example of a use case for this campaign is the analysis of potential problems with the battery packs of a pre-production vehicle fleet. To perform an analysis, vehicle quality engineers may need a high-resolution snapshot for multiple signals (e.g., temperature development of specific battery cells). However, let us assume that the vehicle engineers are only interested in the data if overcurrent event occurs.</p><p>To implement this use case, you will create a campaign with a condition-based collection scheme. The Edge Agent will evaluate an expression that you can define (for example, <code>$variable.EVBatterySample.BMS.BatteryPack01.ShuntPlusCurrent_a
> 450.0</code>). Only if this expression evaluates to true does the Edge Agent collect vehicle data and transfer it to the cloud.</p><p>To create this campaign, please run the following commands:</p><pre class="lang-bash">aws iotfleetwise create-campaign\ --cli-input-json file://7_campaign/conditional-snapshot-campaign.json# Please wait 15 seconds before running the next command to allow for campaign creation to completeaws iotfleetwise update-campaign --action APPROVE\ --name conditional-snapshot-campaign</pre><p>You can learn more about this campaign by reviewing <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/7_campaign/conditional-snapshot-campaign.json">conditional-snapshot-campaign.json</a> .</p><h2>Testing the solution</h2><p>You have successfully deployed a simulation and configured the AWS IoT FleetWise service. Now it’s time to see the overall solution in action. Please follow the instructions below.</p><h3>Step 1: Connect to the simulated vehicle</h3><p>In this step, you will connect to the Amazon EC2 instance that simulates the vehicle. You will then review the output of two software components: Edge Agent and the CAN bus simulation script. Please complete the following steps:</p><p><strong>1. Get the output of the stack</strong></p><pre class="lang-bash">aws cloudformation describe-stacks \ --stack-name vehiclesimulation \ --query "Stacks[0].Outputs[?OutputKey=='Ec2Instance1SSH'].OutputValue" \ --output text</pre><p>If you see “None” as output, it means that stack deployment has not completed yet. Please retry in few minutes. If you experience problems with the stack deployment, please consider <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/troubleshooting.md">the troubleshooting guidelines</a>.</p><p><strong>2. SSH into the Amazon EC2 instance</strong>Please copy and paste the SSH command from the stack output above and run it. When asked if you want to connect to the instance, please confirm with “yes”:</p><pre class="lang-bash">ssh -i ~/fleetwiseblogec2key.pem ubuntu@<Value of Vehicle1EC2PublicIP></pre><p><strong>3. View CAN messages</strong></p><p>Please view the CAN data generated by the <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/simulatedvehicle/canreplay/bin/can_replay.py">vehicle simulation script</a> that runs <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/tree/main/simulatedvehicle/canreplay/service">as a system service</a> .</p><div><pre class="lang-bash">candump vcan0</pre><p>You can exit the output mode using Ctrl-C command.</p></div><p><strong>4. You can view Edge Agent output</strong></p><pre class="lang-bash">sudo journalctl -fu fwe@0</pre><p><em>You can safely ignore error message “Failed to receive VIN from Engine ECU”</em>.</p><h3>Step 2: Review collected vehicle data in Amazon Timestream</h3><p>In this step, you will review the results of the data collection campaigns stored in the Amazon Timestream table.</p><p><strong>1. Open the Amazon Timestream Console</strong></p><p>Please navigate to “Amazon Timestream” service in AWS management console or click on <a href="https://console.aws.amazon.com/timestream/home">this link</a>. Next, select the Query editor menu item.</p><div id="attachment_9854" class="wp-caption alignleft c4"><img aria-describedby="caption-attachment-9854" class="size-large wp-image-9854" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/12/Screenshot-2022-09-12-at-11.33.10-1024x577.png" alt="Amazon Timestream console" width="1024" height="577" /><p id="caption-attachment-9854" class="wp-caption-text">Amazon Timestream console</p></div><p><strong>2. Review vehicle data collected by campaign 1 “Continuously collect battery pack current and cell temperature”</strong></p><p>In the text field for the query, enter the following sample query and choose <strong>Run</strong> :</p><pre class="lang-sql">SELECT time, vehicleName, measure_name, measure_value::double, VehicleVINFROM "FleetWiseDatabase"."FleetWiseTable"WHERE campaignName = 'continious-monitoring-campaign' AND time between ago(15m) and now()ORDER BY time DESC LIMIT 10</pre><p>You can now view the collected vehicle data as you see in example below:</p><p><img class="alignleft size-large wp-image-10129" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/15/timestream_query_campaign_1-1024x577.png" alt="Amazon Timestream Query" width="1024" height="577" />In spite of the fact that both vehicles encode the CAN message for the signal <code>EVBatterySample.BMS.BatteryPack01.ShuntPlusCurrent_a</code> in different ways (see DBC files for <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/simulatedvehicle/canreplay/config/blog-vehicle-01/ev_overcurrent_detection/ev_overcurrent_detection.dbc#L60">vehicle 1</a> and <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/simulatedvehicle/canreplay/config/blog-vehicle-02/ev_overcurrent_detection/ev_overcurrent_detection.dbc#L60">vehicle 2</a>), you can access and analyze the vehicle data under a uniform name!</p><p>We suggest to run your own experiments with visualizing the vehicle data by using <a href="https://aws.amazon.com/grafana/">Amazon Managed Grafana</a> with <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/tree/main/dashboards">example dashboards</a>, as you can see in the example below:<img class="alignleft size-large wp-image-10183" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/16/grafana-monitoring-1024x462.png" alt="Amazon Managed Grafana" width="1024" height="462" /></p><p><strong>3. Review vehicle data collected by campaign 2</strong></p><p>Let’s query the statistics of a specific cell temperature. Enter the following query and select <strong>Run</strong> :</p><pre class="lang-sql">SELECT vehicleName, measure_name, hour(time) as hour, minute(time) as minute, max(measure_value::double) as MaxTemperature, min(measure_value::double) as MinTemperatureFROM "FleetWiseDatabase"."FleetWiseTable"WHERE campaignName = 'conditional-snapshot-campaign' AND measure_name = 'EVBatterySample.BMS.BatteryPack01.Cell001.CellTemperature' AND (time between ago(10m) and now())GROUP by vehicleName, measure_name, hour(time), minute(time)ORDER by vehicleName,hour(time), minute(time)</pre><p>You can now view the aggregated vehicle data as you see in example below. According to <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/cloud/cli-input-templates/7_campaign/vehicletargeted-detailed-analysis-campaign.json">the campaign configuration</a> , the data was transferred only when battery pack shunt current was over 450 amperes. For 19:42 and 19:43, shunt current was below 450 amperes, so no data was transferred.</p><p><img class="alignleft size-large wp-image-10186" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/16/timestream_query_campaign_2-1024x580.png" alt="" width="1024" height="580" /></p><p>We suggest to run your own experiments with the vehicle data by following <a href="https://docs.aws.amazon.com/timestream/latest/developerguide/reference.html">Amazon Timestream Query Language reference guidelines</a> or by creating <a href="https://aws.amazon.com/grafana/">Amazon Managed Grafana</a> dashboards like below <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring">using provided examples</a>:<img class="alignleft size-large wp-image-10188" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/16/grafana-conditional-1024x522.png" alt="" width="1024" height="522" /></p><h2>Cleaning up</h2><p>Please ensure to exit the SSH session to the Amazon EC2 instance before you continue. Please run the following commands in AWS CloudShell to remove the created resources from your AWS account:</p><pre class="lang-bash">aws cloudformation delete-stack --stack-name vehiclesimulationsh ~/aws-iot-fleetwise-evbatterymonitoring/cloud/automation/fleetwise-cleanup.sh</pre><h2>Summary and next steps</h2><p>You have learned how to use AWS IoT FleetWise to implement the collection, conversion, transmission, and storage of CAN bus signals and how to query these signals using Amazon Timestream. In the next part of this blog series, we will introduce you to how you can use AWS services to analyze stored data.</p><p>Visit the <a href="https://aws.amazon.com/iot-fleetwise/">AWS IoT FleetWise</a> webpage to learn more.</p><div><h2>Special thanks</h2><p>Geoffrey Phillips (Senior Software Development Engineer) contributed major parts of the <a href="https://github.com/aws-samples/aws-iot-fleetwise-evbatterymonitoring/blob/main/simulatedvehicle/ec2simulation/template.yaml">AWS CloudFormation template</a> and the CAN Interactive Generator library.</p></div><div><h2>About the authors</h2><div><p><img class="alignleft wp-image-8880" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/07/13/image001-1.jpg" alt="" width="54" height="80" /><a href="https://www.linkedin.com/in/svirida/">Andrei Svirida</a> is Senior Specialist Solutions Architect at Amazon Web Services. He is passionate about enabling companies of all sizes and industries to become data-driven businesses. To that end, he helps AWS customers to architect and build secure and scalable solutions on AWS, focusing on IoT, Analytics and Data Engineering. Prior to joining AWS, Andrei worked at KUKA AG as Head for IoT Delivery and as VP in in-house consulting at Deutsche Telekom AG. Andrei has a computer science background and more then 18 years of industry experience.</p></div><div><p><img class="alignleft size-full wp-image-10370" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/29/suvrath-high-res-current-photo-copy2.jpeg" alt="Suvendu Rath" width="150" height="225" /><a href="https://www.linkedin.com/in/suvendu-rath/">Suvendu Rath</a> is Senior Engagement Manager at Amazon Web Services. He is passionate about robust innovation strategies for Automotive customers .He helps AWS customers to running innovation projects from initial brief through to final deliverable, focusing on IoT, AI/ML and Data Engineering. Prior to joining AWS, Suvendu worked as Software Project Lead at BMW AG and as Software Engineer in Automotive/Avionics industry . Suvendu has an Electrical Engineering background and more than 15 years of industry experience in Automotive and Avionics domain.</p></div><div><p><img class="alignleft size-full wp-image-10346" src="https://d2908q01vomqb2.cloudfront.net/f6e1126cedebf23e1463aee73f9df08783640400/2022/09/25/profile_picture.jpg" alt="Katja Kroedel" width="150" height="200" /></p><p><a href="https://www.linkedin.com/in/katja-maja-kr%C3%B6del-927794198/">Katja-Maja Kroedel</a> is IoT Specialist Solution Architect at Amazon Web Services. She works with AWS customers to provide guidance on cloud adoption, migration, and strategy in the area of IoT. She is passionate about technology and enjoys building and experimenting in the cloud with innovative services, such as AWS IoT FleetWise. Katja has a Computer Engineering background and already worked at different roles within AWS, starting with her Masterthesis as well as her role as Generalist Solutions Architect in Germany, helping small- and middle-sized customers grow and learn about the cloud.</p></div></div></div>