This application contains a module implementing the capture of device motion and orientation using Javascript and an example of how to use it.
Based on:https://www.w3.org/TR/2016/CR-orientation-event-20160818/