cancel
Showing results for 
Search instead for 
Did you mean: 

Smart Bluetooth

Anonymous
Not applicable

Hi All,

Let me start by saying I know close to nothing about C/C++ (and I'm trying hard to understand the iOS source)..  With that said, I have gotten my WICED Sense kit to provide data.. I've figured out how to get the notifications from the sensors.. cool!  Also, I have not modified the firmware - so all sensors are active.

So now, from javascript the kit appears to be sending in an ArrayBuffer; but I'm having a hard time trying to figure out what data is what   Let me give you some examples...

let's say:  data = the WICED Sense Kit ArrayBuffer data

when I write out to my console log this:

kitData = new Uint8Array(data);

I get this:

kitData.length array is 19 and contains:

11, 76, 0, 225, 255, 31, 0, 142, 255, 202, 255, 181, 0, 223, 3, 138, 2, 251, 253

I can only assume that's the sensor data?!  Every 13th iteration, kitData shrinks down to a length of 7 and contains:

52, 155, 3, 210, 39, 247, 0

..again, assuming this is sensor data (probably temp, humidity, and pressure; as they are sent at less intervals because they change less).

if I used signed array:

kitData = new Int8Array(data);

array sizes are the same.. data is now signed..

11, 79, 0, -35, -1, 11, 0, -96, -2, 5, 0, -7, 1, -83, 6, 106, 3, -70, -3

52, -15, 1, -47, 39, -16, 0

..so I know from reading the blog that i need to read a bitmask from the packet to understand the subsequent data.  I noted that in all cases, the first position of the data being sent is "11" (when the array size is 19) and "52" (when the size is 7).

..anyone have any clues as to how I may decipher this incoming data from JavaScript?  Truly appreciate.

-Mike

0 Likes
1 Solution
Anonymous
Not applicable

Ok - I think I have it..  or at least a clue! 

the first int number in this example is 11:

11, 79, 0, -35, -1, 11, 0, -96, -2, 5, 0, -7, 1, -83, 6, 106, 3, -70, -3

11 in binary = 001011    // so if you follow the bits (right-to-left) and reference the bitmask documented OTA_Sensor_Packets.JPG

---------

1: accelerometer sensor data is included

1: gyro sensor data is included

0: humidity sensor data is not included

1: magnetometer sensor data is included

0: pressure sensor data is not included

0: temp sensor data is not included

similarly, 52 in binary = 110100  // again, right-to-left bitmask is:

---------

0: accelerometer sensor data is not included

0: gyro sensor data is not included

1: humidity sensor data is included

0: magnetometer sensor data is not included

1: pressure sensor data is included

1: temp sensor data is included

..so in theory, if I converted the first result from the data to binary, I can figure out the subsequent data being sent.

e.g.

(11).toString(2);        // 1011

I then need to build a structure for the subsequent data so I can read it..

-Mike

View solution in original post

7 Replies
Anonymous
Not applicable

Ok - I think I have it..  or at least a clue! 

the first int number in this example is 11:

11, 79, 0, -35, -1, 11, 0, -96, -2, 5, 0, -7, 1, -83, 6, 106, 3, -70, -3

11 in binary = 001011    // so if you follow the bits (right-to-left) and reference the bitmask documented OTA_Sensor_Packets.JPG

---------

1: accelerometer sensor data is included

1: gyro sensor data is included

0: humidity sensor data is not included

1: magnetometer sensor data is included

0: pressure sensor data is not included

0: temp sensor data is not included

similarly, 52 in binary = 110100  // again, right-to-left bitmask is:

---------

0: accelerometer sensor data is not included

0: gyro sensor data is not included

1: humidity sensor data is included

0: magnetometer sensor data is not included

1: pressure sensor data is included

1: temp sensor data is included

..so in theory, if I converted the first result from the data to binary, I can figure out the subsequent data being sent.

e.g.

(11).toString(2);        // 1011

I then need to build a structure for the subsequent data so I can read it..

-Mike

View solution in original post

Anonymous
Not applicable

Hello Mike,

Can you share your code?

Several forum users are interested WHERE in the code you were able to obtain the sensor data.

Thank you

JT

0 Likes
Anonymous
Not applicable

Hi JT,    sorry for the delayed reply - holidays had my head elsewhere..

I am in the process of getting approval to release the code.  Thanks.

Anonymous
Not applicable

Thanks Mike

JT

0 Likes
Anonymous
Not applicable

Have you seen this?:

Introduction to Format of WICED Sensor Data

This illustrates how the sensor data is encoded.

In general:

  • first byte is bit field indication which sensor values are following
  • two different types of packages are sent (also with different repetition ratio)
    (actually just a different first byte bit field)
    The HPT sensors (Humidity, Pressure, Temperature) are sent less often (slower sensors)
  • sensor values are coded as two byte fixed point values (e.g. temp. as integer multiplied by 10)
  • vector sensors have X, Y, Z (all as two bytes)
Anonymous
Not applicable

Thank you tjaekel

JT

0 Likes
Anonymous
Not applicable

All,

I have published an article on IBM developerWorks on how to interface the WICED sense kit to a hybrid application (basically, it's JavaScript).  The hybrid application runs on a smart device (e.g. smart phone or tablet with BLE support) and uses a JavaScript library that interfaces BLE along with my library to interface the WICED Sense Kit.

The article goes on to integrate messages from the WICED Sense gyro sensors (what I used as a "wearable" in this article) into the IoT Foundation Cloud (which you can do too!)

Link: Build your own wearable with IBM IoT Foundation and IBM Bluemix

Source code included in the article. So anyone that wants to read sensors from the WICED Sense Kit from JavaScript, this should get you started.

Cheers,  Mike