The emergence of wearable miniature inertial measurement unit (IMU) sensors is a powerful enabler for lying motion data extraction. Consumer wearable sleep devices with inertial measurement capability are in the market with some having limited functions such as automatic sleep detection, awakening, determination of sleep position changes and sleep efficiency. In this study, an IMU sensor is used for capturing 3D motion data. A spectrogram based algorithm for feature extraction from the motion data is proposed and implemented. Using the generated spectrogram based features, the long term short memory (LSTM) recurrent neural network (RNN) model is used for recognition of sleeping positions. The test results show that an accuracy of 99.09% can be achieved in a supervised learning mode. A real-time feature extraction and recognition system is developed to implement the proposed algorithm.