examples/MPU6050/README.md
This project shows how to use Serial Studio to visualize motion and orientation data from an MPU6050 accelerometer and gyroscope connected to an Arduino. The Arduino sketch reads processed acceleration, gyroscope, and temperature data from the MPU6050 and sends it to Serial Studio over serial for real-time display on widgets like a g-meter or attitude indicator.
Compatibility. Works with any MPU6050 module connected via I2C. Adjust the wiring if your board exposes I2C on pins other than A4 and A5.
You need an MPU6050 sensor module and an Arduino. Connect the SDA and SCL pins of the MPU6050 to A4 (SDA) and A5 (SCL) on the Arduino. The sketch initializes the MPU6050 with an accelerometer range of ±8 g, a gyroscope range of ±500 deg/s, and a 21 Hz low-pass filter bandwidth.
A4 and A5 are the default I2C pins on Uno and Nano boards.
MPU6050.ino)Install the Adafruit MPU6050 and Adafruit Unified Sensor libraries:
Once the libraries are installed, open the MPU6050.ino sketch, connect the MPU6050 sensor, and upload the code to your Arduino. The MPU6050 data is transmitted with specific delimiters:
$). Marks the start of a data frame.;). Marks the end of the frame.,). Separates fields (acceleration, gyroscope, temperature).The frame looks like this:
$accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z,temperature;
Notes:
accel_x, accel_y, accel_z are in m/s².gyro_x, gyro_y, gyro_z are in deg/s. Serial Studio integrates these to pitch, yaw, and roll in degrees for the attitude indicator widget.Serial Studio needs to know how to parse the incoming sensor data.
MPU6050.ssproj. Launch Serial Studio, go to FRAME PARSING → Parse via Project File, and select the MPU6050.ssproj file from this project. It has everything you need to interpret the Arduino's data.If you want to configure it yourself:
Frame start sequence: $.
Frame end sequence: ;.
Frame parser: split each frame on commas:
function parse(frame) {
return frame.split(',');
}
Add widgets to display real-time acceleration and gyroscope data, plus temperature. The bundled project groups the datasets as Accelerometer (Accelerometer X/Y/Z in m/s²), Gyroscope (Gyro X/Y/Z in deg/s), and Temperature (a bar widget with an alarm at 40 ℃).
Once Serial Studio is configured:
$) and end sequence (;) are set correctly in the project settings, and that the frame parser splits on commas.