🛠 Energy-Aware Automation with M5Stamp Timer Power 2
Objectives
This tutorial aims to configure the M5Stamp Timer Power 2 for a deep sleep cycle with scheduled wake-up, sequentially activating power rails to minimize average consumption below 15 µA.
Required Hardware
- M5Stamp Timer Power 2 module (S021)
- Host microcontroller (e.g., ESP32 or STM32)
- 5V DC power supply or 3.7V LiPo battery
- Connection cables (I2C SDA/SCL, GPIO IRQ)
- Logic analyzer or multimeter for current measurement
Steps
- I2C Initialization: Configure the I2C bus to 400 kHz. The device address is
0x6E. Verify communication by reading the ID register. - Output Configuration: Enable the LDO regulator (
3V3_LDO_OUT) for the host and the DC-DC converter (3V3_DCDC_OUT) for peripheral sensors. Adjust the charge current to 180mA for maximum autonomy. - Wake-up Programming: Configure the internal timer for a wake-up every 60 seconds. Set the
Sleep Modeto achieve a consumption of 6.72 µA. - Interrupt Management: Map a GPIO pin to an external interrupt (IRQ) for critical events (e.g., button press), allowing asynchronous wake-up.
- Main Loop: In the host code, after task execution, send the sleep command via I2C. Wait for the wake-up interrupt.
Verification
Measure the supply line current with a multimeter in µA mode. In sleep, the value should be close to 6.72 µA. During wake-up, observe the activation of the 3V3 outputs. Check the stability of the EXT_5V_INOUT voltage under load.
Further Reading
Integrate internal ADC readings to monitor battery voltage. Implement deep-discharge protection logic by cutting outputs if voltage drops below 3.3V.