The IEEE 802.15.4 standard for wireless sensor networks can support energy efficient, reliable, and timely packet transmission by tuning the medium access control parameters macMinBE, macMaxCSMABackoffs, and macMaxFrameRetries. Such a tuning is difficult, because simple and accurate models of the influence of these parameters on the probability of successful packet transmission, packet delay and energy consumption are not available. Moreover, it is not clear how to adapt the parameters to the changes of the network and traffic regimes by algorithms that can run on resourceconstrained nodes. In this paper, an effective analytical model is used to derive an adaptive algorithm at the medium access control layer for minimizing the power consumption while guaranteeing reliability and delay constraints in the packet transmission. The algorithm does not require any modifications of the IEEE 802.15.4 standard and can be easily implemented on existing network nodes. Numerical results show that...