´╗┐var temper1 = require('temper1');

var devices = temper1.getDevices();

//console.log("Devices found:" + devices);

exports.readTemperature = function(callback) {
    temper1.readTemperature(devices[0], function(err, value) {
        //console.log("reading: " + value);
        callback(err, value);
    });
}
var l = require('../lib/log.js')
var moment = require('moment')
var thermometers=require("temper1");

var devices=thermometers.getDevices();

console.log("Devices found:"+devices);

devices.forEach(function(device) {

	setInterval(function() {
		thermometers.readTemperature(device, function(err, value) {
		  var celsius = value
		  var farenheit = ((celsius*9)/5) + 32 
		  
		  celsius = celsius.toString()
	 	  if(celsius.length > 5) celsius = celsius.substr(0,4)
		  if(celsius.length < 5) {
		    while(celsius.length < 5) {
		      if(celsius.indexOf('.') == -1) {
		        celsius += '.' 
		      }
		      else {
		        celsius += '0'
		      }
		    }
		  }

 
		  farenheit = farenheit.toString()
	 	  if(farenheit.length > 5) farenheit = farenheit.substr(0,4)