The IEEE 802.15.4 protocol is widely adopted as the standard for the physical and MAC layers of wireless sensor networks. Among other mechanisms, it implements a mechanism called duty cycle that defines the node's active time during the network lifetime. This paper proposes a dynamic beacon interval and superframe adaptation algorithm (DBSAA) that adjusts the network duty cycle through two MAC layer parameters: the Beacon Order (BO) and the Superframe Order (SO). The parameters adaptation is triggered by the changes in the traffic load (i.e. increase or decrease due to modification in the environment). Using DBSAA, the network coordinator adjust the BO and SO parameters based on four parameter estimations: the superframe occupation ratio, the collision ratio, the number of packets received by the coordinator, and the number of source nodes. Performance evaluation results show that the duty cycle adaptation taking into account the BO and SO values meets the trade-off defined by the application requirements and energy consumption while compared to two other protocols: the standard 802.15.4 protocol, which does not perform duty cycle dynamic adaptation; and the DSAA (Dynamic Superframe Adjustment Algorithm), which adapts the duty cycle by adjusting only the SO parameter.