I2C SPI USB CAN eSPI Cable Testing View All Quick Start Guides User Manuals Software Downloads Knowledge Base Videos Case Studies App Notes White Papers Sales Support How to Order
Products Blog Sales Support Contact Search
Real-Time I2C/SPI Data Collection for AI Training and Deployment onto Edge Devices

Protocol analyzers can be used to capture and analyze bus traffic for specific communication protocols, including I2C and SPI. The data is displayed as decoded, human-readable packets, making it easier to interpret, isolate, and pinpoint specific transactions and errors. Data transmitted over these communication protocols, whether it be from sensors, memory devices, or power management ICs, can also be extracted and used to train Artificial Intelligence (AI) models and deploy them to edge devices.

What is Edge AI? 

Edge devices are hardware components located close to the source of data and are considered to be at the “edge” of a network where data can be processed locally rather than relying on cloud servers. This approach significantly reduces latency, improves bandwidth efficiency, and enhances security by keeping sensitive data localized. When integrated with AI, edge devices can analyze data and make inferences in real time, using on-device intelligence for tasks such as anomaly detection and failure prediction.

Collecting I2C/SPI Data to Train AI Algorithms

To train AI models for deployment on edge devices, datasets from communication protocols like I2C and SPI are collected to first establish a baseline of normal system behavior. This clean data is used to train an AI model that can automatically extract features to define key parameters of what is normal behavior. The trained model can compare new data against the learned patterns to identify any deviations from the norm, or anomalies. This can include point anomalies, which are single instances of data that are significantly different from the rest, contextual anomalies, which are deviations in a specific context, and collective anomalies, which are not indicators of abnormal behavior on their own, but point to a deviation when occurring together. 

Anomaly detection is useful in embedded systems for identifying communication issues, faulty sensors, or irregular power behavior, anticipating the need for updates, maintenance, or intervention before larger failures occur.

What does this look like in practice when it comes to extracting data and using it to train AI models?

Extracting the I2C/SPI Dataset

In order to generate controlled and repeatable datasets for edge training, an I2C/SPI host adapter can be used to send repeated commands to a sensor, querying its data on a regular interval. This could include readings from position sensors like accelerometers and gyroscopes, environmental sensors measuring temperature and pressure, image sensors using cameras, audio sensors using microphones, and much more.

An I2C/SPI protocol analyzer then captures the data in real time, logging data packets and bus information, including timestamps and transaction duration, start or stop commands, device addresses, and decoded data. This can be set up in a continuous loop, generating a data stream of all events occurring in a specific time period.

The Promira Serial Platform is an advanced serial device that can function as either an I2C/SPI host adapter and a protocol analyzer for this purpose, making it an ideal tool for extracting I2C and SPI datasets. Its I2C and SPI Active Applications can be used for master/slave emulation to send commands and query sensors, while its I2C and SPI Analysis Applications can be used to capture data in real time within Data Center Software. The Promira Software API allow enables users to create custom scripts to send more complex commands, and to log data continuously.

Training and Deploying the Model to an Edge Device

Once the I2C/SPI data is captured, it is processed to extract relevant readings that will be used to train the AI model. Custom scripts can be used to filter and organize this data, ensuring only the necessary information is utilized. The properly formatted dataset is then streamed to an AI algorithm to train a model on the typical patterns of system behavior.

The model is then capable of detecting any outliers or anomalies that occur outside of the norm. This could include unusual accelerometer movements, increases/decreases in pressure, or communication delays across the bus. Once the model is optimized, it can be deployed onto the edge device where it can run inference continuously, enabling real-time identification and flagging of irregularities in sensor or communication data.

Capturing I2C/SPI Data and Deploying Edge AI with Total Phase and NXP Platforms

The process of extracting I2C/SPI data, training an AI model, and deploying it to an edge device can be streamlined using tools like Total Phase protocol analyzers and NXP’s eIQ platform. Below is a summary of how this workflow can be carried out using these tools.

  • Preprocess, Clean, and Organize Data: When training an edge device, especially in supervised learning scenarios, it is crucial to focus on the most relevant data based on the chip’s intended function. This involves cleaning, labeling, and segmenting the data to align with specific tasks, enabling the model to learn meaningful and accurate patterns based on “normal” system behavior. Feature extraction can also be done to highlight key characteristics like expected timing intervals, sequence patterns, byte-level entropy (indicating the normal amount of deviations), and signal duration.

  • AI Model Configuration and Training: Create or use an existing algorithm for training. There are many different types of algorithms that can be used for different functions, including:
    • Decision Trees: used to classify tasks with a clear set of predetermined conditions that will trigger a decision/action.
    • Support Vector Machines (SVMs): used to classify data into distinct categories based on their relation to a hyperplane.
    • Neural Networks: used to evaluate complex patterns in large datasets.
    • K-Means Clustering: used for grouping similar data points.

In some cases, multiple algorithms may be employed. For example, in anomaly detection you might use K-Means clustering to preprocess data by grouping similar patterns together, then use a decision tree to classify the K-Means data as “normal”, and then use a Support Vector Machine (SVM) to flag any data that is outside of the baseline.

Common frameworks for implementing and training machine learning models like these include TensorFlow, ONNX, and PyTorch, which offer pre-built functions and tools to streamline algorithm development.

  • Testing and Validation: Once trained using frameworks like TensorFlow or PyTorch, the model should be tested and validated to ensure that it is fully optimized for deployment. NXP’s eIQ platform integrates with these frameworks, allowing developers to import models and validate performance using a separate dataset. This ensures the model can generalize to new data and run accurate inference tests. Key performance metrics like precision, recall, and F1 score are used to evaluate the model’s effectiveness. If necessary, the model can be fine-tuned with more data or by adjusting parameters like learning rate or network depth.
  • Deploying the Model to an Edge Device: Once validated and optimized, the model can be deployed to an edge device in a compatible format including TensorFlow Lite, Open Neural Network Exchange (ONNX), and TorchScript. Alternatively, with NXP’s eIQ software, users can deploy the model directly to NXP’s MCUs, MPUs, and i.MX applications processors, where they are integrated into the application firmware. The edge device will then perform real-time inference on the data from the embedded system’s sensors, identifying anomalies as they occur.

How Total Phase Tools Can Be Used for I2C/SPI Data Collection

With Data Center Software, a user-friendly bus monitoring GUI compatible with all Total Phase protocol analyzers, users can easily capture, view, filter, and search bus data in real time. The software supports Windows, Linux, and macOS, ensuring seamless cross-platform functionality. 

This software leverages unique technology to provide unmatched visibility into the bus, including LiveDisplay, LiveSearch, and LiveFilter

  • LiveDisplay enables users to view protocol traffic in real time with captured data organized into columns, such as timestamp, data length, device number, endpoint information, raw data, and a summary section for each transaction. Data packets are expandable for deeper insights into each captured point.
  • LiveSearch allows users to easily find areas of interest, such as bus events, text strings, hexadecimal values, and ASCII data patterns within a capture.
  • LiveFilter makes it easy to seamlessly switch between filtered and non-filtered views with a single click, enabling users to target specific indices, errors, endpoints, device addresses, PIDs, data patterns, and more. 

All Total Phase products include a free API, allowing users to integrate the tools into custom applications or more complex projects. For example, a custom script can be written to automate data collection tasks.

The Promira Serial Platform is our most advanced serial device that can be configured as an I2C/SPI host adapter for master/slave emulation as well as an I2C/SPI/eSPI protocol analyzer to capture and monitor data in real time. It supports I2C master and slave speeds up to 3.4 MHz, and can sniff I2C traffic at up to 5 MHz. For SPI, it supports master/slave speeds up to 80 MHz/20 MHz respectively, and can sniff SPI traffic at up to 40 MHz. It also includes support for Single, Dual, and Quad SPI as a master device, as well as High-speed USB and gigabit Ethernet connectivity to the host system.

The Beagle I2C/SPI Protocol Analyzer is a versatile tool that allows users to non-intrusively monitor and capture I2C up to 4 MHz and SPI up to 24 MHz, providing detailed insight into data exchanges, timing, and bus errors. 

Related Products