@@ -81,14 +81,14 @@ void setup() {
81
81
WiFi.hostname (host);
82
82
WiFi.begin ();
83
83
84
- Wire.begin (5 , 4 ); // SDA=D1=5, SCL=D2=4
85
- Wire.setClock (400000L );
86
-
87
- pinMode (0 , OUTPUT); // RESET=D3=0
88
- digitalWrite (0 , LOW); // reset on
84
+ pinMode (0 , OUTPUT); // RESET=D3=0
85
+ digitalWrite (0 , LOW); // reset on
89
86
delay (10 );
90
87
digitalWrite (0 , HIGH); // reset off
91
88
89
+ Wire.begin (5 , 4 ); // SDA=D1=5, SCL=D2=4
90
+ Wire.setClock (400000L );
91
+
92
92
SPIFFS.begin ();
93
93
94
94
// Used for OSC
@@ -205,6 +205,7 @@ void setup() {
205
205
CONFIG_TO_JSON (sensors, " sensors" );
206
206
CONFIG_TO_JSON (decimate, " decimate" );
207
207
CONFIG_TO_JSON (calibrate, " calibrate" );
208
+ CONFIG_TO_JSON (raw, " raw" );
208
209
CONFIG_TO_JSON (ahrs, " ahrs" );
209
210
CONFIG_TO_JSON (quaternion, " quaternion" );
210
211
CONFIG_TO_JSON (temperature, " temperature" );
@@ -247,7 +248,7 @@ void setup() {
247
248
248
249
// Read the WHO_AM_I register, this is a good test of communication
249
250
byte c = mpu[i].readByte (MPU9250_ADDRESS, WHO_AM_I_MPU9250);
250
- Serial.print (F (" MPU9250 I AM 0x" ));
251
+ Serial.print (F (" MPU9250 I am 0x" ));
251
252
Serial.print (c, HEX);
252
253
Serial.print (F (" I should be 0x" ));
253
254
Serial.println (0x71 , HEX);
@@ -281,7 +282,7 @@ void setup() {
281
282
// Read the WHO_AM_I register of the magnetometer, this is a good test of communication
282
283
byte d = mpu[i].readByte (AK8963_ADDRESS, WHO_AM_I_AK8963);
283
284
Serial.print (" AK8963 " );
284
- Serial.print (" I AM 0x" );
285
+ Serial.print (" I am 0x" );
285
286
Serial.print (d, HEX);
286
287
Serial.print (" I should be 0x" );
287
288
Serial.println (0x48 , HEX);
@@ -290,10 +291,6 @@ void setup() {
290
291
status++;
291
292
}
292
293
293
- // mpu[i].Gscale = MPU9250::GFS_2000DPS;
294
- // mpu[i].Ascale = MPU9250::AFS_2G;
295
- // mpu[i].Mmode = MPU9250::M_100HZ;
296
-
297
294
// Get magnetometer calibration from AK8963 ROM
298
295
mpu[i].initAK8963 (mpu[i].factoryMagCalibration );
299
296
// Initialize device for active mode read of magnetometer
@@ -313,8 +310,7 @@ void setup() {
313
310
mpu[i].getMres ();
314
311
315
312
if (config.calibrate == 1 ) {
316
- // The next call delays for 4 seconds, and then records about 15 seconds of
317
- // data to calculate bias and scale.
313
+ // The next call delays for 4 seconds, and then records about 15 seconds of data to calculate bias and scale.
318
314
mpu[i].magCalMPU9250 (mpu[i].magBias , mpu[i].magScale );
319
315
320
316
Serial.println (" AK8963 mag biases (mG)" );
@@ -359,7 +355,7 @@ void loop() {
359
355
if (WiFi.status () != WL_CONNECTED) {
360
356
ledRed ();
361
357
}
362
- else if ((millis () - tic_web) < 5000 ) {
358
+ else if ((millis () - tic_web) < 3000 ) {
363
359
// serving content on the http interface takes a lot of resources and
364
360
// messes up the regular timing of the acquisition and transmission
365
361
ledBlue ();
@@ -394,9 +390,11 @@ void loop() {
394
390
mpu[i].my = (float )mpu[i].magCount [1 ] * mpu[i].mRes * mpu[i].factoryMagCalibration [1 ] - mpu[i].magBias [1 ];
395
391
mpu[i].mz = (float )mpu[i].magCount [2 ] * mpu[i].mRes * mpu[i].factoryMagCalibration [2 ] - mpu[i].magBias [2 ];
396
392
397
- String (id[i] + " /a" ).toCharArray (msgId, 16 ); bundle.add (msgId).add (mpu[i].ax ).add (mpu[i].ay ).add (mpu[i].az );
398
- String (id[i] + " /g" ).toCharArray (msgId, 16 ); bundle.add (msgId).add (mpu[i].gx ).add (mpu[i].gy ).add (mpu[i].gz );
399
- String (id[i] + " /m" ).toCharArray (msgId, 16 ); bundle.add (msgId).add (mpu[i].mx ).add (mpu[i].my ).add (mpu[i].mz );
393
+ if (config.raw ) {
394
+ String (id[i] + " /a" ).toCharArray (msgId, 16 ); bundle.add (msgId).add (mpu[i].ax ).add (mpu[i].ay ).add (mpu[i].az );
395
+ String (id[i] + " /g" ).toCharArray (msgId, 16 ); bundle.add (msgId).add (mpu[i].gx ).add (mpu[i].gy ).add (mpu[i].gz );
396
+ String (id[i] + " /m" ).toCharArray (msgId, 16 ); bundle.add (msgId).add (mpu[i].mx ).add (mpu[i].my ).add (mpu[i].mz );
397
+ }
400
398
401
399
if (config.calibrate == 2 ) {
402
400
mpu[i].magContinuousCalMPU9250 (mpu[i].magCount , mpu[i].magBias , mpu[i].magScale );
@@ -466,7 +464,7 @@ void loop() {
466
464
}
467
465
468
466
// this section is in micros
469
- Now = millis ();
467
+ Now = micros ();
470
468
rate = 1000000 .0f / (Now - Last[i]);
471
469
String (id[i] + " /rate" ).toCharArray (msgId, 16 ); bundle.add (msgId).add (rate);
472
470
String (id[i] + " /time" ).toCharArray (msgId, 16 ); bundle.add (msgId).add (Now / 1000000 .0f );
0 commit comments