summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2015-03-23 17:10:40 +1100
committerStanley Huang <stanleyhuangyc@gmail.com>2015-03-23 17:10:40 +1100
commitb77a6bada4262ea9fcc211b9ae8f5a3c767cb7bd (patch)
tree8c537ba6709f03185bb764f2b40ae780f7f41faf
parent6e30c747d4a63ba4dabaf6de9ef4321db2ac346f (diff)
download2021-arduino-obd-b77a6bada4262ea9fcc211b9ae8f5a3c767cb7bd.tar.gz
2021-arduino-obd-b77a6bada4262ea9fcc211b9ae8f5a3c767cb7bd.tar.bz2
2021-arduino-obd-b77a6bada4262ea9fcc211b9ae8f5a3c767cb7bd.zip
Add support for MPU-9150
-rw-r--r--megalogger/config.h1
-rw-r--r--megalogger/datalogger.h4
-rw-r--r--megalogger/megalogger.ino13
3 files changed, 11 insertions, 7 deletions
diff --git a/megalogger/config.h b/megalogger/config.h
index a29a442..24b456f 100644
--- a/megalogger/config.h
+++ b/megalogger/config.h
@@ -26,6 +26,7 @@
// this defines the format of data streaming
// FORMAT_BIN is required by Freematics OBD iOS App
+// FORMAT_CSV is for text-based output
#define STREAM_FORMAT FORMAT_BIN
/* Default streaming baudrates:
diff --git a/megalogger/datalogger.h b/megalogger/datalogger.h
index e7342ed..2a58bf3 100644
--- a/megalogger/datalogger.h
+++ b/megalogger/datalogger.h
@@ -31,8 +31,8 @@ typedef struct {
#define PID_ACC 0x20
#define PID_GYRO 0x21
#define PID_COMPASS 0x22
-#define PID_TEMP 0x23
-#define PID_VOLTAGE 0x24
+#define PID_MEMS_TEMP 0x23
+#define PID_BATTERY_VOLTAGE 0x24
#define FILE_NAME_FORMAT "/DAT%05d.CSV"
diff --git a/megalogger/megalogger.ino b/megalogger/megalogger.ino
index 65fad3c..22ba948 100644
--- a/megalogger/megalogger.ino
+++ b/megalogger/megalogger.ino
@@ -178,7 +178,7 @@ void showPIDData(byte pid, int value)
lcd.printInt(value, 2);
}
break;
- case PID_VOLTAGE:
+ case PID_BATTERY_VOLTAGE:
lcd.setFontSize(FONT_SIZE_LARGE);
lcd.setCursor(80, 18);
lcd.printInt(value / 10, 2);
@@ -453,6 +453,7 @@ void processAccelerometer()
#if USE_MPU9150
int16_t mx, my, mz;
#endif
+ int temp;
if (logger.dataTime - lastMemsDataTime < ACC_DATA_INTERVAL) {
return;
@@ -466,7 +467,7 @@ void processAccelerometer()
logger.dataTime = millis();
- lcd.setFontSize(FONT_SIZE_SMALL);
+ temp = accelgyro.getTemperature();
ax /= ACC_DATA_RATIO;
ay /= ACC_DATA_RATIO;
@@ -475,7 +476,8 @@ void processAccelerometer()
gy /= GYRO_DATA_RATIO;
gz /= GYRO_DATA_RATIO;
- // display acc data
+ // display MEMS data
+ lcd.setFontSize(FONT_SIZE_SMALL);
lcd.setCursor(214, 22);
setColorByValue(ax, 50, 100, 200);
lcd.print(ax);
@@ -517,6 +519,7 @@ void processAccelerometer()
// log x/y/z of compass
logger.logData(PID_COMPASS, mx, my, mz);
#endif
+ logger.logData(PID_MEMS_TEMP, temp);
lastMemsDataTime = logger.dataTime;
#endif
@@ -791,8 +794,8 @@ void loop()
index3 = (index3 + 1) % TIER_NUM3;
if (index3 == 0) {
int v = obd.getVoltage();
- showPIDData(PID_VOLTAGE, v);
- logger.logData(PID_VOLTAGE, v);
+ showPIDData(PID_BATTERY_VOLTAGE, v);
+ logger.logData(PID_BATTERY_VOLTAGE, v);
}
} else {
if (obd.isValidPID(pidTier2[index2])) {