Skip to content

Instantly share code, notes, and snippets.

@sandeepmistry
Last active December 20, 2015 05:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandeepmistry/6075857 to your computer and use it in GitHub Desktop.
Save sandeepmistry/6075857 to your computer and use it in GitHub Desktop.
node.js TI SensorTag humidity sensor example.
var SensorTag = require('sensortag');
SensorTag.discover(function(sensorTag) {
console.log('discover');
sensorTag.connect(function() {
console.log('connect');
sensorTag.discoverServices(function() {
console.log('discoverServices');
sensorTag.discoverCharacteristics(function() {
console.log('discoverCharacteristics');
sensorTag.enableHumidity(function() {
sensorTag.on('humidityChange', function(temperature, humidity) {
console.log('\ttemperature = %d °C', temperature.toFixed(1));
console.log('\thumidity = %d %', humidity.toFixed(1));
});
sensorTag.notifyHumidity(function() {
console.log('notifyHumidity');
});
});
});
});
});
});
@rmela
Copy link

rmela commented Jun 15, 2014

using bluez 5.19 on arch linux raspberry pi, running as root.
Code blows up at line 5 since sensorTag is a uuid, not a peripheral.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment