2.2.0 • Published 4 years ago

sensortile-ble v2.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

SensorTile Ble

SensorTile boards interface for browsers using the Web Bluetooth API.

Currently only tested with reactjs.

Links

Web Bluetooth Api: https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API

SensorTile evaluation board: https://www.st.com/en/evaluation-tools/steval-stlcs01v1.html

Npm package: https://www.npmjs.com/settings/reavershark/packages

Usage

See example.js for a full example.

Brief example

npm install sensortile-ble --save

In a reactjs file:

import Ble from "sensortile-ble";

ble.connect().then(() => {
  ble.setupSensors()
    .then((sensors) => {
      sensors.battery.read()
        .then((value) => {
          console.log('Battery percentage: ' + value.percentage);
        });
    });
});

Sensors

Accelerometer

Implementation: accelerometer.js

Properties:

  • read
    • value has properties:
      • timestamp
      • steps
        • number of steps since last reset
  • notify
    • triggers an event on the smallest movement
    • some events include the stepcount
      • the step count only increment with large movements
      • multiple events can have the same step count
    • some events include the motion
    • the event cannot have steps and motion at the same time
    • event.value has properties:
      • timestamp
      • steps (optional, mutually exclusive with motion)
        • number of steps since last reset
      • motion (optional, mutually exclusive with motion)

Activity

Implementation: activity.js

Properties:

  • read
    • value has properties:
      • timestamp
      • activity
        • string representation of the current activity
        • possible values:
          • No activity, Stationary, Walking, Fast walking, Jogging, Biking, Driving
  • notify
    • triggers an event now and then
    • event.value has the same properties as read

Battery

Implementation: battery.js

Properties:

  • read

    • value has properties:
      • timestamp
      • percentage
        • battery percentage with 1 decimal (ex. 71.3)
      • voltage
        • battery voltage as a decimal in Volts
      • current
        • current being drawn from the battery in miliampere
        • negative values mean discharging, positive values mean charging
      • status
        • string representation of the current status
        • possible values:
        • Low battery, Discharging, Plugged not charging, Charging, Unknown
  • notify

    • triggers an event every ~0.5 seconds
    • event.value the same properties as read

Carry position

Implementation: carryPosition.js

Properties:

  • read
    • read needs notifications enabled (notifyEnable()) before reading
    • without notifications, position is always 'Unknown'
    • value has properties:
      • timestamp
      • position
        • string representation of the carry postion of the device
        • possible values:
          • Unknown, On desk, In hand, Near head, Shirt pocket, Trousers pocket, Arm swing
  • notify
    • triggers an event now and then
    • event.value has the same properties as read

Gesture

Implementation: gesture.js

Properties:

  • notify
    • triggers an event on every gesture performed
    • event.value has properties:
      • timestamp
      • gesture
        • string representation of the gesture performed of the device
        • possible values:
          • Unknown, Pick up, Glance, Wake up

Movement Fusion

Implementation: movementFusion.js

Properties:

  • notify
    • timestamp
    • acceleration
      • array with 3 elements: xyz
    • rotation
      • array with 3 elements: xyz
    • magnetic
      • array with 3 elements: xyz

Rotation (MEMS sensor fusion compact)

Implementation: rotation.js

Properties:

  • notify
    • timestamp
    • rotation
      • array of 3 elements with properties:
        • Qi
        • Qj
        • Qk
      • Each element represents a rotation 30 msecs after the previous

Sensor reverse-engineering

Unknown 1 (sketch)

UUID: 001d0000-0001-11e1-ac36-0002a5d5c51b

Properties:

  • read
    • timestamp (16)
    • 10 more bytes
  • notify
    • timestamp (16)
    • 10 more bytes

from python sdk:

...
0x00100000: feature_pressure.FeaturePressure,           #001d0000
0x00080000: feature_humidity.FeatureHumidity,           #001d0000
0x00040000: feature_temperature.FeatureTemperature,     #001d0000
#0x00020000: feature_battery.FeatureBattery,
0x00010000: feature_temperature.FeatureTemperature,     #001d0000
...

No idea

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago