Menu
Microbots
0
  • Faire
    • Commencer
    • Constructions de créateurs
    • Éducation
  • Boutique
    • ProtoBot
    • Modules Maker
    • Outils et engrenages
    • Robots et écrans
  • À propos
    • Notre histoire
    • Tendez la main
    • FAQ
  • Connexion
  • français
  • Votre panier est vide
Microbots
  • Faire
    • Commencer
    • Constructions de créateurs
    • Éducation
  • Boutique
    • ProtoBot
    • Modules Maker
    • Outils et engrenages
    • Robots et écrans
  • À propos
    • Notre histoire
    • Tendez la main
    • FAQ
  • Langue

  • 0 0

CodeCell: Motion State

CodeCell can also detect whether the device is on a table, stationary, or in motion, using its Motion State sensing feature.

Understanding Motion State Detection

The CodeCell's BNO085 sensor provides a built-in algorithm called Motion State, which classifies the device’s movement into simple, easy-to-use states.

Enable Motion State with:

myCodeCell.Init(MOTION_STATE);    // Enable motion state sensing

Read the current state using:

int state = myCodeCell.Motion_StateRead();

Motion State Reference

ID State Description
0 MOTION_STATE_UNKNOWN Not yet classified — sensor is still initializing or calibrating.
1 MOTION_STATE_ONTABLE Device is resting on a solid surface (like a desk or table).
2 MOTION_STATE_STATIONARY Not moving at all — completely still.
3 MOTION_STATE_STABLE Movement has recently stopped; sensor is stabilizing.
4 MOTION_STATE_MOTION Device is actively moving.

Tip:
The difference between Stationary and Stable:

  • Stable = recently stopped but still settling
  • Stationary = fully still for a moment

Example – Serial Motion State Monitor

This example prints the current Motion State every 100 ms.

/*
  Example: Motion State Monitor Demo
  Boards: CodeCell C3 / CodeCell C3 Light / CodeCell C6 / CodeCell C6 Drive

  Overview:
  - Demonstrates the CodeCell's Motion State sensing.
  - Continuously reports whether the device is On-Table, In Motion, Stabilizing, or Stationary.  
*/

#include <CodeCell.h>

CodeCell myCodeCell;

void setup() {
  Serial.begin(115200);           // Start USB serial at 115200 baud
  myCodeCell.Init(MOTION_STATE);  // Enable Motion State sensing
}

void loop() {
  if (myCodeCell.Run(10)) {  // Run at 10 Hz
    Serial.print("State: ");
    switch (myCodeCell.Motion_StateRead()) {
      case MOTION_STATE_STABLE:
        Serial.println("Motion Stopped - Stabilizing");
        break;
      case MOTION_STATE_ONTABLE:
        Serial.println("On Table");
        break;
      case MOTION_STATE_STATIONARY:
        Serial.println("Stationary");
        break;
      case MOTION_STATE_MOTION:
        Serial.println("In Motion");
        break;
      default:
        Serial.println("Unknown");
        break;
    }
  }
}

When to Use Motion State

  • Notify devices when picked up: Detect when a project moves.
  • Trigger actions on motion stop: Start logging or measuring once movement stabilizes.
  • Sleep mode optimization: Enter deep sleep when stationary for better battery life.

Notes

  • Motion State may take a few seconds to stabilize after powering on.
  • Mounting orientation affects sensitivity - fixed, rigid mounting gives the best results.
  • Partager:

Partage

Github

  • À propos
  • Logiciel
  • Éducation
  • Contact
  • FAQ
  • Termes
  • Politique de remboursement
  • politique de confidentialité

Soyez le premier informé des nouveaux projets et bénéficiez d'offres intéressantes !

© 2026 Microbots.

★ Reviews

Let customers speak for us

67 reviews
Write a review
85%
(57)
6%
(4)
1%
(1)
3%
(2)
4%
(3)
62
21
C
CodeCell C3
Cloke74

Great piece of kit, had just what i needed to complete the project i had in mind. Shame shipping to the UK is so expensive, but appreciate this isn’t necessarily in the hands of MicroBots

A
CodeCell C6
Anonymous

I had an issue, got a red light, I used too much flux. Support said clean it, then the one sensor worked fine. I got the help and answer same day I provided a foto.

A
CodeCell C6 Drive
Anonymous

I think this is the best of the ESP offered, most versatile.

User picture
P
CodeCell C6
Prudhvi tej Chinimilli

Been testing the Microbots CodeCell C6 and honestly impressed with how much functionality they packed into such a tiny module. Great form factor for rapid prototyping wearable/embedded sensing applications. ESP32-C6 + IMU integration makes development much easier compared to building everything from scratch.

Still exploring battery optimization and compact LiPo options for our use case, but overall the platform is promising for low-cost real-time sensing systems. Excited to keep building with it.

F
CodeCell C6
Francisco Estivallet

Amazing hardware, my go to for compact projects.

User picture
123