1- #include < MPU9250_asukiaaa.h>
2-
3- #ifdef _ESP32_HAL_I2C_H_
4- #define SDA_PIN 21
5- #define SCL_PIN 22
6- #endif
1+ /* Heltec Automation MPU9520 Sensors test example
2+ *
3+ * Function:
4+ * 9-axis sensor
5+ *
6+ * Description:
7+ * 1.The MPU9250 integrates a 3-axis gyroscope, a 3-axis accelerometer,
8+ * and a 3-axis magnetometer. The output is 16-bit digital.
9+ *
10+ * 2. Data can be exchanged via the Integrated Circuit Bus (IIC) interface
11+ * and the microcontroller with a transfer rate of up to 400 kHz / s.
12+ *
13+ * 3. The accelerometer's measurement range is up to ??16g (g is gravitational
14+ * acceleration), and the static measurement accuracy is high.
15+ *
16+ * 4. The magnetometer uses a high-intensity Hall-type sensor for data acquisition.
17+ * The magnetic induction measurement range is ??4800??T, which can be used for auxiliary
18+ * measurement of yaw angle.
19+ *
20+ * 5.The MPU9250's built-in digital motion processor (DMP: Hardware Motion Processor)
21+ * hardware acceleration engine integrates nine-axis sensor data and outputs
22+ * complete 9-axis fusion calculation data to the application.
23+ *
24+ * HelTec AutoMation, Chengdu, China
25+ * www.heltec.org
26+ *
27+ * this project also realess in GitHub:
28+ * https://github.com/HelTecAutomation/ASR650x-Arduino
29+ *
30+ * MPU9250 Get Mag Offset original project available here: https://github.com/asukiaaa/MPU9250_asukiaaa
31+ */
32+
33+ #include < MPU9250.h>
734
835#define CALIB_SEC 20
936
10- MPU9250_asukiaaa mySensor;
37+ MPU9250 mySensor;
1138
1239uint8_t sensorId;
1340float mDirection , mX , mY , mZ ;
@@ -17,12 +44,6 @@ void setup() {
1744 while (!Serial);
1845 Serial.println (" started" );
1946
20- #ifdef _ESP32_HAL_I2C_H_ // For ESP32
21- Wire.begin (SDA_PIN, SCL_PIN); // SDA, SCL
22- #else
23- Wire.begin ();
24- #endif
25-
2647 mySensor.setWire (&Wire);
2748 while (mySensor.readId (&sensorId) != 0 ) {
2849 Serial.println (" Cannot find device to read sensorId" );
@@ -38,7 +59,7 @@ void setup() {
3859 Serial.println (" Finished setting offset values." );
3960}
4061
41- void setMagMinMaxAndSetOffset (MPU9250_asukiaaa * sensor, int seconds) {
62+ void setMagMinMaxAndSetOffset (MPU9250 * sensor, int seconds) {
4263 unsigned long calibStartAt = millis ();
4364 float magX, magXMin, magXMax, magY, magYMin, magYMax, magZ, magZMin, magZMax;
4465
@@ -85,4 +106,4 @@ void loop() {
85106 Serial.println (" at " + String (millis ()) + " ms" );
86107 Serial.println (" " ); // Add an empty line
87108 delay (500 );
88- }
109+ }
0 commit comments