High speed streaming / workarounds for the streaming limit

edited May 2016 in Android
Is there some way to increase the speed of the streaming for the accelerometer? Changing the sampling rate does not have an effect.

For my application I want to stream the data and check against some movement signature. Then I want to store the accelerometer values at X ms before and after.

The sensor in the rpro has a max sampling speed of 1500hz but transmits it via stream at something like 100hz.

I saw that in another post ( http://community.mbientlab.com/discussion/1615/problems-with-low-sampling-frequency-on-ios ) the sampling frequency is limited at around 100Hz because of bandwidth issues. 

Would it be possible to stream the data at 100hz but keep a more detailed log on the device to be transmitted with more accuracy later?

For example, I store the last 3000 samples on the device, dropping off the oldest item whenever I record a new one. Simultaneously I stream the data. When I notice some characteristic movement in the streamed data, I retrieve those last 3000 entries from the device. Is this possible?


  • edited May 2016
    So I wrote some code, and I can see that the return value of getLogCapacity is 12160. If I record three accel values (x,y,z) does this mean that I can store the last (approximately) 12160/3/1600=2.5s of entries at max sampling? Or am I being naive?

    It seems like what I could do is set up the logger to record with overwriting enabled:
    and then ~ 1s after the characteristic movement is detected call stopLogging followed by logModule.downloadLog . This is perfect.

    The only problem is that it seems that the accel can be set up either as a logger or a streamer but not both. Is this correct?
  • edited May 2016
    Maybe I can use splitting and branching? I will try something like the following:

        .end().commit().onComplete(new CompletionHandler<RouteManager>() {
        public void success(RouteManager result) {
    result.setLogMessageHandler(LOG_KEY, loggingHandler );
    result.subscribe( streamingHandler );

  • edited May 2016
    On a blog I see it written:
    It’s important to note that you cannot stream and log on the same route. Also, simultaneously streaming and logging data is not a recommended use case.
    However I was able to implement it and it is both streaming and logging using my code in the above post. What issues should I anticipate?

    Now is downloading the entire log (I think), is there some way I can only download the last N recorded entries?
  • There is nothing wrong with logging and streaming simultaneously; that blog post is wrong. However, the second statement is correct, streaming and logging the same data is not a recommended use case.

    You don't need a splitter to log and steam. The splitter is for data processors, as searched in the documentation:

    What you can do is set the odr to your desired rate and use a time filter to reduce the streaming rate.
  • edited May 2016
    Thanks for pointing out the part about the splitter. Code works fine without it.

    When I read from the sensor it does not return the oldest element first. Compare the following (the top is the same movement as read in the log...it takes about two minutes to retrieve a full buffer)
    Notice in particular that in the top chart the motion seems almost cut off... unlike the bottom buffer where I only recorded for a few seconds. This is with a streamer and a logger enabled. The streamer reads off the 'rough' data, and when it recognizes a movement it will pull the precise readings from the log.

    If I use a filter on the log I won't be able to get streaming data to the device...I think it would be quite clever to use a filter but I don't see how it would be useful since the whole point is finding some way to workaround the streaming limit.

    Looking at the Time documentary page it looks like it is used to remove sampling frequency... 
    public Time(Time.OutputMode mode,
    int period)
    Constructs a config object for a time data processor
    mode - Operation mode of the processor
    period - How often to alllow data through, in milliseconds
    I want max frequency but only for, say, the last one second of data. Everything else seems fine: I just want to be able to be able to pull a log in the proper order, ideally only the last N entries. Is there any way to do that?

    Thanks for the help so far.
  • edited May 2016
    Here is my code for retrieving the log data:
        Logging loggingModule = mwBoard.getModule(Logging.class);
        final Bmi160Accelerometer bmi160AccModule = mwBoard.getModule(Bmi160Accelerometer.class);
        // first stop the accel:
        loggingModule.downloadLog(0.05f, new Logging.DownloadHandler() {
        public void onProgressUpdate(int nEntriesLeft, int totalEntries) {
    Log.i("LOG", String.format("Downloading Log: Progress= %d / %d", nEntriesLeft,
  • If I leave the log active for some long time there are all sorts of pathological findings...this one is clearly cut off. I let it sit recording on my desk for a minute or two and then moved it around a bit right at the end... there are only about twenty elements (at the very beginning) of the 800hz recording which are nonzero. Why did this happen?
  • Overwriting does not work if you are connected to the board; it looks like you are reading data from earlier runs.  You can clear the log by downloading it or issuing a clear command, then disconnecting.

    Log data is returned in chronological order so you will have to download the entire log to get your desired data.
This discussion has been closed.