LIS3DH Asset tracker vibration detection

Hello All,

I am not a programmer and i am trying to learn so please excuse me.

I have an application to remotely monitor a motor when its ON and OFF and I am thinking the best option is to use asset tracker with built in “LIS3DH” to detect the motor vibration, so when the motor is ON then I can see that from the acceelerometer range, unless you have a better idea which I will be thankful if you share it with me.

I have a bit of problem in coding wise using the LIS3DH, I can read “t.readXYZmagnitude” but i can not set the threshold in appropriate way because it is difficult to detect, for example when no vibration it reads around 8000 equivalent to 1G, that is fine I can set the threshold to be:

if (t.readXYZmagnitude() > 8500) then the motor is ON,

but the problem is when I shake it it reads negative and reads less than 4000 sometimes while i am shaking it , so i need a help of how to set up the right way to detect the motor if its ON or OFF also is there away to make sleep till the motor vibrant then the electron wake-up and send signal till the motor off again then sleep.

Appreciate your help.

I assume that’s to be expected since you’ll have a permanent acceleration of 1g downwards (-Z direction) due to Earth’s gravity.

yea i expected that as well, in fact from previous topic in here, it clearfied from @rickkas7

The LIS3DH returns a 16-bit two’s complement value (-32768 to 32767).

The value is relative to the sensitivity, which can be 2G, 4G, 8G, or 16G. The hardware defaults to 2G, however the AssetTracker library overrides this to be 4G by default.

In the default 4G setting, 32767 should be +4G, so 8000 seems about right for the effect of gravity.

the problem is how to setup a threshold as this Z direction sometimes goes to negative, all i want is to get notification when the motor is on and off, assume when the motor off the LIS3DH z-direction is 8000, i can setup that as a motor off status but when i shake it i can read negative number so its difficult to make this indication,

You’d first normalise (subtract the bias) and then use the abs() function.


I’ve just found this:

constrain(x, a, b); I think its the function that will meet my requirement, I will try it and let you know.

Thank you very much

Random thoughts:
Assuming this is an AC motor, you might be able to simplify your project with a $5-10 split-core CT instead of the Asset Tracker, since you only want to know when the motor is running. The CT (w/ burden resistor) will produce a voltage when the motor lead has current, which “could” be used to Wake the Electron.

Since you are monitoring an electric motor, figuring out how to provide a constant power source for the Electron would also help to simplify the project (no battery, no sleeping, etc).

1 Like

Tank you very much @Rftop, its really great, i am just thinking i want something compact i.e one box stick on the side of motor, however by using the CT we will run a cable between the electron the sensor CT if i am right.

but i really like the idea i am going to try it.

appreciate it


@majj_11, if you are considering purchasing a complete board, take a look at this one instead:

You would mount it in the existing control panel. The split-core CT will snap around the motor wire verses routing the wire to the NCD board. You also get to customize your AMP rating for increased measurement accuracy. If the control panel has a DC source (usually 24VDC) , use it to power the NCD board & Electron and don’t worry about Sleeping.

If the motor is turning a pump, you can relate the AMPs to the amount of work being performed (gallons, GPM, etc). Obviously you can track min/max AMPS, run-times, etc.

It’s worth mentioning that you can monitor up to 6 motors (various NCD Boards w/ different # of channels) from 1 board, which makes a project like this more cost effective per motor monitored.

I appoligize for the Scope Creep and getting way off topic.
This direction isn’t a “tiny box stuck to the side of the motor”.
Your previous plan would be much better for that goal :grin:.

1 Like

@Rftop, thank you very much, yes that is help a lot.

your way is more robust i can tell :wink:

@Rftop and @majj_11 this is a great topic and one I am interested in.

I can see the benifit in both, but majj_11’s acceelerometer approach has most of my attention.

I believe the decision point is invasive (current sensor, even if its clip on you still have to open up equipment enclosures to clip it on to something) vs. non-invasive (sensor pack is slapped on via magnets and you are done). To clarify, I am assuming battery power for either case.

Of course, the non-invasive acceelerometer will take more data filtering and manipulation to output helpful data metrics that are actually useful to determine equipment status (on / off) and health (increased vibration over time, etc.). I don’t know if this level of data filtering and manipulation is possible to create an equally robust data output when compared to the invasive split-core CT.

1 Like

If you’re looking for true vibration monitoring for a predictive maintenance program, then you’re better off with a combined inertial module.

There are several finished wireless products on the market for vibration monitoring, but most use BLE for comms :smirk:.

@Backpacker87 and @Rftop, thank you very much.

well, it depends on the application, for example if the application is not critical i.e. they don’t care about data like in my application, the main requirement is when the motor ON and when its OFF, so if i set up a low cost vibration sensor or accelerometer “advantage here its “built in” in asset tracker” so we can setup a threshold depends on the motor size. i.e. when vibration > 1G then the motor is ON, else the motor is OFF.

1 Like

@majj_11, good clarification on application.

1 Like

The LIS3DH has built-in filtering. If you select a high-pass filter you mostly eliminate the effect of gravity and only get movement/vibration above the filter’s cut-off frequency.

1 Like

Thank you very much @tve , could you explain more on how to choose that filter and activate it if its the right word, it will amazing to have that filter in my application.

Appreciate it.

Have you read the official datasheet (Section 8.9) and application note Section 4.3?

1: You are trying to detect motor rotation. If the motor is well balanced, it may not vibrate much so other vibrations may cause false indications.

2: A current transformer may indicate current when a motor is stalled, but the motor is not actually rotating.

If indeed you want to sense if a motor is rotating or not use a shaft encoder of some type to detect shaft rotation directly. This can be a magnet / hall effect sensor combo or a photo interrupter wheel and photo transistor / led sensor or a variable reluctance sensor like is used on ABS brakes.

For reliable sensing, try to directly sense the parameter you are interested in, as opposed to sensing a secondary parameter which is less likely to be correlated as well as the first parameter. (For instance a motor would also heat up when used, so you could use a temperature sensor, but environmental changes could give false indications.)

Hope this helps.


I’d like to suggest a vibration sensor instead of an accelerometer or inertial sensor. Specifically a rolling ball sensor. I had an application recently where I was trying to detect a motor through vibration, and I used a rolling ball sensor without any problems. Essentially it acts like a switch, so just put a pullup or pulldown on there, set up the GPIO as an interrupt, and then you can use the number and frequency of interrupts to determine whether it’s running or not. The best part is that it consumes VERY little power depending on your pull value.

The specific part number I’ve been working with (because I needed very small) is Sensolute SEN-MVS0608.02 or SEN-MVS0409.02.

1 Like

Thanks @bobbaddeley, vibration sensor is really good and i have used it before, its low cost and it does the job but one of the disadvantages in my situation its not compact system, that is why i prefer to use for example accelerometer because its built in with asset tracker, so in industrial application you are looking for something “robust”.

This is my point of view.

Many Thanks