Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can you access raw green LED data rather than HR? Also basic file writing question.

First question simply is there any way to access the raw data from the green LED or are we restricted to the already coded "HR" function? Is there no way to get to a deeper level? 

 

Secondly, I am totally new and useless. Could someone be a hero and tell me how to combine these two functions to set up a recorder and rather than send to console record that data to a text file instead. 

 

I know this is how to set up the sensor to record. But rather than "console.log" I want it to be saved as a text file. Well .CSV ideally but doesn't really matter. Effectively a text file of the console log with time stamp and then data for this sensor. Then after recording data I can extract the file and do whatever stats/manipulation I want. 

 

Hope someone can answer - i am a total novice so apologise for asking a bad question. 
Thanks!!!

import { Accelerometer } from "accelerometer";

if (Accelerometer) {
  // sampling at 1Hz (once per second)
  const accel = new Accelerometer({ frequency: 1 });
  accel.addEventListener("reading", () => {
    console.log(
      `ts: ${accel.timestamp}, \
       x: ${accel.x}, \
       y: ${accel.y}, \
       z: ${accel.z}`
    );
  });
  accel.start();
}

 

Best Answer
0 Votes
1 REPLY 1

At the moment, there's no way to get raw LED data from the API.

Getting sensor data into an accessible file is tricky. The broad outline is:

  • Get data on watch.
  • Watch sends data to companion app via messaging or file transfer.
  • Companion app send data to a server via fetch() or WebSocket. You can write your own server running on 127.0.0.1, or use a pre-existing web-based service.
  • Server saves the data to file.
  • Client (eg, browser) accesses server to obtain file.

I've roughly got this working for heart-rate data in near real time. Accelerometer data could pose an additional challenge because it can potentially accumulate much more rapidly, requiring faster comms (unless you don't want much of it).

Peter McLennan
Gondwana Software
Best Answer
0 Votes