The formula your brother suggested is calculating the total magnitude of the acceleration vector, this might be what you’d use in combination with calculating the angle of the vector to determine the speed/direction of movement. I’m not sure how useful this- or indeed my own crude formula- is to measuring vibrations from passing trucks, since they will usually be noisy and unpredictable.
What you might find, if you were to plot X, Y and Z individually, is some (to possibly misuse a phrase) correlated noise between them. That is to say that if a passing truck causes a vibration on X, it’s possible that it produces an event of a similar magnitude and time on Y and Z.
Now a vibration is, in all but the most extreme of cases, generally also an audible sound and there are ways to process audible sound (and any other signals involving magnitude measurements over time) in order to filter unwanted components and pay particular attention to frequencies of interest- these are a Low-pass Filter, and a Fast-Fourier Transform respectively.
Low Pass is, as its name might allude, a filter that allows low frequencies to pass through, while blocking high ones. In your case you would be interested in the mid frequencies that suggest truck vibrations but not the low frequencies or high frequency noise.
A crude implementation of a Low Pass filter is a moving average- this involves a sliding window of samples over time, and produces an average of those samples. This causes high-frequency noise to cancel itself out, while the lower frequency component is still visible.
IE: say we have the signals:
6 -1 1 -1 1 -1 1 and
6 0 0 0 0 0 0, these are all 7 samples long and when you take the average of them, they both give a single sample of
This is somewhat more complicated, and you should google for ways to apply this in Python because it’ll make this thread ten pages long if I try to approach it.
In brief, for signals like this FFT will transform a set of samples over a period of time into a collection of magnitudes for each frequency.
Careful application of FFT should allow you to measure the magnitude of the frequency group that corresponds to “trucks passing” at any given time.
Back on track…
You should probably start by applying a low pass filter - or moving average - across your data to attempt to cancel out some of the noise.
Since your logged signal is actually pretty low frequency anyway - it looks like once every 3-4sec - you should probably sample the accelerometer at a higher frequency and log the moving average value at a fixed rate- IE: once a second.
Try logging the X/Y/Z individually, plotting them, and looking for correlations. It might also help to either grab a timer and manually log every time a truck passes, or set up a microphone so you can correlate points of interest in your data with actual events and see if things line up.
If you go the microphone route (audacity recording from a laptop mic might even do) give the desk a couple of slaps to generate a spike that both the accelerometer and microphone will log for syncing up.