Professional Documents
Culture Documents
Update For Github
Update For Github
Pull requests
Issues
Marketplace
Explore
@Jesus-Vaz4
PowerBroker2
/
ELMduino
15
15038
Code
Issues
5
Pull requests
Actions
Projects
Wiki
m
er as
Security
Insights
co
ELMduino/src/ELMduino.h
eH w
@PowerBroker2
PowerBroker2 Fix issues #81 and #83
o.
Latest commit 824ef60 on 22 May
History rs e
ou urc
1 contributor
417 lines (365 sloc) 19.8 KB
#pragma once
o
#include "Arduino.h"
aC s
vi y re
//---------------------------------------------------------------------------------
----//
ed d
// Protocol IDs
ar stu
//---------------------------------------------------------------------------------
----//
const char AUTOMATIC = '0';
const char SAE_J1850_PWM_41_KBAUD = '1';
is
This study source was downloaded by 100000828587148 from CourseHero.com on 06-26-2021 13:39:55 GMT -05:00
https://www.coursehero.com/file/98593628/Update-for-Githubtxt/
//---------------------------------------------------------------------------------
----//
// PIDs (https://en.wikipedia.org/wiki/OBD-II_PIDs)
//---------------------------------------------------------------------------------
----//
const uint8_t SERVICE_01 = 1;
m
er as
const uint8_t VEHICLE_SPEED = 13; // 0x0D - km/h
const uint8_t TIMING_ADVANCE = 14; // 0x0E - ° before TDC
co
const uint8_t INTAKE_AIR_TEMP = 15; // 0x0F - °C
eH w
const uint8_t MAF_FLOW_RATE = 16; // 0x10 - g/s
const uint8_t THROTTLE_POSITION = 17; // 0x11 - %
o.
const uint8_t COMMANDED_SECONDARY_AIR_STATUS = 18; // 0x12 - bit encoded
const uint8_t rs e
OXYGEN_SENSORS_PRESENT_2_BANKS = 19; // 0x13 - bit encoded
ou urc
const uint8_t OXYGEN_SENSOR_1_A = 20; // 0x14 - V %
const uint8_t OXYGEN_SENSOR_2_A = 21; // 0x15 - V %
const uint8_t OXYGEN_SENSOR_3_A = 22; // 0x16 - V %
const uint8_t OXYGEN_SENSOR_4_A = 23; // 0x17 - V %
o
This study source was downloaded by 100000828587148 from CourseHero.com on 06-26-2021 13:39:55 GMT -05:00
https://www.coursehero.com/file/98593628/Update-for-Githubtxt/
const uint8_t EVAP_SYSTEM_VAPOR_PRESSURE = 50; // 0x32 - Pa
const uint8_t ABS_BAROMETRIC_PRESSURE = 51; // 0x33 - kPa
const uint8_t OXYGEN_SENSOR_1_C = 52; // 0x34 - ratio mA
const uint8_t OXYGEN_SENSOR_2_C = 53; // 0x35 - ratio mA
const uint8_t OXYGEN_SENSOR_3_C = 54; // 0x36 - ratio mA
const uint8_t OXYGEN_SENSOR_4_C = 55; // 0x37 - ratio mA
const uint8_t OXYGEN_SENSOR_5_C = 56; // 0x38 - ratio mA
const uint8_t OXYGEN_SENSOR_6_C = 57; // 0x39 - ratio mA
const uint8_t OXYGEN_SENSOR_7_C = 58; // 0x3A - ratio mA
const uint8_t OXYGEN_SENSOR_8_C = 59; // 0x3B - ratio mA
const uint8_t CATALYST_TEMP_BANK_1_SENSOR_1 = 60; // 0x3C - °C
const uint8_t CATALYST_TEMP_BANK_2_SENSOR_1 = 61; // 0x3D - °C
const uint8_t CATALYST_TEMP_BANK_1_SENSOR_2 = 62; // 0x3E - °C
const uint8_t CATALYST_TEMP_BANK_2_SENSOR_2 = 63; // 0x3F - °C
m
er as
const uint8_t AMBIENT_AIR_TEMP = 70; // 0x46 - °C
const uint8_t ABS_THROTTLE_POSITION_B = 71; // 0x47 - %
co
const uint8_t ABS_THROTTLE_POSITION_C = 72; // 0x48 - %
eH w
const uint8_t ABS_THROTTLE_POSITION_D = 73; // 0x49 - %
const uint8_t ABS_THROTTLE_POSITION_E = 74; // 0x4A - %
o.
const uint8_t ABS_THROTTLE_POSITION_F = 75; // 0x4B - %
const uint8_t rs e
COMMANDED_THROTTLE_ACTUATOR = 76; // 0x4C - %
ou urc
const uint8_t TIME_RUN_WITH_MIL_ON = 77; // 0x4D - min
const uint8_t TIME_SINCE_CODES_CLEARED = 78; // 0x4E - min
const uint8_t MAX_VALUES_EQUIV_V_I_PRESSURE = 79; // 0x4F - ratio V mA kPa
const uint8_t MAX_MAF_RATE = 80; // 0x50 - g/s
o
This study source was downloaded by 100000828587148 from CourseHero.com on 06-26-2021 13:39:55 GMT -05:00
https://www.coursehero.com/file/98593628/Update-for-Githubtxt/
//---------------------------------------------------------------------------------
----//
// AT commands (https://www.sparkfun.com/datasheets/Widgets/ELM327_AT_Commands.pdf)
//---------------------------------------------------------------------------------
----//
const char * const DISP_DEVICE_DESCRIPT = "AT @1"; // General
const char * const DISP_DEVICE_ID = "AT @2"; // General
const char * const STORE_DEVICE_ID = "AT @3 %s"; // General
const char * const REPEAT_LAST_COMMAND = "AT \r"; // General
const char * const ALLOW_LONG_MESSAGES = "AT AL"; // General
const char * const AUTOMATIC_RECEIVE = "AT AR"; // OBD
const char * const ADAPTIVE_TIMING_OFF = "AT AT0"; // OBD
const char * const ADAPTIVE_TIMING_AUTO_1 = "AT AT1"; // OBD
const char * const ADAPTIVE_TIMING_AUTO_2 = "AT AT2"; // OBD
const char * const DUMP_BUFFER = "AT BD"; // OBD
const char * const BYPASS_INIT_SEQUENCE = "AT BI"; // OBD
const char * const TRY_BAUD_DIVISOR = "AT BRD %s"; // General
const char * const SET_HANDSHAKE_TIMEOUT = "AT BRT %s"; // General
const char * const CAN_AUTO_FORMAT_OFF = "AT CAF0"; // CAN
m
er as
const char * const CAN_AUTO_FORMAT_ON = "AT CAF1"; // CAN
const char * const CAN_EXTENDED_ADDRESS_OFF = "AT CEA"; // CAN
co
const char * const USE_CAN_EXTENDED_ADDRESS = "AT CEA %s"; // CAN
eH w
const char * const SET_ID_FILTER = "AT CF %s"; // CAN
const char * const CAN_FLOW_CONTROL_OFF = "AT CFC0"; // CAN
o.
const char * const CAN_FLOW_CONTROL_ON = "AT CFC1"; // CAN
const char * const SET_ID_MASK rs e = "AT CM %s"; // CAN
ou urc
const char * const SET_CAN_PRIORITY = "AT CP %s"; // CAN
const char * const SHOW_CAN_STATUS = "AT CS"; // CAN
const char * const CAN_SILENT_MODE_OFF = "AT CSM0"; // CAN
const char * const CAN_SILENT_MODE_ON = "AT CSM1"; // CAN
o
This study source was downloaded by 100000828587148 from CourseHero.com on 06-26-2021 13:39:55 GMT -05:00
https://www.coursehero.com/file/98593628/Update-for-Githubtxt/
const char * const SET_ISO_SLOW_INIT_ADDRESS = "AT IIA %s"; // ISO
const char * const USE_J1939_ELM_DATA_FORMAT = "AT JE"; // J1850
const char * const J1939_HEAD_FORMAT_OFF = "AT JHF0"; // J1850
const char * const J1939_HEAD_FORMAT_ON = "AT JHF1"; // J1850
const char * const USE_J1939_SAE_DATA_FORMAT = "AT JS"; // J1850
const char * const SET_J1939_TIMER_X_TO_1X = "AT JTM1"; // J1850
const char * const SET_J1939_TIMER_X_TO_5X = "AT JTM5"; // J1850
const char * const DISP_KEY_WORDS = "AT KW"; // ISO
const char * const KEY_WORD_CHECKING_OFF = "AT KW0"; // ISO
const char * const KEY_WORD_CHECKING_ON = "AT KW1"; // ISO
const char * const LINEFEEDS_OFF = "AT L0"; // General
const char * const LINEFEEDS_ON = "AT L1"; // General
const char * const LOW_POWER_MODE = "AT LP"; // General
const char * const MEMORY_OFF = "AT M0"; // General
const char * const MEMORY_ON = "AT M1"; // General
const char * const MONITOR_ALL = "AT MA"; // OBD
const char * const MONITOR_FOR_PGN = "AT MP %s"; // J1939
const char * const MONITOR_FOR_RECEIVER = "AT MR %s"; // OBD
const char * const MONITOR_FOR_TRANSMITTER = "AT MT %s"; // OBD
const char * const NORMAL_LENGTH_MESSAGES = "AT NL"; // OBD
const char * const SET_PROTO_OPTIONS_AND_BAUD = "AT PB %s"; // OBD
m
er as
const char * const PROTOCOL_CLOSE = "AT PC"; // OBD
const char * const ALL_PROG_PARAMS_OFF = "AT PP FF OFF"; // PPs
co
const char * const ALL_PROG_PARAMS_ON = "AT PP FF ON"; // PPs
eH w
const char * const SET_PROG_PARAM_OFF = "AT PP %s OFF"; // PPs
const char * const SET_PROG_PARAM_ON = "AT PP %s ON"; // PPs
o.
const char * const SET_PROG_PARAM_VAL = "AT PP %s SV %s"; // PPs
const char * const rs e
DISP_PP_SUMMARY = "AT PPS"; // PPs
ou urc
const char * const RESPONSES_OFF = "AT R0"; // OBD
const char * const RESPONSES_ON = "AT R1"; // OBD
const char * const SET_RECEIVE_ADDRESS_TO = "AT RA %s"; // OBD
const char * const READ_STORED_DATA = "AT RD"; // General
o
//---------------------------------------------------------------------------------
This study source was downloaded by 100000828587148 from CourseHero.com on 06-26-2021 13:39:55 GMT -05:00
https://www.coursehero.com/file/98593628/Update-for-Githubtxt/
----//
// Class constants
//---------------------------------------------------------------------------------
----//
const float KPH_MPH_CONVERT = 0.6213711922;
const float RPM_CONVERT = 0.25;
const int8_t QUERY_LEN = 7;
const int8_t ELM_SUCCESS = 0;
const int8_t ELM_NO_RESPONSE = 1;
const int8_t ELM_BUFFER_OVERFLOW = 2;
const int8_t ELM_GARBAGE = 3;
const int8_t ELM_UNABLE_TO_CONNECT = 4;
const int8_t ELM_NO_DATA = 5;
const int8_t ELM_STOPPED = 6;
const int8_t ELM_TIMEOUT = 7;
const int8_t ELM_GENERAL_ERROR = -1;
class ELM327
m
er as
{
public:
co
Stream* elm_port;
eH w
bool connected = false;
o.
bool debugMode;
char* payload; rs e
ou urc
uint16_t PAYLOAD_LEN;
int8_t status = ELM_GENERAL_ERROR;
uint64_t response;
uint16_t recBytes;
o
uint8_t numPayChars;
aC s
uint16_t timeout_ms;
vi y re
byte responseByte_0;
byte responseByte_1;
byte responseByte_2;
byte responseByte_3;
byte responseByte_4;
ed d
byte responseByte_5;
ar stu
byte responseByte_6;
byte responseByte_7;
is
Th
bool begin(Stream& stream, const bool& debug = false, const uint16_t& timeout
= 1000, const char& protocol = '0', const uint16_t& payloadLen = 40);
bool initializeELM(const char& protocol='0');
void flushInputBuff();
uint64_t findResponse();
sh
uint32_t supportedPIDs_1_20();
This study source was downloaded by 100000828587148 from CourseHero.com on 06-26-2021 13:39:55 GMT -05:00
https://www.coursehero.com/file/98593628/Update-for-Githubtxt/
uint32_t monitorStatus();
uint16_t freezeDTC();
uint16_t fuelSystemStatus();
float engineLoad();
float engineCoolantTemp();
float shortTermFuelTrimBank_1();
float longTermFuelTrimBank_1();
float shortTermFuelTrimBank_2();
float longTermFuelTrimBank_2();
float fuelPressure();
uint8_t manifoldPressure();
float rpm();
int32_t kph();
float mph();
float timingAdvance();
float intakeAirTemp();
float mafRate();
float throttle();
uint8_t commandedSecAirStatus();
uint8_t oxygenSensorsPresent_2banks();
uint8_t obdStandards();
m
er as
uint8_t oxygenSensorsPresent_4banks();
bool auxInputStatus();
co
uint16_t runTime();
eH w
o.
uint32_t supportedPIDs_21_40();
rs e
ou urc
uint16_t distTravelWithMIL();
float fuelRailPressure();
float fuelRailGuagePressure();
float commandedEGR();
o
float egrError();
aC s
float commandedEvapPurge();
vi y re
float fuelLevel();
uint8_t warmUpsSinceCodesCleared();
uint16_t distSinceCodesCleared();
float evapSysVapPressure();
uint8_t absBaroPressure();
ed d
float catTempB1S1();
ar stu
float catTempB2S1();
float catTempB1S2();
float catTempB2S2();
is
uint32_t supportedPIDs_41_60();
Th
uint32_t monitorDriveCycleStatus();
float ctrlModVoltage();
float absLoad();
float commandedAirFuelRatio();
sh
float relativeThrottle();
float ambientAirTemp();
float absThrottlePosB();
float absThrottlePosC();
float absThrottlePosD();
float absThrottlePosE();
float absThrottlePosF();
float commandedThrottleActuator();
This study source was downloaded by 100000828587148 from CourseHero.com on 06-26-2021 13:39:55 GMT -05:00
https://www.coursehero.com/file/98593628/Update-for-Githubtxt/
uint16_t timeRunWithMIL();
uint16_t timeSinceCodesCleared();
float maxMafRate();
uint8_t fuelType();
float ethonolPercent();
float absEvapSysVapPressure();
float evapSysVapPressure2();
float absFuelRailPressure();
float relativePedalPos();
float hybridBatLife();
float oilTemp();
float fuelInjectTiming();
float fuelRate();
uint8_t emissionRqmts();
uint32_t supportedPIDs_61_80();
float demandedTorque();
float torque();
uint16_t referenceTorque();
m
er as
uint16_t auxSupported();
void printError();
co
eH w
o.
private: rs e
ou urc
char query[QUERY_LEN] = { '\0' };
bool longQuery = false;
uint32_t currentTime;
uint32_t previousTime;
o
aC s
vi y re
};
© 2021 GitHub, Inc.
Th
Terms
Privacy
Security
Status
Docs
sh
Contact GitHub
Pricing
API
Training
Blog
About
Loading complete
This study source was downloaded by 100000828587148 from CourseHero.com on 06-26-2021 13:39:55 GMT -05:00
https://www.coursehero.com/file/98593628/Update-for-Githubtxt/
Powered by TCPDF (www.tcpdf.org)