stanleyhuangyc / ArduinoOBD

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

Error during compliation #9

Open AlienSKP opened 10 years ago

AlienSKP commented 10 years ago

Hi I have the following error when I try to compile any sketch using the ODB lib :

OBD.cpp: In member function 'void COBDI2C::begin(byte)': OBD.cpp:333: error: 'Wire' was not declared in this scope OBD.cpp: In member function 'virtual void COBDI2C::write(char_)': OBD.cpp:369: error: 'Wire' was not declared in this scope OBD.cpp: In member function 'bool COBDI2C::sendCommand(byte, uint8t, byte, byte)': OBD.cpp:378: error: 'Wire' was not declared in this scope OBD.cpp: In member function 'virtual byte COBDI2C::receive(char)': OBD.cpp:390: error: 'Wire' was not declared in this scope OBD.cpp: In member function 'bool COBDI2C::btReceive(byte, byte)': OBD.cpp:429: error: 'Wire' was not declared in this scope OBD.cpp: In member function 'bool COBDI2C::gpsQuery(GPS_DATA*)': OBD.cpp:438: error: 'Wire' was not declared in this scope

I'm using :

Please someone help me !

I also noticed that my cable colors are DIFFERENT from the one found on your website. I have

Thanks in advance for your help.

novaspirit commented 10 years ago

i also just got my model A (UART) which i recieved yesturday yellow is rx0 white is tx1

AlienSKP commented 10 years ago

So I should connect yellow to the TX on my Mega 2650 (RX to the TX) and White to the RX. Am I right ? thanks

novaspirit commented 10 years ago

the other way around, yellow to rx and white to tx

AlienSKP commented 10 years ago

yellow to RX0 and white to TX0 :

avrdude: stk500v2_ReceiveMessage(): timeout avrdude: stk500v2_command(): unknown status 0xc8 avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check.

avrdude: stk500v2_command(): unknown status 0x01 avrdude: stk500v2_disable(): failed to leave programming mode

AlienSKP commented 10 years ago

Are you using latest version of OBD library ? you can compile without problem ?

stanleyhuangyc commented 10 years ago
Add #include <Wire.h> in your
  sketch
  On 2014/6/12 3:58, AlienSKP wrote:

  Hi
    I have the following error when I try to compile any sketch
    using the ODB lib :
  OBD.cpp: In member function 'void COBDI2C::begin(byte)':
    OBD.cpp:333: error: 'Wire' was not declared in this scope
    OBD.cpp: In member function 'virtual void
    COBDI2C::write(char*)':
    OBD.cpp:369: error: 'Wire' was not declared in this scope
    OBD.cpp: In member function 'bool COBDI2C::sendCommand(byte,
    uint8_t, byte*, byte)':
    OBD.cpp:378: error: 'Wire' was not declared in this scope
    OBD.cpp: In member function 'virtual byte
    COBDI2C::receive(char*)':
    OBD.cpp:390: error: 'Wire' was not declared in this scope
    OBD.cpp: In member function 'bool COBDI2C::btReceive(byte*,
    byte)':
    OBD.cpp:429: error: 'Wire' was not declared in this scope
    OBD.cpp: In member function 'bool COBDI2C::gpsQuery(GPS_DATA*)':
    OBD.cpp:438: error: 'Wire' was not declared in this scope
  I'm using :
  Freematic ODB-II Adapter for Arduino - Model A (UART) bought
      here : http://arduinodev.com/store/index.php?route=product/product&manufacturer_id=8&product_id=30

    Arduino Mega 2650 (last model)
    Arduino IDE v1.0.5
    Latest OBD library downloaded on GitHub (I even tried to
      revert to older versions without success). And I'd rather
      mention that I installed the library correctly.
    I also tried to include Wire.h library but it still throws
      errors...
  Please someone help me ! 
  I also noticed that my cable colors are DIFFERENT from the one
    found on your website. 
    I have 
  red (obviously VCC)
    black (obviously GRND)
    WHITE
    YELLOW
      Which one is TX and which one is RX ? is the white one
      supposed to be the blue one ??
  Thanks in advance for your help.
  —
    Reply to this email directly or view
      it on GitHub.
stanleyhuangyc commented 10 years ago
You should never connect Arduino OBD-II
  adapter to Serial0. This will affect code downloading.
  On 2014/6/12 8:57, AlienSKP wrote:

  yellow to RX0 and white to TX0 : 
  avrdude: stk500v2_ReceiveMessage(): timeout
    avrdude: stk500v2_command(): unknown status 0xc8
    avrdude: initialization failed, rc=-1
    Double check connections and try again, or use -F to override
    this check.
  avrdude: stk500v2_command(): unknown status 0x01
    avrdude: stk500v2_disable(): failed to leave programming mode
  —
    Reply to this email directly or view
      it on GitHub.
AlienSKP commented 10 years ago

Thank you Stanley for your help. I already included Wired lib..

So where should I plug it ? I have the Arduino Mega 2650 so a lot of other TX/RX available.. http://arduino.cc/en/Main/arduinoBoardMega2560

AlienSKP commented 10 years ago

I solved the issue by myself. I must say I didn't have much help from you guys, but thanks anyway ! OK SO 1 - make sure you plug like this : WHITE -> TX1 (pin 18 on the Mega 2650) YELLOW ->RX1 (pin 19 on the Mega 2650) This port is the Serial1. If you plan to use Serial2 or Serial3 on the Mega, you'll probably have to make some changes to the library : Line 22 : #define OBDUART Serial1
2 - make sure you include Wire library and you have the latest OBD-II lib as well 3 - DO NOT EXPECT ANY HELP from people highly skills like the previous 2 people who answered this post. They don't give a sh!t about noobs like us apparently :-1:
4 - Enjoy learning Arduino and never give up !

azzamsaziz commented 10 years ago

Trying not to give up here. The code always half works lol.

stanleyhuangyc commented 10 years ago

The code 100% works. Many users are using it without problem.