Pi2Grover Weather Station Pi 3 - read sensors?

Hello,

I am having quite a bit of trouble determining how to read the sensors. This project is built and uses I2C, but how do I determine the sensors names, output as well as how to address them using the JS framework? I have been searching this site (and others) all day and have very little information on how to proceed. I am not a novice programmer, but would like some help determining where to start.

Thank you.

There are limited JS examples… but they are here somewhere… e.g. This is the only one I have running, mostly as a learning process… It is fairly well commented, but you will have to break it down and glean whatever you can on your own… then tell me how it works :stuck_out_tongue:


var Gpio = require('onoff').Gpio;  // links variable 'Gpio' to the all important onoff GPIO control library
var Blynk = require('blynk-library');  // Links variable 'Blynk' to the Blynk Library
var AUTH = 'cda957435ce44407bed2e9283c95018f';  // My top secret auth code... useless to anyone on the cloud ;P
var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr: "10.10.3.13", port: 8442 } ) });  // This takes all the info and directs the connection to my Local Server.
var process = require('child_process'); // Allows this script to run CLI commands? Used in the "run the command ifconfig" function
var LEDintensity = 255;

var v1 = new blynk.VirtualPin(1);  // Setup Button Widget on V1 with variable 'v1'
var v4 = new blynk.VirtualPin(4);  // Setup Slider Widget on V4 with variable 'v4'
var v5 = new blynk.VirtualPin(5);  // Setup Button Widget on V5 with variable 'v5'
var v6 = new blynk.VirtualPin(6);  // Setup Display Widget on V6 with variable 'v6'
var v9 = new blynk.VirtualPin(9);  // Setup Display Widget on V9 with variable 'v9'
var v10 = new blynk.VirtualPin(10);  // Setup LED Widget on V10 with variable 'v10'

v1.on('write', function(param) {  // Watches for V1 Button
  console.log('V1:', param[0]);  // prints value to CLI
  if (param == 0) {
    blynk.virtualWrite(10, 0);  // V10 Widget (ORANGE) LED OFF
  } else if (param == 1) {
    blynk.virtualWrite(10, LEDintensity);  // V10 Widget (ORANGE) LED ON
  }
});

// Vary the intensity or orange LED
v4.on('write', function(param) {  // Watches for V4 Slider
LEDintensity = param;
console.log(LEDintensity);  // prints value to CLI
v6.write(LEDintensity);
blynk.syncVirtual(1);  // Runs the button funtion to update the LED
});

v4.on('read', function() {  // I don't understand why this says read??
  v6.write(LEDintensity);  // but this sends the seconds 0-59 to the Display Widget
});

// Run the command "ifconfig"
v5.on('write', function(param) {  // Watches for V5 Button
  console.log('V5:', param[0]);  // prints value to CLI
  if (param == 1) {  // Runs the CLI command ifconfig if the button on V5 is pressed
    process.exec('ifconfig', function (err, stdout, stderr) {
      if (err) {
        console.log("\n" + stderr);
      } else {
        console.log(stdout);
      }
    })
  }
});

v9.on('read', function() {  // I don't understand why this says read??
  v9.write(new Date().getSeconds());  // but this sends the seconds 0-59 to the Display Widget
});

led = new Gpio(18, 'out'),  // Sets up the BCM pin 18 as an output for the LED and assigns it to variable "led"
button = new Gpio(25, 'in', 'both');  // Sets up the BCM pin 25 as an input registering both rising and falling for the variable "button"

button.watch(function (err, value) {  // Watches for button press and assigns 0/1 to value
  if (err) {
    throw err;  // Some form of error handling
  }
  led.writeSync(value);  // Sends value (0/1) to Physical LED
  if (value  == 0) {
    blynk.virtualWrite(2, 0);  // V2 Widget (BLUE) LED off
    blynk.virtualWrite(3, 255);  // V3 Widget (RED) LED on
  }   else if (value == 1) {
    blynk.virtualWrite(2, 255);  // V2 (BLUE) Widget LED on
    blynk.virtualWrite(3, 0);  // V3 (RED) Widget LED off
  }
});