Project to visualize the accelerometer and gyroscope readings of the MPU6050 sensor under the presence of its built-in Digital Motion Processor(DMP) with the NodeMCU V2(ESP8266) as a host. The project is based on the i2cdev library by Jeff Rowberg & toxiclibs. The project also contains the Processing sketch to visualize a model that constantly updates itself based on the quaternions received by the MPU6050's FIFO.
- PlatformIO Extension on VSCode.
- Processing.
- The MPU6050's VCC and GND pins have been connected to the 3.3v and GND pins of the NodeMCU.
- The MPU6050's SCL and SDA pins have been connected to D2 and D1 of the NodeMCU respectively.
- The MPU6050's INT pin is connected to D5 on the NodeMCU
- The MPU6050's AD0 pin may be left unconnected or connected to GND on the NodeMCU to ensure that the I2C address remains 0x68. Incase the AD0 pin is connected to high this address changes to 0x69 and changes need to be made to the main.cpp file. The ADO pin was left unconnected during my tests.
After compiling and uploading the source code to the NodeMCU, you'll have to send any character to through the serial monitor in order to trigger the initialization of the DMP. Once this is done the calibration functions run in order to print out the appropriate offsets for your MPU6050.
The 6 values printed out in the serial monitor now represent the offsets for acceleration in the X, Y, Z directions and rotation rate(angular velocity) about the X, Y, Z directions respectively.
These values can now be set in:
imu-test-visual-nodemcuv2/src/main.cpp
Lines 206 to 210 in cc2f025
Now if you run the code on your board again you should get more accurate values for yaw, pitch and roll(y, p, r) respectively.
The values produced by the IMU can be graphically visualized in the Processing environment by running the .pde file in the processing folder on Processing.
This repository also contains another demo based on the original processing sketch for visualization which can be used to visualize movements of the arm in a scenario where the MPU6050 is mounted on the arm. The arm attached to the human body animation can be used to visualize roll and pitch movements.
The visualization demo also depends on toxiclibs which should be added in the libraries folder of the folder where your Processing is installed.
Windows users need to set the correct serial port by commenting out:
and uncommenting:
and setting the appropriate COM port.
The current code has been tested for Linux x86_64.