AtomS3R: sleep + wake up on IMU acceleration?
-
Hi all,
Is it possible to use the UIFlow 2.0 API to put the AtomS3R into deep or light sleep mode and then to wake it up if the accelerometer registers a large enough acceleration?
I'm a total noob, but I saw in the schematics that the IMU INT line is connected to something (XTAL_32K_N) so it should be possible somehow, right? But I saw nothing in the API for this.If it's not possible with UIFlow 2.0, is it perhaps doable with Arduino?
-
Yes, it is possible to put the AtomS3R into deep or light sleep mode and wake it up using the accelerometer, but this functionality is not directly available through the UIFlow 2.0 API. However, you can achieve this using Arduino by leveraging the ESP32's low-power features and the accelerometer's interrupt capabilities.
Steps to Implement in Arduino:Deep/Light Sleep Setup:
Use the esp_sleep_enable_ext0_wakeup() or esp_sleep_enable_ext1_wakeup() functions to configure the wake-up source from the accelerometer's interrupt pin.
The accelerometer's INT pin is connected to XTAL_32K_N (as you noted), which can be used as a wake-up trigger.Accelerometer Configuration:
Configure the accelerometer (e.g., MPU6886 or similar) to generate an interrupt when a significant acceleration is detected.
Set the threshold for acceleration to trigger the interrupt.Putting the Device to Sleep:
Call esp_deep_sleep_start() for deep sleep or esp_light_sleep_start() for light sleep.
Example Code (Arduino):
#include <M5AtomS3.h>void setup() {
M5.begin(); // Initialize M5AtomS3
M5.Imu.Init(); // Initialize the IMU (accelerometer)// Configure accelerometer interrupt
M5.Imu.setIntEnable(1); // Enable interrupt
M5.Imu.setWakeOnMotionThreshold(10); // Set threshold (adjust as needed)
M5.Imu.setWakeOnMotionEnabled(true); // Enable wake-on-motion// Configure wake-up from accelerometer interrupt
esp_sleep_enable_ext0_wakeup(GPIO_NUM_X, HIGH); // Replace X with the correct GPIO for XTAL_32K_NSerial.println("Going to sleep...");
delay(100);
esp_deep_sleep_start(); // Enter deep sleep
}void loop() {
// This will not run after deep sleep
}Notes:
UIFlow 2.0 Limitation: UIFlow 2.0 does not currently expose APIs for configuring sleep modes or accelerometer-based wake-up. You must use Arduino for this functionality.
GPIO Pin: You need to identify the correct GPIO pin connected to XTAL_32K_N (check the AtomS3R schematic or documentation).
Power Consumption: Deep sleep significantly reduces power consumption, while light sleep retains some peripherals (like Wi-Fi) but consumes more power.Alternative Approach:
If you prefer UIFlow, you might need to use a workaround (e.g., periodic wake-up and check accelerometer values), but this is less efficient than hardware-triggered wake-up. -
@yuyun2000 Thank you for your response. I will try it out with Arduino as soon as possible.
Just a quick question to make sure we're on the same page. We are talking about the integrated IMU in the AtomS3R, no external accelerometer, right?
I will try to find more details in the documentation, but as far as I can see, the only place where the IMU is mentioned in the schematics is the IMU_INT that's connected to this XTAL_32K_N.
I will update you as soon as I have news.