2. Topology

There are many possible topologies for Bluetooth based sensor systems

2.1. Multiple MetaSensors

The MetaBase App allows you to stream data from 2-3 MetaSensors at the same time. Although MetaSensors can have infinite connections; it is not possible to connect more due to hardware and OS level constraints on the device running the MetaBase App.

Warning

Bluetooth FAQ - Apple support article HT3887 - “The official Bluetooth specifications state seven is the maximum number of Bluetooth devices that can be connected at once. However, three to four devices is a practical limit, depending on the types of devices and profiles are used.”

If you want to connect more than 3 sensors simultaneously, you will need to use a Linux PC or use the MetaHub with multiple dongles. Programming is required.

2.1.1. Synchronizing Multiple Datasets in Excel

When collecting data from multiple sensors or multiple devices, you may want to synchronize the data to a single set of time stamps. We can accomplish this in Excel in a few seconds.

In our test, we use two MetaSensors streaming accelerometer data.

We used two sensors, therefore we get two files; Calib3_Accelerometer_2017-09-14T13-39-02.461.csv and Calib4_Accelerometer_2017-09-14T13-39-02.461.csv.

We graphed the data in Excel:

_images/Excel-sync1.png

As you can see in Excel; there are three timestamps followed by accelerometer x,y,z data.

epoch (ms) time (-07:00) elapsed (s) X-Axis (g) Y-Axis (g) Z-Axis (g)
Unix time in ms Full Date Elapsed Time Acc X Acc Y Acc Z
1505421542683.00 2017-09-14T13:39:02.683 0 -0.986 -0.263 0.03

Note

You might need to format the Epoch cell in Excel to see the timestamp correctly.

The Unix Epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT)

For example, epoch time 1521250282.00 is 1521250282 seconds since Jan 01 1970. (UTC) which translates to 03/17/2018 @ 1:31am (UTC)

You should look at the epoch portion of the timestamp for synching purposes.

What you are looking for is to match the two timestamps that are closest to one another (hopefully only a few ms apart) between the two files. Then delete any extraneous data sets.

The first MetaSensors has an initial timestamp of 1505421542706.00 and the second starts at 1505421542683.00, this is only a difference of .023 seconds! This is fine for our application as this difference in time is beyond perceptible to the human eye and more than acceptable for medical and consumer applications.

If you started recording data from the first sensor seconds, minutes, or even hours before the other sensor, that’s ok! Just delete the extra data (row entries) in Excel that you do not need. The idea is to find the two best matching and closest timestamps between the two sensors to sync their data sets.

You will want to combine the two files into one file when you are ready:

_images/Excel-sync2.png

And finally, delete the extra timestamps (Excel rows / data entries) from the second sensor once you have decided on your best timestamp match.

You can then graph the data easily as we have done below:

_images/Excel-sync3.png

We are done!

Warning

You should note that some entries have repeat timestamps. This is normal. We pack data in order to maximize efficiency of the device.

You can do a bit of math to restore timestamps for packed data as we have done below:

epoch (ms) time (-07:00) elapsed (s) X-Axis (g) Y-Axis (g) Z-Axis (g)
1505421542683.00 2017-09-14T13:39:02.683 0 -0.986 -0.263 0.03
1505421542703.00 2017-09-14T13:39:02.703 0.020 -0.994 -0.265 0.033
1505421542723.00 2017-09-14T13:39:02.723 0.040 -0.993 -0.264 0.03
1505421542744.00 2017-09-14T13:39:02.744 0.061 -0.994 -0.264 0.031
1505421542764.00 2017-09-14T13:39:02.764 0.081 -0.992 -0.266 0.031
1505421542784.00 2017-09-14T13:39:02.784 0.101 -0.993 -0.265 0.032
1505421542804.00 2017-09-14T13:39:02.804 0.121 -0.993 -0.265 0.032

2.1.2. Synchronizing Multiple Datasets in Python

We can accomplish synching multiple data sets easily using Python. Here is a basic example of how to do this synchronization using the Pandas Python package:

First we import the pandas package and read in the data:

import pandas as pd

df = pd.read_csv("Test_Accelerometer.csv") #Reading the dataset in a dataframe using Pandas
df2 = pd.read_csv("Test_Gyroscope.csv") #Reading the dataset in a dataframe using Pandas

In this case, we are trying to synchronize 100Hz gyroscope data to 50Hz accelerometer data. The head command can be used to check if the data was imported correctly.

df.head(5) #This will display the first 5 lines of the imported data set
df2.head(5)

We are looking to merge the gyroscope data with the accelerometer data by finding the “closest” timestamp in the gyro data set that matches a given timestamp in the accelerometer data set.

Lets take an easy example to illustrate what we want to accomplish.

>>> Data set 1:
>>>
>>> Time: 12:45pm Data: 0.1
>>>
>>> Data set 2:
>>> Time: 12:40pm Data: 2
>>> Time: 12:46pm Data: 1
>>> Time: 12:48pm Data: 3

In this case, we are looking to merge the data sets to form 1 set as such:

>>> Combined data set:
>>> Time 12:45pm Data1: 0.1 Data2: 1

Fortunately, there is a very easy function in the Pandas library that lets us do this:

pd.merge_asof(df, df2, on='epoch (ms)')

This will merge df2 with df, while using the ‘epoch (ms)’ column as the “index” to merge on. In this case, we will get a merged data set with x, y, and z axis data for both the accelerometer and the gyroscope.

2.2. 1 Sensor + 1 App (Hub)

This is the most common infrastructure used by devices such as your Fitbit or smart Scale.

_images/standard-infrastructure.png

This can be:

  • Wearables
  • Fitness Trackers

Note

A smartphone app captures the bio and fitness metrics of a sensor worn on running shorts. The motion sensors are used to analyze the gait and cadence of the runner and metrics are displayed in the App.

2.3. 2+ Sensors + 2+ Apps (Hubs)

This is a common infrastructure for tracking many people at a conference using iBeacons or Eddystones.

_images/beacons-infograph.jpg

This can be:

  • Asset Tracker
  • People Tracker

Note

7 MetaHubs are placed in each room of the warehouse facility and movable objects are outfitted with MetaSensors beaconing. The advertised beacon data has information about the temperature and humidity of the packages which is observed by the MetaHub and relayed to the cloud. The information is used to locate the movable objects and make sure they are kept in proper inventory conditions.

2.4. 1 Sensor + 2+ Apps (Hubs)

This is a common infrastructure for logistics and tracking the dark portions of a supply chain such as your crate of bananas in a container that is refrigerated currently stuck in the Panama Canal.

_images/beacons-infograph.png

This can be:

  • Cargo Tracker
  • RTLS (Location / Beacon)

Note

2 Hubs and 1 App are used by the warehouse owners, on the manufacturing floor, and by consignees in the supply chain. At each step, data is downloaded from 1 sensor Device tracking cold cargo shipment of extremely sensitive pharmaceuticals.

2.5. 2+ Sensors + 1 App (Hub)

This is a common infrastructure for motion detection of people and robots such as analyzing a tennis swing or a swim stroke.

_images/bluetooth-low-energy-sensor-nodes.png

This can be:

  • Motion/Sports/Object Tracker
  • Robot

Note

1 Hub is used to track the motion of a robot arm in a laboratory. The Hub relays the information to the cloud which tracks the motion of the robot arm as well as how often they are used by researchers.