0

IMU example for MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32)

Prerequisites

If not already done so already, install Arduino software and make basic connections, as described in page for MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32).

Task

MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32) has an internal IMU. We will show how to read heading, pitch and roll it measures.

Program

The program is again simple:

#include <mrm-imu.h>

Mrm_imu imu;

void setup(){
  Serial.begin(115200);
  Wire.begin();
  imu.add(true); 
}

void loop(){
  Serial.print("Heading: ");
  Serial.print(imu.heading());
  Serial.print(", pitch: ");
  Serial.print(imu.pitch());
  Serial.print(", roll: ");
  Serial.println(imu.roll());
  delay(100);
}
After including one of the downloaded librarires, mrm-imu, object "imu" is defined. This is our IMU.

setup() starts serial communication with our PC, then starts I2C (Wire.begin). I2C is necessary because the IMU (Inertial Measurement Unit) uses this serial bus. The last command starts the device.

loop() just displays heading, pitch, and roll measurements.