There is a physical device (sensor) which I can rotate. The device sends its X Y Z coordinates and a calculated acceleration vector in mg (mill mg). I can read this data from this device by using BLE. The device should lie flat while transportation, so I need to calculate how many degrees each side of the device is up or down.

Let me illustrate:

So, what I need to find out is how many degrees the device’s central vector (I guess?) is off the X Y Z axis?

Any help is greatly appreciated. Please, let me know if I should update my answer or give more details.