Securing the wireless Internet of Things (IoT) is a challenging issue do to their technological constraints: limited computing power, restricted batteries or inconsistent energy supply. With more than 26 billion devices connected in 2019, the expected 75 billion things by 2025 will require an even higher energy supply. Meanwhile, as smarts cities, industry and healthcare represent more than 75% of the IoT market share, these devices must be secured while limiting the impact on energy consumption. The lifetime of specific devices such as Wearable or Implantable Medical Devices (WMDs, IMDs) can then be significantly impacted. In this paper, we propose a generic design that dynamically reduces the energy consumption required by the addition of security within the IoT networks, according to the local level of battery use. This self-monitored, fully-automated, low-cost and remotely configurable mechanism adjusts the number of encryption rounds of the cryptographic primitive while guaranteeing the minimum level of security required. This method has been integrated into the Constrained Application Protocol (CoAP) with the Datagram Transport Layer Security (DTLS) using the AES-128 encryption standard, with 10 rounds (full) to 7, and can be implemented on other protocol stacks. We show a reduction in CPU power consumption of a Raspberry Pi of 19.67%. Finally, we estimate its efficiency by simulating the discharge of multiple batteries with different capacities. Our mechanism increases operating time up to 33 minutes and 15 seconds for a 10,000mAh Raspberry Pi battery when 150 messages of 4Kb per second are exchanged with an operator.