Avatar for user155657

user155657

Member since Jun 2023 • Last active Sep 2024
  • 2 conversations
  • 7 comments

Most recent activity

  • in Bangle.js
    Avatar for user155657

    I recently saw following error when I am using Bangle.setHRMPower(1)

    Prompt not detected - upload failed. Trying to recover... VC31
    WHO_AM_I failed (0)

    I initially thought there is an error in my code and after trying some existing app on the app store and checking Bangle.js Data Streaming and the Heartrate monitor stream came to conclusion that my bangleJs2 isn't allowing me to use HRM anymore.

    When I am trying to any app or code related to HRM, my bangle JS2 is heating up. Even using a simple code to print on emulator is giving the same error and heating up the device.

    Bangle.setHRMPower(1);
      Bangle.on('HRM',function(hrm) {
        var d = [
          "H",
          hrm.bpm,
          hrm.confidence
          ];
        print(d.join(","));
      });
    

    Never experienced this issue before. I am not sure if I missed anything.

  • in Bangle.js
    Avatar for user155657

    Thank you very much.
    It is working :-)

  • in Bangle.js
    Avatar for user155657

    Thanks @Gordon
    Another quick question, do you think my approach of using Date.now()-timePast>100 for sampling rate is efficient or you recommend any other way?
    I took inspiration from Arduino millis() function

    Thanks again

  • in Bangle.js
    Avatar for user155657

    Thank you very much.
    I will try it today and update you

    Also var memory = require("Storage").getFree(); is a very good idea.

  • in Bangle.js
    Avatar for user155657

    Hello,

    I am a student who is to new JS and recently got my hands on to bangleJS2. As part of our student project we are planning to acquire motion and heartrate data from bangleJS2.
    The goal of the following code is to save outputs of accelerometer, magnetometer and heartrate sensor into a csv file. Due to storage limitation we are stopping it to record data when Flash is less than 0.75MB.

    We want to record at least two days worth of data.

    fileName = "rawData";
    Bangle.setCompassPower(1);
    var rawData = require("Storage").open(fileName+".csv", "a");
    Bangle.setHRMPower(1);
    var timePast = Date.now();
    Bangle.on('HRM-raw', function(hrm) {
      var memory = require("Storage").getStats();
      var hrmRaw = [
        "HRM:",
        hrm.raw,
        hrm.filt,
        hrm.bpm,
        hrm.confidence
      ];
      var c = Bangle.getCompass();
      var a = Bangle.getAccel();
      //Data order in the csv
      //timestamp, accelerometer[x,y,z], magentometr [x, y, g, dx, dy, dz], hrm [raw, filter, bpm, confidence]
      if(Date.now()-timePast>100){
        if (memory > 750000)
        {
        //1000000 Bytes = 1 MB (in decimal)
    rawData.write([Math.floor(Date.now()),a.x,a.y,a.z,c.x,c.y,c.z,c.dx,c.dy,c.dz,hrm.raw,hrm.filt,hrm.bpm,hrm.confidence].map((o)=>parseInt(o*1000)/1000).join(","));
      rawData.write("\n");
      timePast = Date.now();}
      else{
       g.drawString("Memory full", 50, 50)
      }}
    });
    

    When we are trying to call the data we are only retrieving only 550 rows of data, even though the csv is having more data, we aren't able to get more values
    We are using the following code in our script to read data

    //getting Data
    var getData = require('Storage').read('rawData.csv\1');
    var array = getData.split("\n");
    Bluetooth.println("<data>\n"+array[d]+"\n</data>");
    //Removing Data
    require("Storage").erase('rawData.csv\1');
    require("Storage").open("rawData.csv", "w");
    

    Is there a way to read all the rows from the csv file to array and send using ''Bluetooth.print''?

    Apologies for my clumsy code.
    Thank you in advance.

Actions