ELMduino question

My goal is to read (engine coolant temperature and vehicle speed) and control engine cooling fan. So far I have been able to have my sketch compiled. I have yet to do the field test.

My sketch is a slightly modified version of ELMduino example. One statement I am not sure of is the (if condition):

if (!myELM327.begin(ELM_PORT, true, 2000))
{
Serial.println("Couldn't connect to OBD scanner");
while (1);
}

Does it mean (if the serial communication with ELM327 OBD2 reader is not successful within 2 seconds)? Thank you.

If the documentation is sparse or missing, the next step is to look for comments in the source code
https://github.com/PowerBroker2/ELMduino/blob/master/src/ELMduino.cpp

Thank you. I found sufficient comments in the code. It was as I guessed.

EDIT: All is working well. Thank you PowerBroker2 for ELMduino.

Hello powerbroker2 and thank you for the nice elmduino library
I used your sample code to read rpm and temp for a Bluetooth dongle. However, I get a lot of unnecessary replies where I am simply trying to get the rpm and temperature valuew. How do i shut off all the other incoming data? here is the code and output that I am using:
#include <SoftwareSerial.h>
#include "ELMduino.h"

SoftwareSerial mySerial(2, 3); // RX, TX
ELM327 myELM327;

uint32_t rpm = 0;
uint16_t Temp = 0;

void setup()
{
Serial.begin(38400);
mySerial.begin(38400);
myELM327.begin(mySerial, true, 2000);
}

void loop()
{
float tempRPM = myELM327.rpm();
float tempTemp=myELM327.engineCoolantTemp();
if (myELM327.status == ELM_SUCCESS)
{
rpm = (uint32_t)tempRPM;
Temp = (uint16_t)tempTemp;
Serial.print("RPM: "); Serial.println(rpm);
Serial.print("Temp: "); Serial.println(Temp);
}
}

and the output:
18:26:01.789 -> Received char: >
18:26:01.789 -> Delimiter found
18:26:01.789 -> All chars received: 410585
18:26:01.789 -> Expected response header: 4105
18:26:01.789 -> Single response detected
18:26:01.823 -> 64-bit response:
18:26:01.823 -> responseByte_0: 133
18:26:01.823 -> responseByte_1: 0
18:26:01.823 -> responseByte_2: 0
18:26:01.823 -> responseByte_3: 0
18:26:01.823 -> responseByte_4: 0
18:26:01.823 -> responseByte_5: 0
18:26:01.857 -> responseByte_6: 0
18:26:01.857 -> responseByte_7: 0
18:26:01.857 -> RPM: 682
18:26:01.857 -> Temp: 93
18:26:01.857 -> Service: 1
18:26:01.857 -> PID: 12
18:26:01.857 -> Normal length query detected
18:26:01.857 -> Query string: 010C
18:26:01.891 -> Clearing input serial buffer
18:26:01.891 -> Sending the following command/query: 010C
18:26:02.061 -> Received char: 4
18:26:02.061 -> Received char: 1
18:26:02.061 -> Received char: 0
18:26:02.061 -> Received char: C
18:26:02.061 -> Received char: 0
18:26:02.061 -> Received char: A
18:26:02.061 -> Received char: C
18:26:02.095 -> Received char: 8
18:26:02.095 -> Received char: \r
18:26:02.095 -> Received char: \n
18:26:02.163 -> Received char: \r
18:26:02.163 -> Received char: \n
18:26:02.163 -> Received char: >
18:26:02.163 -> Delimiter found
18:26:02.163 -> All chars received: 410C0AC8
18:26:02.163 -> Expected response header: 410C
18:26:02.197 -> Single response detected
18:26:02.197 -> 64-bit response:
18:26:02.197 -> responseByte_0: 200
18:26:02.197 -> responseByte_1: 10
18:26:02.197 -> responseByte_2: 0
18:26:02.197 -> responseByte_3: 0
18:26:02.231 -> responseByte_4: 0
18:26:02.231 -> responseByte_5: 0
18:26:02.231 -> responseByte_6: 0
18:26:02.231 -> responseByte_7: 0
18:26:02.231 -> Service: 1
18:26:02.231 -> PID: 5
18:26:02.231 -> Normal length query detected
18:26:02.265 -> Query string: 0105
18:26:02.265 -> Clearing input serial buffer
18:26:02.265 -> Sending the following command/query: 0105
18:26:02.435 -> Received char: 4
18:26:02.435 -> Received char: 1
18:26:02.435 -> Received char: 0
18:26:02.435 -> Received char: 5
18:26:02.435 -> Received char: 8
18:26:02.435 -> Received char: 5
18:26:02.469 -> Received char: \r
18:26:02.469 -> Received char: \n
18:26:02.537 -> Received char: \r
18:26:02.537 -> Received char: \n
18:26:02.537 -> Received char: >
18:26:02.537 -> Delimiter found
18:26:02.537 -> All chars received: 410585
18:26:02.571 -> Expected response header: 4105
18:26:02.571 -> Single response detected
18:26:02.571 -> 64-bit response:
18:26:02.571 -> responseByte_0: 133
18:26:02.571 -> responseByte_1: 0
18:26:02.571 -> responseByte_2: 0
18:26:02.605 -> responseByte_3: 0
18:26:02.605 -> responseByte_4: 0
18:26:02.605 -> responseByte_5: 0
18:26:02.605 -> responseByte_6: 0
18:26:02.605 -> responseByte_7: 0
18:26:02.605 -> RPM: 690
18:26:02.639 -> Temp: 93

I suppose the output is to the serial monitor. Since you will not place a serial monitor in the project box, should it matter? You will get rpm for RPM and temperature for TEMP. I hope this helps.

@tabsh

You can disable the debug printouts by replacing

myELM327.begin(mySerial, true, 2000);

with

myELM327.begin(mySerial);

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.