sensortile-ble
v2.2.0
Published
npm package for interfacing with SensorTile boards using the Web Bluetooth API
Downloads
13
Maintainers
Readme
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 --saveIn 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
- value has properties:
- 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)
- string array of motions performed (ex. ['Tilt', 'Single tap'])
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
- value has properties:
- 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
- value has properties:
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
- array of 3 elements with properties:
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
