function startSensorWatch(socket) {
    'use strict';
        
    setInterval(function () {
        var a = myAnalogPin.read();
        //console.log("Analog Pin (A0) Output: " + a);
        //console.log("Checking....");
        
        var resistance = (1023 - a) * 10000 / a; //get the resistance of the sensor;
        //console.log("Resistance: "+resistance);
        var celsius_value = 1 / (Math.log(resistance / 10000) / B + 1 / 298.15) - 273.15;//convert to temperature via datasheet ;
        var celsius = new mco.UnitValue(celsius_value, MetricSystem.CELSIUS);
        console.log("Celsius Temperature "+celsius); 
        var fahrenheit =  mco.UnitTransformer.transform(celsius, UsCustomarySystem.FAHRENHEIT);
        console.log("Fahrenheit Temperature: " + fahrenheit);
        var fahrenheit_value = fahrenheit.getValue(); // we use the numeric value to hand to Websocket
        // Publish the message to Websocket
        socket.emit("message", fahrenheit_value);
        // Publish the message to the local agent
        //client.publish("temperature", celsius);
    }, 4000);
}
/*
Function: startSensorWatch(socket)
Parameters: socket - client communication channel
Description: Read Temperature Sensor and send temperature in degrees of Fahrenheit every 4 seconds
*/
startSensorWatch(socket)
Parameters: socket - client communication channel
Description: Read Temperature Sensor and send temperature in degrees of Fahrenheit every 4 seconds
startSensorWatch ( socket ) Parameters : socket - client communication channel Description : Read Temperature Sensor and send temperature in degrees of Fahrenheit every 4 seconds
function startSensorWatch(socket) {
    'use strict';
    setInterval(function () {
        var a = myAnalogPin.read();
        var resistance = (1023 - a) * 10000 / a; 
        var celsius_value = 1 / (Math.log(resistance / 10000) / B + 1 / 298.15) - 273.15;
        var celsius = new mco.UnitValue(celsius_value, MetricSystem.CELSIUS);
        console.log("Celsius Temperature "+celsius); 
        var fahrenheit =  mco.UnitTransformer.transform(celsius, UsCustomarySystem.FAHRENHEIT);
        console.log("Fahrenheit Temperature: " + fahrenheit);
        var fahrenheit_value = fahrenheit.getValue(); 
        socket.emit("message", fahrenheit_value);
    }, 4000);
}
function startSensorWatch ( socket ) { 'use strict' ; setInterval ( function ( ) { var a = myAnalogPin . read ( ) ; var resistance = ( 1023 - a ) * 10000 / a ; var celsius_value = 1 / ( Math . log ( resistance / 10000 ) / B + 1 / 298.15 ) - 273.15 ; var celsius = new mco . UnitValue ( celsius_value , MetricSystem . CELSIUS ) ; console . log ( "Celsius Temperature " + celsius ) ; var fahrenheit = mco . UnitTransformer . transform ( celsius , UsCustomarySystem . FAHRENHEIT ) ; console . log ( "Fahrenheit Temperature: " + fahrenheit ) ; var fahrenheit_value = fahrenheit . getValue ( ) ; socket . emit ( "message" , fahrenheit_value ) ; } , 4000 ) ; }
Function: startSensorWatch(socket)
Parameters: socket - client communication channel
Description: Read Temperature Sensor and send temperature in degrees of Fahrenheit every 4 seconds
Function : startSensorWatch ( socket ) Parameters : socket - client communication channel Description : Read Temperature Sensor and send temperature in degrees of Fahrenheit every 4 seconds
//console.log("Analog Pin (A0) Output: " + a); //console.log("Checking...."); //get the resistance of the sensor; //console.log("Resistance: "+resistance); //convert to temperature via datasheet ; // we use the numeric value to hand to Websocket // Publish the message to Websocket // Publish the message to the local agent //client.publish("temperature", celsius);