Pervasive healthcare is one of the most important applications of the Internet of Things (IoT). As part of the IoT, the wireless sensor networks (WSNs) are responsible for sensing the abnormal behavior of the elderly or patients. In this article, we design and implement a fall detection system called SensFall. With the resource restricted sensor nodes, it is vital to find an efficient feature to describe the scene. Based on the optical flow analysis, it can be observed that the thermal energy variation of each sub-region of the monitored region is a salient spatio-temporal feature that characterizes the fall. The main contribution of this study is to develop a feature-specific sensing system to capture this feature so as to detect the occurrence of a fall. In our system, the three-dimensional (3D) object space is segmented into some distinct discrete sampling cells, and pyroelectric infrared (PIR) sensors are employed to detect the variance of the thermal flux within these cells. The hierarchical classifier (two-layer HMMs) is proposed to model the time-varying PIR signal and classify different human activities. We use self-developed PIR sensor nodes mounted on the ceiling and construct a WSN based on ZigBee (802.15.4) protocol. We conduct experiments in a real office environment. The volunteers simulate several kinds of activities including falling, sitting down, standing up from a chair, walking, and jogging. Encouraging experimental results confirm the efficacy of our system.