SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
qmi8658_wake_on_motion.ino File Reference

@license MIT License More...

#include <stdarg.h>
#include <ImuDrv.hpp>
#include "DevicesPins.h"
Include dependency graph for qmi8658_wake_on_motion.ino:

Go to the source code of this file.

Macros

#define USE_I2C_INTERFACE
 
#define IMU_SDA   17
 
#define IMU_SCL   18
 
#define IMU_IRQ   33
 

Functions

void setupPower ()
 
void womCallback ()
 
void applyWomConfig ()
 
void printWomHelp ()
 
void handleWomCommands ()
 
void setup ()
 
void loop ()
 

Variables

SensorQMI8658 imu
 
uint32_t lastPollMs = 0
 
volatile bool isInterruptTriggered = false
 
constexpr uint32_t kPollIntervalMs = 50
 
uint8_t womThreshold = 150
 
float womOdrHz = 11.0f
 
uint8_t womDefaultPinValue = 1
 
uint8_t womBlankingTime = 0x20
 
AccelFullScaleRange womRange = AccelFullScaleRange::FS_8G
 
SensorQMI8658::IntPin womIntPin = SensorQMI8658::IntPin::PIN2
 

Detailed Description

@license MIT License

Copyright (c) 2026 lewis he

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author
Lewis He (lewis.nosp@m.he@o.nosp@m.utloo.nosp@m.k.co.nosp@m.m)
Date
2026-04-15

Wake-on-motion example using SensorQMI8658.

This example demonstrates how to:

  • Configure wake-on-motion (WoM) detection
  • Set up callbacks for WoM events
  • Use low-power accelerometer mode for power efficiency

@important WoM Notes:

  • In Non-SyncSample mode, DRDY routing and WoM routing are different paths.
  • This example uses hardware interrupt callback on a dedicated interrupt pin.
  • configWakeOnMotionAdvanced(...) exposes vendor-style parameters: threshold, ODR, interrupt route, default pin level, blanking time, accel range.
  • Runtime serial tuning commands are provided in this example for quick debug.
Note
Wake-on-motion is ideal for battery-powered applications where the system should wake up only when motion is detected. The accelerometer runs in low-power mode when not triggered.

Definition in file qmi8658_wake_on_motion.ino.

Macro Definition Documentation

◆ IMU_IRQ

#define IMU_IRQ   33

Definition at line 91 of file qmi8658_wake_on_motion.ino.

◆ IMU_SCL

#define IMU_SCL   18

Definition at line 85 of file qmi8658_wake_on_motion.ino.

◆ IMU_SDA

#define IMU_SDA   17

Definition at line 81 of file qmi8658_wake_on_motion.ino.

◆ USE_I2C_INTERFACE

#define USE_I2C_INTERFACE

Definition at line 57 of file qmi8658_wake_on_motion.ino.

Function Documentation

◆ applyWomConfig()

◆ handleWomCommands()

void handleWomCommands ( )

◆ loop()

◆ printWomHelp()

void printWomHelp ( )

Definition at line 163 of file qmi8658_wake_on_motion.ino.

Referenced by handleWomCommands(), and setup().

◆ setup()

◆ setupPower()

void setupPower ( )

Definition at line 108 of file qmi8658_wake_on_motion.ino.

Referenced by setup().

◆ womCallback()

void womCallback ( )

Definition at line 136 of file qmi8658_wake_on_motion.ino.

Referenced by setup().

Variable Documentation

◆ imu

Definition at line 123 of file qmi8658_wake_on_motion.ino.

Referenced by applyWomConfig(), loop(), and setup().

◆ isInterruptTriggered

volatile bool isInterruptTriggered = false

Definition at line 127 of file qmi8658_wake_on_motion.ino.

Referenced by loop(), and setup().

◆ kPollIntervalMs

constexpr uint32_t kPollIntervalMs = 50
constexpr

Definition at line 128 of file qmi8658_wake_on_motion.ino.

Referenced by loop().

◆ lastPollMs

uint32_t lastPollMs = 0

Definition at line 126 of file qmi8658_wake_on_motion.ino.

Referenced by loop().

◆ womBlankingTime

uint8_t womBlankingTime = 0x20

Definition at line 132 of file qmi8658_wake_on_motion.ino.

Referenced by applyWomConfig(), and handleWomCommands().

◆ womDefaultPinValue

uint8_t womDefaultPinValue = 1

Definition at line 131 of file qmi8658_wake_on_motion.ino.

Referenced by applyWomConfig(), and handleWomCommands().

◆ womIntPin

◆ womOdrHz

float womOdrHz = 11.0f

Definition at line 130 of file qmi8658_wake_on_motion.ino.

Referenced by applyWomConfig(), and handleWomCommands().

◆ womRange

◆ womThreshold

uint8_t womThreshold = 150

Definition at line 129 of file qmi8658_wake_on_motion.ino.

Referenced by applyWomConfig(), and handleWomCommands().