stanleyhuangyc / ArduinoOBD

OBD-II library and sketches for Arduino
http://freematics.com
968 stars 519 forks source link

read Speed #57

Open cuongcoco opened 5 years ago

cuongcoco commented 5 years ago

hi i want read speed by obdIIUART and print it to Serial monitor my code is

include

COBD obd;

void setup() { // we'll use the debug LED as output pinMode(13, OUTPUT); Serial.begin(115200); // start serial communication obd.begin(); // initiate OBD-II connection until success while (!obd.init()); }

void loop() { int SPEED; if (obd.readPID(PID_SPPED, SPEED)) {

Serial.println(SPEED);

} delay(500); }

but my result is ATIATZATE0ATH0010D0100012001400160 010D50 010D50 010D50 why it happend? i only want "50" as speed please help me

ivanpajon commented 5 years ago

Hi, I think your error can be that you have mispelled PID's name, you need to write PID_SPEED instead of PID_SPPED, so wrong code would see like:

if (obd.readPID(PID_SPEED, SPEED)) {
    Serial.println(SPEED);
}

I hope this can help you.