diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2017-02-12 23:01:21 +1100 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2017-02-12 23:01:21 +1100 |
commit | ceb4720c4a89735fb1ef128b66a7e582270043da (patch) | |
tree | b66d8c66073e6fb9ccc1da7bd2721f57df146365 /libraries/OBD/examples/obd_i2c_test | |
parent | d9b2570fd97aec7660c466804cd78ba60f04bec9 (diff) | |
download | 2021-arduino-obd-ceb4720c4a89735fb1ef128b66a7e582270043da.tar.gz 2021-arduino-obd-ceb4720c4a89735fb1ef128b66a7e582270043da.tar.bz2 2021-arduino-obd-ceb4720c4a89735fb1ef128b66a7e582270043da.zip |
Improved compatibility
Diffstat (limited to 'libraries/OBD/examples/obd_i2c_test')
-rw-r--r-- | libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino b/libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino index 38da62e..810aacf 100644 --- a/libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino +++ b/libraries/OBD/examples/obd_i2c_test/obd_i2c_test.ino @@ -12,10 +12,11 @@ #include <OBD.h> COBDI2C obd; +bool hasMEMS; void testOut() { - static const char cmds[][6] = {"ATZ\r", "ATL1\r", "ATH0\r", "ATRV\r", "0100\r", "010C\r", "0902\r"}; + static const char cmds[][6] = {"ATZ\r", "ATH0\r", "ATRV\r", "0100\r", "010C\r", "0902\r"}; char buf[128]; for (byte i = 0; i < sizeof(cmds) / sizeof(cmds[0]); i++) { @@ -111,15 +112,12 @@ void setup() { delay(500); obd.begin(); + hasMEMS = obd.memsInit(); Serial.print("MEMS:"); - if (obd.memsInit()) { - Serial.println("OK"); - } else { - Serial.println("NO"); - } - + Serial.println(hasMEMS ? "Yes" : "No"); + // send some commands for testing and show response for debugging purpose - //testOut(); + testOut(); // initialize OBD-II adapter do { @@ -151,6 +149,7 @@ void setup() { void loop() { readPIDs(); readBatteryVoltage(); - readMEMS(); + if (hasMEMS) { + readMEMS(); + } } - |