IoT - Reading from multiple sensors with NodeJS on Raspberry PI

I got this amazing sensor tag from Texas Instrument:
I saw this up and working at Microsoft one month ago, however at that time the sample provided was with C, I am not familiar with C and I really needed something I can easily change to my needs.

When testing this at Microsoft, we only tested the Temperature Sensor, however I just noticed that this small device has up to 10 sensors on the same box, it has Magnometer, Luxomer, Acceleromer, Barometric pressure, temperature, amongst others.

To install the package:

npm install sensortag  

Then in order to read data from multiple sensor tags at the same time, you just register them by id, which is printed in the box.

In the example below I just enabled 3 sensors, temperature, accelerometer and the buttons.

var SensorTag = require('sensortag');        // sensortag library

SensorTag.discoverById('24718908d606', onDiscover);  
SensorTag.discoverById('a0e6f8af0c85', onDiscover);

// listen for tags:
function onDiscover(tag)  {  
    // when you disconnect from a tag, exit the program:
    tag.on('disconnect', function() {

    function connectAndSetUpMe() {          // attempt to connect to the tag
        tag.connectAndSetUp(enableIrTempMe);        // when you connect, call enableIrTempMe\

    function enableIrTempMe() {        // attempt to enable the IR Temperature sensor
        // when you enable the IR Temperature sensor, start notifications:

    function notifyMeAcc() {
           tag.notifyAccelerometer(listenForAcc);      // start the accelerometer listener
        tag.notifySimpleKey(listenForButton);       // start the button listener

    function listenForAcc() {
        tag.on('accelerometerChange', function(x, y, z) {
         console.log('\tx = %d G', x.toFixed(1));
         console.log('\ty = %d G', y.toFixed(1));
         console.log('\tz = %d G', z.toFixed(1));

    function notifyMeTemp() {
           tag.notifyIrTemperature(listenForTempReading);      // start the accelerometer listener
        tag.notifySimpleKey(listenForButton);       // start the button listener

    // When you get an accelermeter change, print it out:
    function listenForTempReading() {
        tag.on('irTemperatureChange', function(objectTemp, ambientTemp) {
         console.log('\tObject Temp = %d deg. C', objectTemp.toFixed(1));
         console.log('\tAmbient Temp = %d deg. C', ambientTemp.toFixed(1));

    // when you get a button change, print it out:
    function listenForButton() {
        tag.on('simpleKeyChange', function(left, right) {
            if (left) {
                console.log('left: ' + left);
            if (right) {
                console.log('right: ' + right);
            // if both buttons are pressed, disconnect:
            if (left && right) {

    // Now that you've defined all the functions, start the process:

And the end result:

Full documentation is posted here: