You are reading a single comment by @Frida and its replies. Click here to read the full conversation.
  • Is it somthing like this.
    I made this on my Puck to get ruuvi tags and display the results.
    The ruuvi tags are emitting raw values in "Manufacturer specific data".

    // pucktest05
    
    setBusyIndicator(LED1);
    var darray = {};
    var tg = 0x2F; // 0x2F ^ 0x73 = 0x5C
    var count = 0;
    
    
    function getDewpoint(temp, humi) {
    
      var C = {
        a1 : 8.1332,
        b1 : 1762.39,
        c1 : 235.66
      };
    
      PP = Math.pow(10,C.a1 - C.b1 / (this.temp + C.c1));
      this.dewp = -((C.b1 / (Math.log(this.humi * PP / 100) / Math.log(10) - C.a1)) + C.c1);
      return this.dewp.toFixed(2);
    }
    
    function bprint(dada, navn) {
      humi = dada.data[8] / 2;
      temp = dada.data[9] + dada.data[10] / 100;
      if(temp >128) {temp = 128 - temp;}
      bati = (dada.data[19] * 256 + dada.data[20]);
      dewi = getDewpoint(temp, humi);
      console.log(navn +
                  dada.rssi +
                 '  ' + temp.toFixed(2) +
                 '  ' + humi.toFixed(1) +
                 '  ' + dewi +
                 '  ' + bati);
    }
    
    function cprint(didi) {
      tg ^= 0x73;
      console.log('count: ' + count++);
      console.log(String.fromCharCode(tg) +
                     ' ' + NRF.getBattery().toFixed(3));
      console.log('   Sted  Rssi  Temp  Humi   Dewi  Bati');
      bprint(didi[0], '    Ude: ');
      bprint(didi[1], 'Drivhus: ');
      bprint(didi[2], '    Bad: ');
      bprint(didi[3], 'Udestue: ');
      console.log(' ');
    }
    
    function find() {
      NRF.findDevices(function(devices) {
        console.log(devices.length);
        for(i=0;i<devices.length;i++) {
          if(devices[i].id == 'ce:5c:55:08:22:5a random') {
            darray[0] = devices[i];
          }
          if(devices[i].id == 'da:dc:f2:19:d4:e3 random') {
            darray[1] = devices[i];
          }
          if(devices[i].id == 'fa:2e:7b:6d:97:e0 random') {
            darray[2] = devices[i];
          }
          if(devices[i].id == 'fc:62:2d:b7:96:30 random') {
            darray[3] = devices[i];
          }
        }
        cprint(darray);
      }, 3000);
    }
    
    find();
    setInterval(function () {
      find();
    }, 60000);
    
    
    
About

Avatar for Frida @Frida started