Avatar for Melonator

Melonator

Member since Jul 2018 • Last active Aug 2018
  • 2 conversations
  • 12 comments

Most recent activity

  • in Other Boards
    Avatar for Melonator

    Cool. Thanks for the suggestions!

  • in Other Boards
    Avatar for Melonator

    On another slightly related track, Once I get values and store them to the RuuviTag, is there a way to move them to the internal storage of the raspberry pie? Or does the Espruino IDE have the capability to store data locally?

  • in Other Boards
    Avatar for Melonator

    Thanks a lot, that really helps!

  • in Other Boards
    Avatar for Melonator

    Hey, I'm not sure if this is the right place to ask but I'm having a problem combining two Espruino/JavaScript concepts on my RuuviTag sensor beacon and I was wondering if anyone here had any insight into the matter.
    Basically, I'm trying to use a variation of the program on this web page: [https://lab.ruuvi.com/temp-logger/]

    But I'm trying to modify it so that I can store a lot more values by lowering the precision and storing values that take up less space in the RuuviTag memory.
    For that purpose I found this Espruino method which supposedly lets you store sensor reading as 8 bit integers instead of 32 or 64 bit floats: [https://www.espruino.com/Data+Collection­]
    Here is what I have right now:

    const period = 1000; // milliseconds (every 30 minutes)
    const length = 10; // number of records (for 100 hours / 4 days)
    
    var ruuvi = require("Ruuvitag");
    var records = new Int8Array(length);
    
    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);
    

    When I upload and run this code it says this over and over:

    in function called from system
    Uncaught Error: Function "unshift" not found!
     at line 2 col 15
      if (records.unshift({time:getTime(),temp:ru­uvi.getEnvData(...
                  ^
    

    And when I type the getData() command into the left side while the program is running I get this:

    in function called from system
    >getData()
    0   undefined   NaN
    1   undefined   NaN
    2   undefined   NaN
    3   undefined   NaN
    4   undefined   NaN
    5   undefined   NaN
    6   undefined   NaN
    7   undefined   NaN
    8   undefined   NaN
    9   undefined   NaN
    =undefined
    

    Am I missing something about the code? Or is it harder than I think it is to log values that take up less space in the memory? I don't see any reason why the unshift function would not be found. If unshift won't work for this type of operation, is there something else that will?

  • in Other Boards
    Avatar for Melonator

    Perfect! Thanks a lot!

  • in Other Boards
    Avatar for Melonator

    Hello there,

    I'm having an issue using Espruino Web IDE on a Raspberry Pi with the RuuviTag sensor. When I upload some code I found online to run the sensors on the RuuviTag device I get a screen that looks like the attached screenshot. It kind of looks like it isn't finding the necessary library. Does anyone know how to get past this issue?

Actions