Menu
Microbots
0
  • Robots
    • ProtoBot
    • CubeBot
    • Robot Parts
  • Modules & Parts
    • CodeCell ESP32 Modules
    • Motors & Actuators
    • LiPo Batteries
  • Gear
    • Tools
    • Merch
  • Learn
    • User Guide & Tutorials
    • DIY Projects & Files
    • Education Discounts
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Sign in
  • Your Cart is Empty
Microbots
  • Robots
    • ProtoBot
    • CubeBot
    • Robot Parts
  • Modules & Parts
    • CodeCell ESP32 Modules
    • Motors & Actuators
    • LiPo Batteries
  • Gear
    • Tools
    • Merch
  • Learn
    • User Guide & Tutorials
    • DIY Projects & Files
    • Education Discounts
  • About
    • Our Story
    • Reach Out
    • FAQs
  • 0 0

CodeCell: Reading the Roll, Pitch & Yaw

CodeCell Motion Sensing

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.

Understanding Roll, Pitch, and Yaw

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:

  • Roll – rotation around the X-axis (tilt left or right)
  • Pitch – rotation around the Y-axis (tilt forward or backward)
  • Yaw – rotation around the Z-axis (turn left or right)

Before reading these values, initialize rotation sensing in your setup using:

myCodeCell.Init(MOTION_ROTATION);

Example – Reading Roll, Pitch, and Yaw

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);
  }
}

Customization Tips

  • Adjust update rate: Change the myCodeCell.Run() frequency to suit your application.
  • Filter motion data: Use averaging or thresholds to smooth movement or ignore small jitters.
  • Expand control: Map roll, pitch, or yaw to multiple servos, LEDs, or motors for responsive motion-based projects.

 

  • Share:

Follow

Github

  • About
  • Software
  • Education
  • Contact
  • FAQs
  • Terms
  • Refund Policy
  • Privacy Policy

Join our Community ~ Be the first to know about new products and get exciting deals!

© 2026 Microbots.

★ Reviews

Let customers speak for us

87 reviews
Write a review
87%
(76)
5%
(4)
2%
(2)
2%
(2)
3%
(3)
81
21
A
CodeCell C3
Anonymous

Perfect product!

A
ProtoBot
Anonymous

This is a great product for beginners who want hands-on experience with Arduino and 3D printing. The Protobot has a sleek, solid design, and the software is just as polished. I’ve bought several educational robotics kits, and this is the best one so far. Looking forward to more awesome products!

Thank you so much for your kind review! 😊

F
ProtoBot
Francis van Uyten

Really love this robot. I like that is simple to assemble and I like that you guys prepares it easy to start programming with examples and libraries. My opinion on what to improve is more like a add-on, can you guys develop a localisation sensor or function so it will know where the bot is. Expecting only great things coming from you guys. Succes

Thank you so much for your thoughtful review! Glad you’re enjoying ProtoBot 😊 A localisation sensor is a great suggestion! The I²C connection lets you add compatible sensors, so there’s room to explore this. Thanks for your support!

G
Experiment in Progress Mug
Gerald Kendrick

I am enjoying my Experiment in Progress coffee mug. It fits in well in the lab.

Hi Gerald, we’re so glad you’re enjoying it! Thanks for sharing your kind review.

K
12-in-1 Screwdriver (Pen-Size)
Klaas

Very useful fun little screwdriver for the all tiny stuff

Hi Klaas, thanks for the great review! We’re glad you’re enjoying your screwdriver!