Avatar for user115800

user115800

Member since Jul 2020 • Last active Jul 2020
  • 1 conversations
  • 2 comments

Most recent activity

  • in General
    Avatar for user115800

    I just wanted to know if it is possible to log data from RuvviTag into a CSV file using Espruino. If any code is available it would help a lot.

    This is the code I'm using to print values on the console

    const period = 30*60*1000; // milliseconds (every 30 minutes)
    const length = 200; // number of records (for 100 hours / 4 days)
    
    var ruuvi = require("Ruuvitag");
    var records = [];
    
    function log() {
      ruuvi.setEnvOn(true);
      if (records.unshift({time:getTime(),temp:ruĀ­uvi.getEnvData().temp}) > length){
        records.pop();
      }
      ruuvi.setEnvOn(false);
    }
    
    function getData() {
      records.forEach( function(d,i) {
        console.log(i+"\t"+ d.temp +"\t"+ (getTime()-d.time));
      });
    }
    
    ruuvi.setAccelOn(true);
    setInterval(log, period);
    
Actions