Wiring MPU9250 to use with ESPrtk
ESP32 | IMU-MPU9250 |
---|---|
3.3V out | 3.3V |
GND | GND |
SDA_I2C | SDA |
SCL_I2C | SCL |
Introduce
This feature is supported on version 2.7.5 or higher.
When enabled, ESPrtk will communicate with MPU9250 and export raw data, calibration data and filter data to TX_UART0 port.
ESPrtk can run this function in multitask , also no problem at highspeed output . ( (ESPrtk can run NTRIP/MQTT /RF Link +Send NMEA to Server + SD Card log NMEA realtime + Export IMU data realtime + ...other actions in the same time) .
- Update frequency (Hz) : “2”,”10″,”15″,”20″,”25″,”35″,”50″,”100″,
“150”,”200″. - Gyroscope Scale range : ‘250’, ‘500’, ‘1000’,’2000′.
- Accelerometer Scale range : ‘2’, ‘4’, ‘8’,’16’.
- Low pass Filter (Hz): ‘Not use’,’5′,’10’,’20’,’41’,’92’,’184′.
- Shock tolerance Kalman Filter (input range): 1.000 ~ 20.000.
Format output data on TX_UART0
$EPIM1, GX,GY,GZ, MX,MY,MZ, AX,AY,AZ, T, MXc,MYc,MZc,* <CS><CR><LF>
- GX,GY,GZ : Raw Gyroscope 3 Axis (Degree/second)
- MX,MY,MZ : Raw Magnetometer 3 Axis (uT) (micro-Tesla)
- AX,AY,AZ : Raw Accelerometer 3 Axis ( scale 0.1 m/s^2)
- T : Temperature sensor (°C) (degrees Celsius)
- MXc,MYc,MZc : Magnetometer 3 Axis + Calibrated.
$EPIM2, QW,QX,QY,QZ, Yaw,Pitch,Roll, H, FQW,FQX,FQY,FQZ, FYaw,FPitch,FRoll, FH,* <CS><CR><LF>
- QW,QX,QY,QZ : DMP-Quaternion.
- Yaw,Pitch,Roll: DMP-Euler 3 Axis. (Degree)
- H :Compass Heading (using magnetometer calibrated) + Tilt compensation. (Degree)
- FQW,FQX,FQY,FQZ : DMP-Quaternion + Extended Kalman Filter.
- FYaw,FPitch,FRoll : DMP-Euler 3 Axis + Extended Kalman Filter. (Degree)
- FH :Compass Heading (using magnetometer calibrated) + Tilt compensation +Extended Kalman Filter (Degree)
<CS><CR><LF> :
- <CS> : a checksum represented as a two-digit hexadecimal number. The checksum is the bitwise exclusive OR of ASCII codes of all characters between the ($ )and (*). (does not include $ and * ).
- <CR> : “Carriage return” or ‘\r’ or ‘0x0D in hex’ (13 in decimal)
- <LF> : “Line Feed” or ‘\n’ or ‘0x0A in hex ‘ (10 in decimal) .
Calculate checksum – algorithm :
#include <stdio.h> int checksum(const char *s) { int c = 0; while(*s) c ^= *s++; return c; } int main() { char mystring[] = "EPIM1,0.06,0.00,-0.06,48.86,-58.79,88.12,-0.19,-0.92,0.42,32.91,47.90,-59.29,87.77,"; printf("Your checksum is : 0x%02X\n", checksum(mystring)); // result -> Checksum:0x2F return 0; }
Example output on TX_UART0 :
$EPIM1,-0.18,-0.12,0.06,46.91,-60.74,87.67,-0.19,-0.93,0.43,33.56,45.97,-61.23,87.35,*05 $EPIM2,-0.18,0.22,0.49,-0.82,148.76,-65.10,10.62,231.27,,,,,148.87,-65.09,10.61,231.41,*04 $EPIM1,0.30,-0.12,-0.12,49.16,-59.54,88.12,-0.19,-0.92,0.43,33.52,48.20,-60.04,87.77,*09 $EPIM2,-0.18,0.22,0.49,-0.82,148.76,-65.10,10.62,231.24,,,,,148.87,-65.09,10.61,231.41,*07 $EPIM1,-0.55,-0.12,0.00,48.11,-60.59,88.87,-0.19,-0.92,0.43,33.55,47.15,-61.09,88.54,*08 $EPIM2,-0.18,0.22,0.49,-0.82,148.76,-65.11,10.62,231.05,,,,,148.87,-65.09,10.61,231.41,*05
Calibration for magnetomter data
Compensating hard-iron-and-soft-iron-effects on compass sensor using trasnsformation matrix.
Go to this post to learn more : IMU MPU9250 ; Calibrate magnetometer on ESPrtk using Magneto1.2.
Calibration Helper.
Display and collect XYZ 3-axis magnetometer data to make calibration magnetometer more simple and professional with wireless connection (WIFI).
See detail here: IMU MPU9250 ; Calibration Helper .