Bluetooth Low Energy (BLE) is a wireless protocol well suited for ultralow-power sensors running on small batteries. It is optimized for low power communication and is not compatible with the original Bluetooth, referred to as Bluetooth Basic Rate (BR)/Enhanced Data Rate (EDR). BLE is described as a new protocol in the official Bluetooth 4.0 specification. It reuses many parts of the Bluetooth BR hardware and software stack to enable dual mode devices supporting Bluetooth BR/EDR and BLE. To design energy-efficient devices, the protocol provides a number of parameters that need to be optimized within an energy, latency and throughput design space. To minimize power consumption, the protocol parameters have to be optimized for a given application. Therefore, an energy-model that can predict the energy consumption of a BLE-based wireless device for different parameter value settings, is needed. As BLE differs from Bluetooth BR significantly, models for Bluetooth BR cannot be easily applied to the BLE protocol. Since the last one year, there have been a couple of proposals on energy models for BLE. However, none of them can model all the operating modes of the protocol. This paper presents a precise energy model of the BLE protocol, that allows the computation of a device's power consumption in all possible operating modes. To the best of our knowledge, our proposed model is not only one of the most accurate ones known so far (because it accounts for all protocol parameters), but it is also the only one that models all the operating modes of BLE. Furthermore, we present a sensitivity analysis of the different parameters on the energy consumption and evaluate the accuracy of the model using both discrete event simulation and actual measurements. Based on this model, guidelines for system designers are presented, that help choosing the right parameters for optimizing the energy consumption for a given application.