Getting the acceleration from ADXL345 and using it to make a decision.

Hello Everyone. Hope you all are in good health.
I’ve recently started working on the project and i have been stuck on this for as long as i can remember.

Basically, i have an ADXL345 Accelerometer which i have to integrate with an NodeMCU Esp8266.
I just need the acceleration (that is if the object is moving or not) and then i have to make a decision based on that acceleration value that i have got.
we have 2 accelerometers and 2 NodeMCU’s. they`ll communicate with each other.

I.E, if the object is in motion, Esp8266 will join an access point(created by another Esp8266). If the object is in rest it will create an access point.

Thank you for taking the time to read this and for your help.

An accelerometer will not sense motion. It senses change in motion in its sensitive axis. If an object is stopped or at a steady velocity the acceleration is zero.

what should my next step be then? what should i replace the accelerometer with?

Thank you for your help.

I think that if the changes in acceleration are very low that you can consider the object 'stationary'. I would keep a moving average of readings and compare the current values to the averages. If the difference is above a threshold (to be determined by experiment) the object is moving.

  • First step: Print acceleration values for X, Y and Z accelerations.
  • Second step: Observe the reports to see what kind of range to expect in a stationary object.
  • Third step: Calculate a moving average for each axis and report the values.
  • Fourth step: Switch to "Moving" when the latest acceleration is outside the expected range of the moving average.