Inertial measurement unit with a Grove connector
GetSensorData
Connect the IMU Module to the controller with a Grove cable to read acceleration, angular velocity, and magnetic field values, then print the readings over the controller serial port.
Configure Vofa+ to calculate orientation from the IMU Module data.
Things used in this project
Hardware components
Software apps and online services
Story
Schematics
Firmware
Use the tool below to flash precompiled firmware to the ESP32-C3 TFT Devkit directly from your browser, without installing additional software:
ESP32 Flasher (Official API)
Disconnected
Select firmware
Operation log
Instructions and Troubleshooting
For flashing problems and other troubleshooting, see the ESP Flasher Guide.
Code
c++
/*
Arduino BMM150 - Simple Magnetometer
This example reads the magnetic field values from the BMM150
sensor and continuously prints them to the Serial Monitor
or Serial Plotter.
The circuit:
- Arduino Nano 33 BLE Sense Rev2
created 10 Jul 2019
by Riccardo Rizzo
This example code is in the public domain.
*/
#include "Arduino_BMI270_BMM150.h"
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("Started");
Wire.begin(8, 10);
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
Serial.print("Magnetic field sample rate = ");
Serial.print(IMU.magneticFieldSampleRate());
Serial.println(" Hz");
Serial.println();
Serial.println("Magnetic Field in uT");
Serial.println("X\tY\tZ");
}
void loop() {
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
Serial.print("accel:");
Serial.print(x);
Serial.print(',');
Serial.print(y);
Serial.print(',');
Serial.print(z);
Serial.println();
}
if (IMU.gyroscopeAvailable()) {
IMU.readGyroscope(x, y, z);
Serial.print("gyro:");
Serial.print(x);
Serial.print(',');
Serial.print(y);
Serial.print(',');
Serial.print(z);
Serial.println();
}
if (IMU.magneticFieldAvailable()) {
IMU.readMagneticField(x, y, z);
Serial.print("mag:");
Serial.print(x);
Serial.print(',');
Serial.print(y);
Serial.print(',');
Serial.print(z);
Serial.println();
}
delay(500);
}