Skip to content

Commit

Permalink
updating loggin data
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Satrom committed Apr 28, 2015
1 parent 22f18c7 commit 9da8bca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
4 changes: 3 additions & 1 deletion src/default.js
Expand Up @@ -22,8 +22,10 @@ setInterval(function () {
reading.location.longitude = 122.11;
reading.location.latitude = 22;

console.log(JSON.stringify(reading));

storage.logData(reading);
}, 1000);
}, 5000);

process.on('SIGTERM', cleanUp);
process.on('SIGINT', cleanUp);
29 changes: 14 additions & 15 deletions src/sensors.js
Expand Up @@ -7,51 +7,50 @@ var analogSensors;
var lightVal, tempVal;

var channelResponders = [
function(value, pct) { // Light Sensor
console.log('lightValue is: ' + value + '. pct: ' + pct);
function(value) { // Light Sensor
console.log('DEBUG: lightValue is: ' + value);
lightVal = value;
},
function(value, pct) { // Temp Sensor
console.log('tempValue is: ' + value + '. pct: ' + pct);
function(value) { // Temp Sensor
console.log('DEBUG: tempValue is: ' + value);
tempVal = value;
}
];

function initADC() {
var adcConfig = {
tolerance : 2,
interval : 300,
channels : [
interval : 300,
channels : [
lightSensorChannel,
tempSensorChannel
],
SPICLK: 23,
SPIMISO: 21,
SPIMOSI: 19,
SPICS: 24
SPICLK: 23,
SPIMISO: 21,
SPIMOSI: 19,
SPICS: 24
};

analogSensors = new ADC(adcConfig);
analogSensors.init();

// ADC Events
analogSensors.on('ready', function() {
console.log('Analog Pins ready, listening to channel...');
console.log('LOG: Analog Pins ready, listening to channel...');
});

analogSensors.on('close', function() {
console.log('ADC terminated');
console.log('LOG: ADC terminated');
process.exit();
});

// Respond to sensor changes
analogSensors.on('change', function(data) {
if (data) {
var channel = data.channel,
value = data.value,
pct = data.pct;
value = data.value;

channelResponders[channel](value, pct);
channelResponders[channel](value);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/storage.js
Expand Up @@ -23,11 +23,11 @@ var storage = {
logData: function(reading) {
sensorRepository.create(reading,
function(data) {
console.log("Successfully posted sensor data to cloud. " +
console.log("LOG: Successfully posted sensor data to cloud. " +
JSON.stringify(data));
},
function(error) {
console.log("Error posting sensor data to cloud: " +
console.log("ERR: Error posting sensor data to cloud: " +
JSON.stringify(error));
});
}
Expand Down

0 comments on commit 9da8bca

Please sign in to comment.