Arduino MEGA 2560 + HC-05 + EML327 simplest solution

Hi, Guys!

I’m before making an Arduino module onto my LADA VAZ 21925 “Kalina2 Sport” car, to display Ambient Temperature, Coolant Temperature, Fuel level (and with AM2320 module the indoor air temp and humidity).

Now the detection / display of indoor temp & humidity is solved, I’m interested in, what is Your opinion our sketch, where are the ELM327-READ-PID routines.

I will pair the HC-05 with MEGA 2560 like this: http://bibi21000.gallet.info/index.php/fr/accueil/82-racine-fr/public-fr/domotique-fr/arduino-fr/181-arduino-et-bluetooth.html Connections are the same.

What do You think? Is my sketch good, maybe I will cause damage in MOTRONIC of my car, or the sketch is wrong?

I could check this ino by the Arduino IDE, with success.

Thanks: rcph

ELM327.cpp (16.9 KB)

ELM327.h (9.09 KB)

ARD_ELM327_HC05_02.ino (4.44 KB)

Is my sketch good, maybe I will cause damage in MOTRONIC of my car, or the sketch is wrong?

should be ok if you trust the elm327.cpp code and all you're doing is reading.

but in your ARD ...ino file, do you realize you're displaying status instead of temperature and level?

Do You think for this part of the sketch?

"// ++++++++++++++++++++++++++++++++++++++++++++++++++++++
void readPID() {
status=Elm.coolantTemperature(temp);
if (status == ELM_SUCCESS){
// Serial.print("Coolant Temperature: ");
// Serial.println(status);
myGLCD.printNumI(temp,340,50);
}else{
// Serial.print("Elm begin failed with error: ");
// Serial.println(status);
}
status=Elm.ambientAirTemperature(temperature);
if (status == ELM_SUCCESS){
// Serial.print("Ambient Temperature: ");
// Serial.println(status);
myGLCD.printNumI(status,30,150);
}else{
// Serial.print("Elm begin failed with error: ");
// Serial.println(status);
}
status=Elm.fuelLevel(level);
if (status == ELM_SUCCESS){
// Serial.print("Fuel level: ");
// Serial.println(level);
myGLCD.printNumI(status,340,150);
}else{
// Serial.print("Elm begin failed with error: ");
// Serial.println(status);
}"

I think, that value of "status" variable will be the read temperatures and levels.

Do You think otherwise?

rcpilot_hun:
I think, that value of "status" variable will be the read temperatures and levels.

then how does this code work? is status a temperature value or ELM_SUCCESS?

status=Elm.ambientAirTemperature(temperature);
if (status  == ELM_SUCCESS){

andn do you pass temperature or a pointer to temperature , & temperature?

I've found in ELM327.cpp the following routine: (with another ones)

byte Elm327::ambientAirTemperature(int &temperature){
byte status;
byte values[1];
status=getBytes("01","41","46",values,1);
if (status != ELM_SUCCESS){
return status;
}
temperature=values[0]-40;
return ELM_SUCCESS;
}

It seems that this routine gives read values after getBytes 01 41 46 commands from ECU, and You can reach them via ambienAirTemperatue() function.

Oooh, maybe the readPID routine has to be like that:

void readPID() {
ambientAirTemperature(temperature);
myGLCD.printNumI(temperature,340,50);
}
else {
myGLCD.printNumI("ERROR",340,50);
}

don't you want to print the temperature, not the status?

Maybe these routines are good:

void readPID() {
Elm.coolantTemperature(temp);
if (status == ELM_SUCCESS){
myGLCD.printNumI(temp,340,50);
}else{
myGLCD.print(“HIBA”,340,50);
}
//
Elm.ambientAirTemperature(temperature);
if (status == ELM_SUCCESS){
myGLCD.printNumI(temperature,30,150);
}else{
myGLCD.print(“HIBA”,30,150);
}
//
status=Elm.fuelLevel(level);
if (status == ELM_SUCCESS){
myGLCD.printNumI(level,340,150);
}else{
myGLCD.print(“HIBA”,340,150);
}

ARD_ELM327_HC05_03.ino (4.03 KB)

yes

Hooray, thank You very much the reply! :slight_smile: