Thanks to the technological development on the last decades, inertial sensors have reduced their size to the point of occupying a small space inside a smartphone. The information of these sensors has been exploited in order to recognize human activities using different approaches, especially using machine learning techniques. This paper presents a human activity recognition (HAR) system that uses accelerometer and gyroscope data obtained from a smartphone as inputs to a bidirectional long short-term memory (LSTM) network. Six human activities were recognized: sitting, standing, laying, walking, walking upstairs, and walking downstairs. Different network architectures were tested using a grid search methodology. We have found that the easiest activity to recognize was laying down whereas the most difficult activity to recognize was sitting. Thanks to the property of bidirectional LSTM networks to process past and future information of a signal, walking downstairs and walking upstairs (two related activities) were recognized correctly. An overall accuracy of 92.67% was obtained using the proposed HAR system.