Search Blog


Choose a category


Real-time stretch sensor data processing with Amazon Web Services Kinesis

In this blog post, we will take a quick look at how we can leverage the power of a cloud service provider like AWS to collect and process data in real-time.



To create a wearable that improves someone’s life and achieves widespread acceptance, it must have two defining characteristics: it must work with anybody, and it must work “out-of-the-box”.

People come in all shapes and sizes, so to make smart garments that are easy to use and work out-of-the-box it is imperative that we create a system that works seamlessly with the natural variation in people. Machine Learning (ML) and Artificial Intelligence (AI) are excellent frameworks to deal with this particular design consideration. Rather than undertaking the unrealistic task of having a perfect model of every person who puts a smart garment on, the principle of deriving insight by analyzing multiple data points simultaneously and operating on a “best fit” makes the process more robust to the (unavoidable) natural variation from body to body. Further, this allows systems to capture the interaction between multiple metrics (e.g. a shoulder lifting while at the same time rotating), it acts as a natural smoothing filter, and it greatly reduces the complexity – and in some cases can eliminate entirely – the need for an underlying theoretical model for the system to operate on. When you are developing a new User Experience, this means you do not need to have specialist knowledge in biomechanics or physiology in order to use human motion for your particular application whether that be in sports or physical therapy.



The first step in this process is to capture body motion data. Fortunately, macro-trends in technology have created an environment where band-width and computing power are high and getting higher, and the cost of storage is low and getting lower. From that perspective the more data that is captured the better, especially in the early stages of development.

Data on its own is necessary but not sufficient. Data only has value if we can distill it into actionable knowledge. This is where ML and AI become powerful tools for extracting insights both in what the data shows and how different elements interact within a dataset. It is important therefore that the process of capturing data is designed such that it will easily flow into the necessary analysis.

We are developing cloud integration for you because:

  1. It allows you to create a central repository of data and simplifies data aggregation.
  2. It creates a dataset to be mined for new insights as your understanding of what is contained in that data improves.
  3. The data is explicitly linked to the infrastructure and tools to bring ML and AI to bear on your application.
  4. The data, and ultimately the actionable knowledge, can be accessed from anywhere if such a feature is valuable to you.



We have used AWS as our first example of cloud integration. AWS provides several ways to send data to the cloud and in this blog, we have chosen Amazon Kinesis to demonstrate the principle, as it is tailored for streaming data in real-time. If your data is already filtered and has real-time relevance then Kinesis works very well.



Note: the images here are courtesy of Amazon Web Services and have been added to demonstrate the setup.

Below is the basic topology we have used in our example. We have a smart garment generating data and we want that data to make its way to the AWS cloud storage platform.



There are several options for transporting data using AWS Kinesis, but we have chosen to use the Kinesis Firehose Delivery System in our example. We have opted for a very simple setup for this example, your specific needs may vary but the purpose of the below is to give you a starting point.

  1. Go to the Kinesis Dashboard and click Create Delivery Stream in the Kinesis Firehose delivery stream section. 
  2. You will need to name your stream. In this setup, we have named our stream ‘StretchSense-Demo-SensorStream.’ The input source can be from any device such as a mobile phone or an Arduino board. These devices will use Firehose SDK to send data to streams using PUT command. 
  3. You can choose to manipulate your data before saving it to a data store. AWS Lambda allows you to convert the source format to a different one of your choice. We won’t use this in our example, so we have disabled Record Transformation and Record Format Conversion.
  4. Next, you need to select the destination for storing your data. In our example, we have stored the data as flat files such as CSV, and we have chosen S3 as our storage service. Within S3 we need to create a bucket using the Create New button in the S3 destination section. We have named our bucket ‘stretchsensor-data-demo-bucket’.  
    1. “Create New” 
  5. Once the bucket is created, your bucket will now appear in the S3 dashboard.
  6. Next, you must set the S3 buffer condition to control how frequently your app transfers data to S3. The Amazon Kinesis data stream will cache the data on your local device (e.g. your Android/iOS device) until one of the conditions are met, at which point the data will be pushed to S3.
  7. Before your app will be allowed to send data to your S3 you must set up the appropriate permissions. In order to give the data stream access to the S3 folder, we need to create an IAM role which allows the stream to put data on the S3 folder. Once the IAM role is created you can set up this role on the stream. The final window will look like this:
  8. Now any device with internet access will be able to send or stream data to Kinesis. In the beginning, only authenticated devices will be able to send data to our stream, but it is possible to create an unauthenticated role to allow unauthenticated devices to send data to this stream. To allow unauthenticated devices go to IAM console in AWS and create a role that allows unauthenticated devices to put batch records to the stream.
  9. Once this role is applied data can be pushed from unauthenticated devices. Using the API provided by Amazon Kinesis SDK we can call putRecord or putBatchRecord to send data to the stream. If the device is offline, the device will record the data locally and sync it when the connection is available.
  10. Once data is received from devices onto the stream, it will be made available at S3:



In this example we have used AWS to capture data via Amazon Kinesis that is ready for further analysis using the ML tools also available through the AWS platform. This is the beginning of a series of posts highlighting different ways you can use data from our smart garments and sensors to build a new user experience to suit your needs.

Previous Article

Sensor fusion for human motion capture

Read more

Next Article


Read more

Hear it from us first!

Sign up to be one of the first to hear the latest news and product releases from StretchSense.


Latest Press Release: StretchSense Acquires MocapNow

Download Packaged File (PDF 4.8MB)