TensorFlow Lite

Has anyone tried using TensorFlow Lite on the ruuvi? I would like to apply a model to the accelerometer so that only a trained motion triggers the accelerometer. The trigger data in turn, would be sent to a gateway for cloud access.

The goal is to avoid false positives and increase battery life.

Thanks in advance

I took a quick look at it once, and it seemed that the Tensorflow needs a beefier MCU,

For example https://www.tensorflow.org/lite/guide says that binary is 300 kB, current Ruuvi Firmware build has less than that in free Flash. Maybe you could squeeze it in if you can disable optional features both in Ruuvi FW (GATT, flash logging) and in Tensorflow

1 Like

@otso

Thanks for your reply and for taking time to research the possibility. This is what had lead me to believe it might work.

The supported boards seem to have nRF52840, which has 256 kB of RAM and 1 MB of flash, compared to 64 kB + 512 kB on RuuviTag’s 52832.

On the other hand, Tensorflow advertises being able to fit in 16 kB, which is similar to RuuviTag’s flash logging memory requirements so I’d guess there is a chance if you drop the flash logging.

My approach would be to start with https://codelabs.developers.google.com/codelabs/ai-magicwand/#0 written for 840 and if it works, look into porting the project into RuuviTag. Code written on 832 usually works just fine on 840, other way around the memory limitations may be a problem.

In any case, you’re looking at somewhat big project. I would start by taking a step back and think about alternative approaches. Maybe your goal of sending data on trigger to could could be achieved in some easier way, for example by using double-click interrupt built-in to LIS2DH12.

Thank you for your detailed reply and suggestions

I came across this today: https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/nrf-tensorflow-support .
Apparently Zephyr has some integration with Tensorflow, but it’s not tested on 52832

Thank you @otso, I just saw your reply. For some reason I am not getting notifications as expected.

I also found this link

Similar to my use. My issue is I want to monitor the state of a “door” however, the “door” is subject to vibration and I do not wish to monitor vibration. I had hoped that by modeling the desired motion, I could sleep the LIS and only wake up when the trained motion is recognized which would translate into longer battery life.

Still reading and learning about what I can do with Ruuvi.