Internet of Things (IoT) is one of the main features in 5G. Low-power wide-area networking (LPWAN) has attracted enormous research interests to enable large-scale deployment of IoT, with the design objectives of low cost, wide coverage area, as well as low-power consumption. In particular, a long battery lifetime is essential since many of the IoT devices will be deployed in hard-to-access locations. Prediction of the battery lifetime depends on the accurate modeling of energy consumption. This article presents a comprehensive power consumption model for battery lifetime estimation, which is based on user equipment (UE) states and procedures, for two cellular IoT technologies: 1) Narrowband IoT (NB-IoT) and 2) long-term evolution for machines (LTE-M). A measurement testbed has been set up and the proposed model has been tested and validated via extensive measurements under various traffic patterns and network scenarios, achieving the modeling inaccuracy within 5%. The measurement results show that the battery lifetime of an IoT device can reach up to ten years as required by 3GPP, with proper configuration of the traffic profile, the coverage scenario, as well as the network configuration parameters.