Acceleration Logger

This topic is dedicated to comments and conversations about the following RuuviLab tutorial:

If you don’t see any comments yet, don’t be afraid to be the first one to contribute!

1 Like

Hello! This challange is still up? I have an use case that I wanna try to solve with this RuuviTag’s Acceleration Module.
Thanks

MVP implemented. This logs highest G force acceleration data for each hour. Stored values can be read from RuuviTag also with a phone using web bluetooth (tested).

var Ruuvitag = require(“Ruuvitag”);

var x = 0;
var y = 0;
var z = 0;
var g = 0;
var maxG = 0;
var hour = 0;
var lasthour = 0;
var records = [];

function getData() {
for (var i in records) {
console.log(i + “,” + records[i]);
}
}

Ruuvitag.setEnvOn(true);
Ruuvitag.setAccelOn(true);

Ruuvitag.setAccelOn(true, function(xyz) {

x=xyz[“x”];
y=xyz[“y”];
z=xyz[“z”];

g = Math.sqrt(x * x + y * y + z * z);

g=g/1000;

hour = Math.floor(getTime()/3600);

if (hour != lasthour) {
maxG = 0;
}

lasthour = hour;

if (g>maxG) {
records[hour] = g;
maxG = g;
}

});

Ruuvitag.accel.setPowerMode(“highres”);

Nice, I’l get this tested ASAP. Could you make quick instructions on how to read the results with web bluetooth?

I used WebBLE app on iPhone to connect to RuuviTag with Espruino IDE (https://www.espruino.com/ide/).

In the console calling method “getData();” prints the logged data to iPhone screen. It possibly depends on the use case whether this approach is enough for a MVP.

For me the main challenge was to figure out getting the resolution enough to detect sudden accelerations, get the overall acceleration instead of x, y or z alone and to think what are the value units since I could not find all needed documentation for the library.

Better user experience for some use cases is probably needed. I like the idea though that I’m able to read the acceleration data of a received package wirelessly even before signing acceptance of the delivery.

Seems to work nicely, I’ll take a tag to my pocket and go outside for a while. Let’s see how gentle courier I am :slight_smile:

Ok, test run is complete:

getData()
0,3.44831616871
1,3.42316583123
2,1.03326865783
3,1.03170211591
4,1.03242656751
5,1.03156298887
6,1.03170211591
7,1.03072968274
8,1.42825996545
9,1.41050415819
10,1.02669931368
11,1.03453419546
12,1.02650330255
13,1.02599963313
14,1.06017272981
15,1.02596291693
16,1.29443129140
17,3.44944242311
18,3.38152262210

It’s easy to see when I’ve been on the go :slight_smile:
@lauri Can you update the idea with this solution?
@js please contact @henri to get your tags shipped

RuuviTag is pretty neat :slight_smile: I just contacted @henri via email.

Hi,
we are looking at using Ruuvi Tags with our app to LOG TEMP, HUM & VIBRATIONS similar to what you are proposing here with vibrations. The data would stored on the Tag itself and then read out via BT or other later. Storage should last 6-8 weeks so storing maximums over 1hr as proposed would make sense.
Would you be interested in coding this? Let me know.

Hello,

You can also post in our matchmaking section where more people can find your post:
https://f.ruuvi.com/c/matchmaking

Hi,

Is this still relevant? I have a code, which could meet your requirements. Might depend on your use case what kind of tweaks the code needs. I could also possibly propose some more ideas around this.

Hi JS
Still relevant. Can you contact me directly via
rod at roderich dot com?