ODB-II not work on mega 2560
Posted: Thu Oct 12, 2017 9:56 pm
Greetings,
I use "Freematics OBD-II UART Adapter V2 (for Arduino)" on my arduino mega 2560.
RED Power -> VIN
BLACK GND -> GND
White RX -> D0
Green TX -> D1
I use this code:
#include <OBD2UART.h>
COBD obd;
void setup(){
Serial.begin(9600);
Serial.println("Setup.start");
// we'll use the debug LED as output
pinMode(13, OUTPUT);
// start communication with OBD-II adapter
obd.begin();
// initiate OBD-II connection until success
while (!obd.init()){
Serial.print(".");
};
Serial.println("Setup.end");
}
void loop(){
int value;
// save engine RPM in variable 'value', return true on success
if (obd.readPID(PID_RPM, value)) {
// light on LED on Arduino board when the RPM exceeds 3000
if(value > 3000){
Serial.println("3000");
digitalWrite(13, HIGH );
}else{
digitalWrite(13, LOW);
}
}
}
When start the engine, the blue light's Freematics module is power on, some time later, it power off...
And arduino's serial output is:
Setup.start
......................
I have test with 3 arduino mega, all have the same result.
My vehicle is WV Up 2017.
What is wrong?
Best regards
I use "Freematics OBD-II UART Adapter V2 (for Arduino)" on my arduino mega 2560.
RED Power -> VIN
BLACK GND -> GND
White RX -> D0
Green TX -> D1
I use this code:
#include <OBD2UART.h>
COBD obd;
void setup(){
Serial.begin(9600);
Serial.println("Setup.start");
// we'll use the debug LED as output
pinMode(13, OUTPUT);
// start communication with OBD-II adapter
obd.begin();
// initiate OBD-II connection until success
while (!obd.init()){
Serial.print(".");
};
Serial.println("Setup.end");
}
void loop(){
int value;
// save engine RPM in variable 'value', return true on success
if (obd.readPID(PID_RPM, value)) {
// light on LED on Arduino board when the RPM exceeds 3000
if(value > 3000){
Serial.println("3000");
digitalWrite(13, HIGH );
}else{
digitalWrite(13, LOW);
}
}
}
When start the engine, the blue light's Freematics module is power on, some time later, it power off...
And arduino's serial output is:
Setup.start
......................
I have test with 3 arduino mega, all have the same result.
My vehicle is WV Up 2017.
What is wrong?
Best regards