RMS filter for C-type sensor

Hi,

Is the FitnessTracker app only works for R-type sensors on Android? Seems like C-type sensor support was added later for IOS only.



I have a C-type sensor and would like to implement RMS filter for activity tracking, what sample app should I use?

 Thank you,
Michael

Comments

  • We do not have a fitness tracker app that uses the latest API.  The old API used by the app greatly differs from the new API so updating the project is not as simple as switching to the latest API.

    What you can do is implement the filter chain using the latest api. It is much simpler that the code outlined in the blog post.
  • Thank you Eric. Can you tell me why I don't get any output please?

    private Bmi160Accelerometer accModule = null;
    // on ready
    accModule = mwBoard.getModule(Bmi160Accelerometer.class);
    accModule.setOutputDataRate(5.f);
    accModule.setAxisSamplingRange(4);

    //((Bmi160Accelerometer) accModule).configureAxisSampling()
    // .setFullScaleRange( Bmi160Accelerometer.AccRange.AR_4G )
    // .commit();

    Log.i("tutorial", "mvOnReady");

    // on clicked start button
    accModule
    .routeData()
    .fromAxes()
    .process(new Rms())
    .stream("acc_stream")
    .commit()
    .onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
    @Override
    public void success(RouteManager result) {
    result.subscribe("acc_stream", new RouteManager.MessageHandler() {
    @Override
    public void process(Message msg) {
    Log.i("tutorial", msg.getData(Rms.class).toString());
    }
    });
    Thanks!
  • You have to start the accelerometer and enable axis sampling.  See:

    Also, rms data is interpreted as a float.  The Rms class is not a valid data type.
  • That worked! Thanks a lot!

    If I may to ask another question here.

    I need to upload RMS average over 15 minutes but the "average" module only accept 128 sample points.
    If I use 12.5 sampling rate for 15 min * 60 = 900 seconds my average over 900*12.5= 11,250 times.
    I can do that on the phone but I thought I may save the battery life  if I only connect and get  data every 15 minutes.
    .process(new Rms())
    .process(new Average((byte) 128))// 12.5 times per second ->900*12.5= 11,250 times

    .process(new Time(Time.OutputMode.ABSOLUTE,9000000)) // 900 sec, getting only last 128?
    What would be the best way to accomplish this and what is the best practices to prolong the battery life?
    Thank you!
    Michael
  • edited May 2016

  • The average is a running average, not a true average over N samples.  If you need a true average, you could sum up the rms values over a 15 min period, record that value and reset the accumulator.
  • Thank you Eric for the suggestion but I am getting a very strange results now.
    RMS was in 0.5-0.6 range.
    When I totaled it over 3 seconds I was expecting to get 3*12.5*0.5= 18.75, I am seeing 2-3
    and numbers are changing without me touching the sensor.
    .process(new Rms())
    .process("accum_proc", new Accumulator())
    .process(new Time(Time.OutputMode.ABSOLUTE,3000)) // 3 sec
    .process(new Maths(Maths.Operation.DIVIDE, 1.0)) // must be 3*12.5=37.5
    .monitor(new DataSignal.ActivityHandler() {
    @Override
    public void onSignalActive(Map<String, DataProcessor> processors,
    DataSignal.DataToken token) {
    processors.get("accum_proc").setState(new Accumulator.State(0));
    }
    })
    05-20 17:37:51.766  { "d": {  "ts": "2016-05-20 17:37:51","rms":"3.6166992"}}
    05-20 17:37:54.836  { "d": {  "ts": "2016-05-20 17:37:54","rms":"2.375"}}
    05-20 17:37:57.956  { "d": {  "ts": "2016-05-20 17:37:57","rms":"3.6193237"}}
    05-20 17:38:00.976  { "d": {  "ts": "2016-05-20 17:38:00","rms":"1.75177"}}
    05-20 17:38:04.046  { "d": {  "ts": "2016-05-20 17:38:04","rms":"3.6175537"}}
    05-20 17:38:07.116  { "d": {  "ts": "2016-05-20 17:38:07","rms":"2.3759155"}}
    05-20 17:38:10.286  { "d": {  "ts": "2016-05-20 17:38:10","rms":"3.616516"}}
    05-20 17:38:13.356  { "d": {  "ts": "2016-05-20 17:38:13","rms":"2.3738403"}}
    05-20 17:38:16.426  { "d": {  "ts": "2016-05-20 17:38:16","rms":"3.6172485"}}
    05-20 17:38:19.406  { "d": {  "ts": "2016-05-20 17:38:19","rms":"1.7537231"}}
    05-20 17:38:22.476  { "d": {  "ts": "2016-05-20 17:38:22","rms":"3.6200562"}}
    05-20 17:38:25.596  { "d": {  "ts": "2016-05-20 17:38:25","rms":"2.9978638"}}
    05-20 17:38:28.616  { "d": {  "ts": "2016-05-20 17:38:28","rms":"2.3742065"}}
    05-20 17:38:31.686  { "d": {  "ts": "2016-05-20 17:38:31","rms":"3.614441"}}
    05-20 17:38:34.756  { "d": {  "ts": "2016-05-20 17:38:34","rms":"2.371643"}}
    thank you,
    Michael
  • Increase the output size of the accumulator.
  • Worked! 

    Thank you Eric.

  • How did you get readable time format.I am getting raw data, here is my code. Please guide
    public void success(RouteManager result) {
    result.subscribe(STREAM_KEY, new RouteManager.MessageHandler() {
    public void process(Message msg) {
    Log.i(TAG, String.format("Accelerometer: %s", msg.getData())); sensorMsg(String.format(msg.toString()), "accel");
  • you mean this:float fRMS = msg.getData(Float.class);
  • you mean this:
    float fRMS = msg.getData(Float.class);
  • if you need date/time : java.sql.Date date = new java.sql.Date(msg.getTimestamp().getTimeInMillis());
  • Thanks Mikesv, I got the desired results
     

  • FYI,  the fitness app has been updated,  but it uses the build in step counter instead of the RMS,  but it is possible to chain things.
This discussion has been closed.