# Acceleration Logger

**URL:** <https://f.ruuvi.com/t/acceleration-logger/460>\
**Category:** 🇬🇧 RuuviLab (article comments)\
**Created:** [29 June 2017 09:41 UTC](https://f.ruuvi.com/t/acceleration-logger/460 "2017-06-29T09:41:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![lauri](https://f.ruuvi.com/user_avatar/f.ruuvi.com/lauri/32/18_2.png) [@lauri](https://f.ruuvi.com/u/lauri)\
**Post date:** [29 June 2017 09:41 UTC](https://f.ruuvi.com/t/acceleration-logger/460/1 "2017-06-29T09:41:49Z")

</div>

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

> **[RuuviLab - Acceleration Logger](https://lab.ruuvi.com/acc-logger/)**
>
> The mystery of how fragile shipments are handled will finally be solved!

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

---

<div class="post-metadata">

**Author:** ![marpereira](https://f.ruuvi.com/letter_avatar_proxy/v4/letter/m/f19dbf/32.png) [@marpereira](https://f.ruuvi.com/u/marpereira)\
**Post date:** [21 August 2017 11:14 UTC](https://f.ruuvi.com/t/acceleration-logger/460/2 "2017-08-21T11:14:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![js](https://f.ruuvi.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@js](https://f.ruuvi.com/u/js)\
**Post date:** [12 December 2017 23:29 UTC](https://f.ruuvi.com/t/acceleration-logger/460/3 "2017-12-12T23:29:57Z")

</div>

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”);

---

<div class="post-metadata">

**Author:** ![otso](https://f.ruuvi.com/user_avatar/f.ruuvi.com/otso/32/1651_2.png) [@otso](https://f.ruuvi.com/u/otso)\
**Post date:** [13 December 2017 09:45 UTC](https://f.ruuvi.com/t/acceleration-logger/460/4 "2017-12-13T09:45:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![js](https://f.ruuvi.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@js](https://f.ruuvi.com/u/js)\
**Post date:** [15 December 2017 19:54 UTC](https://f.ruuvi.com/t/acceleration-logger/460/5 "2017-12-15T19:54:20Z")

</div>

I used WebBLE app on iPhone to connect to RuuviTag with Espruino IDE ([https://www.espruino.com/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.

---

<div class="post-metadata">

**Author:** ![otso](https://f.ruuvi.com/user_avatar/f.ruuvi.com/otso/32/1651_2.png) [@otso](https://f.ruuvi.com/u/otso)\
**Post date:** [20 December 2017 14:22 UTC](https://f.ruuvi.com/t/acceleration-logger/460/6 "2017-12-20T14:22:01Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![otso](https://f.ruuvi.com/user_avatar/f.ruuvi.com/otso/32/1651_2.png) [@otso](https://f.ruuvi.com/u/otso)\
**Post date:** [21 December 2017 08:58 UTC](https://f.ruuvi.com/t/acceleration-logger/460/7 "2017-12-21T08:58:02Z")

</div>

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 🙂  
@lauri Can you update the idea with this solution?  
@js please contact @henri to get your tags shipped

---

<div class="post-metadata">

**Author:** ![js](https://f.ruuvi.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@js](https://f.ruuvi.com/u/js)\
**Post date:** [3 January 2018 14:04 UTC](https://f.ruuvi.com/t/acceleration-logger/460/8 "2018-01-03T14:04:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Roderick](https://f.ruuvi.com/user_avatar/f.ruuvi.com/roderick/32/1617_2.png) [@Roderick](https://f.ruuvi.com/u/Roderick)\
**Post date:** [8 May 2019 09:53 UTC](https://f.ruuvi.com/t/acceleration-logger/460/9 "2019-05-08T09:53:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![otso](https://f.ruuvi.com/user_avatar/f.ruuvi.com/otso/32/1651_2.png) [@otso](https://f.ruuvi.com/u/otso)\
**Post date:** [8 May 2019 15:36 UTC](https://f.ruuvi.com/t/acceleration-logger/460/10 "2019-05-08T15:36:02Z")

</div>

Hello,

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

---

<div class="post-metadata">

**Author:** ![js](https://f.ruuvi.com/letter_avatar_proxy/v4/letter/j/7bcc69/32.png) [@js](https://f.ruuvi.com/u/js)\
**Post date:** [16 May 2019 19:18 UTC](https://f.ruuvi.com/t/acceleration-logger/460/11 "2019-05-16T19:18:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Roderick](https://f.ruuvi.com/user_avatar/f.ruuvi.com/roderick/32/1617_2.png) [@Roderick](https://f.ruuvi.com/u/Roderick)\
**Post date:** [16 May 2019 20:46 UTC](https://f.ruuvi.com/t/acceleration-logger/460/12 "2019-05-16T20:46:49Z")

</div>

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