
CodeCell includes a BNO085 motion sensor that combines an accelerometer, gyroscope, and magnetometer to calculate rotation angles in real time. In this guide, you'll learn how to measure roll, pitch, and yaw, the three fundamental orientation angles used in robotics, drones, and motion-tracking applications.
The BNO085 sensor fuses multiple motion readings into a rotation vector that can be read using the CodeCell library. You can directly access these rotation angles (in degrees) with the following function:
myCodeCell.Motion_RotationRead(Roll, Pitch, Yaw);
This function updates the three float variables you define for the current orientation of the CodeCell:
Before reading these values, initialize rotation sensing in your setup using:
myCodeCell.Init(MOTION_ROTATION);
This example prints CodeCell’s rotation angles to the Serial Monitor at 10Hz, giving you live feedback on how the module moves.
#include <CodeCell.h>
CodeCell myCodeCell;
float Roll = 0.0;
float Pitch = 0.0;
float Yaw = 0.0;
void setup() {
  Serial.begin(115200);              // Start serial monitor
  myCodeCell.Init(MOTION_ROTATION);  // Enable rotation sensing
}
void loop() {
  if (myCodeCell.Run(10)) {          // Run loop at 10 Hz
    myCodeCell.Motion_RotationRead(Roll, Pitch, Yaw);
    Serial.printf("Roll: %.2f°, Pitch: %.2f°, Yaw: %.2f°\n", Roll, Pitch, Yaw);
  }
}
myCodeCell.Run() frequency to suit your application.
Join our Community ~ Be the first to know about new products and get exciting deals!
            © 2025 Microbots.