Giter Site home page Giter Site logo

Comments (8)

jimwhitelaw avatar jimwhitelaw commented on August 24, 2024

The important info is here:

Clearing input serial buffer
Sending the following command/query: AT SH 17FC007B
Received char: ?
Received char: \r
Received char: \r
Received char: >
Delimiter found.
All chars received:

The ? response indicates that the ELM device did not understand the command. See p.39 of the ELM327 datasheet for details on setting headers. As a guess, all the examples use spaces between the header bytes, so maybe try sending

AT SH 17 FC 00 7B

and see if that works.

from elmduino.

Waldmensch1 avatar Waldmensch1 commented on August 24, 2024

Nope, Result is the same

Connected to ELM327
Clearing input serial buffer
Sending the following command/query: AT SH 17 FC 00 7B
        Received char: ?
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received:

in the project where I found the PIDs they fire additional AT commands before set the header. Can this make a different in accepting the header?
Just to mention: The OBDII Adapter works well with Carscanner App in ioS. The Values for PID I try to use are shown without any problem.

    "AT Z",    // reset to default settings to be sure what the base setting are
      "AT I",    // Print the version ID
      "AT SP7",  // Set protokoll to 7 - ISO 15765-4 CAN (29 bit ID, 500 kbaud)
      "AT BI",   // Bypass the initialization sequence to make sure it stays at protokoll 7
      "AT CAF0", // Turns off CAN automatic formating so that PCI bytes are not inserted in the messages, or expected in the response
      "AT L0",   // Linefeeds off
      "AT DP",   // xxxxxxxxx
      "AT ST16", // reduced timeout to 1, orig.16

from elmduino.

jimwhitelaw avatar jimwhitelaw commented on August 24, 2024

If you know that the above sequence of AT commands is working with carscanner then perhaps try sending those first. From the output you've provided, I'm not convinced that the protocol has been successfully detected. The last AT command you send with an OK response is "AT TP A7". That tells the ELM to try protocol 7 and fall back to an auto search if that doesn't work. After that, the next command you send should trigger the protocol detection. The ELM327 datasheet (p.29) recommends sending "0100" command to trigger the protocol detection. You should get back a response that starts with "SEARCHING..." followed by some additional bytes indicating which PIDs are supported in that mode.

If you use the "AT SP 7" command as above, you won't have to go through the detection part, but it also won't search for any other protocol if 7 is not correct. All OBDII compliant systems are required to support command "0100" so it's a good test to see if you've actually got a valid connection from ELM to ECU before proceeding with other queries.

from elmduino.

Waldmensch1 avatar Waldmensch1 commented on August 24, 2024

I changed my loop that it plays out the AT command sequence I mentioned one by one. Also I set ATH1 to see what headers maybe come in. I try then to get the PIDs for SoC and Temp without setting a header. After that all I jump into a test console, where I can manueall send commands from serial terminal over to ELM. In Log you can see that the AT commands are all accepted and confirmed by ELM. Also if I send some commannd manually like 0140 I get a response 18 DA F1 0A 03 7F 40 11 AA AA AA AA. (ignore the echo I get from Terminal, have to find a way to switch of in PIO)
If I send a header without the leading 17 (FC007B) I get an "ok" back instead of "?" when I send 17FC007B. Could it be that the header is to long?

The Header and PID I have found in evDash project. What I meant with Carscanner was, that SoC and Temp get shown there as values, without knowledge of magic behind there. What I wanted to tell was that the ELM should be okay if other software can communicate.

This is the link to ID.3 specific code in evDash: https://github.com/nickn17/evDash/blob/master/src/CarVWID3.cpp

code:

void loop()
{
  button_loop();

  switch (cmd)
  {
  case CMD1:
  {
    if (myELM327.sendCommand_Blocking("AT Z") == ELM_SUCCESS)
      tft.println("AT Z okay");
    else
      myELM327.printError();
    cmd = CMD2;
  }
  case CMD2:
  {
    if (myELM327.sendCommand_Blocking("AT I") == ELM_SUCCESS)
      tft.println("AT I okay");
    else
      myELM327.printError();
    cmd = CMD3;
  }
  case CMD3:
  {
    if (myELM327.sendCommand_Blocking("AT SP7") == ELM_SUCCESS)
      tft.println("AT SP7 okay");
    else
      myELM327.printError();
    cmd = CMD4;
  }
  case CMD4:
  {
    if (myELM327.sendCommand_Blocking("AT BI") == ELM_SUCCESS)
      tft.println("AT BI okay");
    else
      myELM327.printError();
    cmd = CMD5;
  }
  case CMD5:
  {
    if (myELM327.sendCommand_Blocking("AT CAF0") == ELM_SUCCESS)
      tft.println("AT CAF0 okay");
    else
      myELM327.printError();
    cmd = CMD6;
  }
  case CMD6:
  {
    if (myELM327.sendCommand_Blocking("AT L0") == ELM_SUCCESS)
      tft.println("AT L0 okay");
    else
      myELM327.printError();
    cmd = CMD7;
  }
  case CMD7:
  {
    if (myELM327.sendCommand_Blocking("AT DP") == ELM_SUCCESS)
      tft.println("AT DP okay");
    else
      myELM327.printError();
    cmd = CMD8;
  }
  case CMD8:
  {
    if (myELM327.sendCommand_Blocking("AT ST16") == ELM_SUCCESS)
      tft.println("AT ST16 okay");
    else
      myELM327.printError();
    cmd = CMD9;
  }
  case CMD9:
  {
    if (myELM327.sendCommand_Blocking("ATH1") == ELM_SUCCESS)
    {
      tft.println("ATH1 okay");
      cmd = TEMP;
    }
    else
      myELM327.printError();
  }
/*  case CMD11:
  {
    tft.println("try set header");
    char header[20] = "\0";
    sprintf(header, SET_HEADER, "17FC007B");

    if (myELM327.sendCommand_Blocking(header) == ELM_SUCCESS)
      tft.println("Header 17FC007B okay");
    else
      myELM327.printError();

    cmd = TEMP;
  }*/
  case TEMP:
  {
    tft.println("try process PID 0x2a0b");
    float temp = myELM327.processPID(0x22, 0x2a0b, 1, 2, 1.0, 0.0);

    if (myELM327.nb_rx_state == ELM_SUCCESS)
    {
      DEBUG_PORT.print("Temp: ");
      DEBUG_PORT.println(temp);
      tft.print("Temp: ");
      tft.println(temp);

      cmd = SOC;
    }
    else
      myELM327.printError();
  }
  case SOC:
  {
    tft.println("try reading PID 22028C");
    // Query PID for SoC

    if (myELM327.queryPID(0x22, 0x028c)) // 22028C
    {
      int32_t tmpsoc = myELM327.findResponse();

      DEBUG_PORT.print("Payload for 22028C: ");
      for (byte i = 0; i < myELM327.PAYLOAD_LEN; i++)
      {
        DEBUG_PORT.print(myELM327.payload[i]);
      }
      DEBUG_PORT.println();

      if (myELM327.nb_rx_state == ELM_SUCCESS)
      {
        soc = tmpsoc;
        DEBUG_PORT.print("SOC: ");
        DEBUG_PORT.println(soc);

        tft.print("SOC: ");
        tft.println(soc);
      }
      else
      {
        DEBUG_PORT.println("SOC1: error");
        myELM327.printError();
        tft.println("--- failed");
      }
    }
    else
    {
      DEBUG_PORT.println("SOC2: error");
      myELM327.printError();
      tft.println("--- failed");
    }

    cmd = DIRECT;
  }
  case DIRECT:
  {
    wait = false;

    if (DEBUG_PORT.available())
    {
      char c = DEBUG_PORT.read();

      DEBUG_PORT.write(c);
      ELM_PORT.write(c);
    }

    if (ELM_PORT.available())
    {
      char c = ELM_PORT.read();

      if (c == '>')
        DEBUG_PORT.println();

      DEBUG_PORT.write(c);
    }
  }
  }

  if (wait == true)
    espDelay(5000);
}

Log:

[ 20618][I][BluetoothSerial.cpp:423] esp_bt_gap_cb(): ESP_BT_GAP_DISC_RES_EVT properties=3
[ 20619][I][BluetoothSerial.cpp:426] esp_bt_gap_cb(): Scanned device: 70:74:14:5c:a4:22
[ 20623][D][BluetoothSerial.cpp:467] esp_bt_gap_cb(): ESP_BT_GAP_DEV_PROP_COD 0x740420
[ 20631][D][BluetoothSerial.cpp:477] esp_bt_gap_cb(): ESP_BT_GAP_DEV_PROP_RSSI 174
[ 20638][I][BluetoothSerial.cpp:435] esp_bt_gap_cb(): ESP_BT_GAP_DISC_RES_EVT : EIR : My Skoda 9122 : 13
[ 21099][I][BluetoothSerial.cpp:423] esp_bt_gap_cb(): ESP_BT_GAP_DISC_RES_EVT properties=3
[ 21099][I][BluetoothSerial.cpp:426] esp_bt_gap_cb(): Scanned device: 70:74:14:5c:a4:22
[ 21103][D][BluetoothSerial.cpp:467] esp_bt_gap_cb(): ESP_BT_GAP_DEV_PROP_COD 0x740420
[ 21111][D][BluetoothSerial.cpp:477] esp_bt_gap_cb(): ESP_BT_GAP_DEV_PROP_RSSI 172
[ 21118][I][BluetoothSerial.cpp:435] esp_bt_gap_cb(): ESP_BT_GAP_DISC_RES_EVT : EIR : My Skoda 9122 : 13
[ 21996][I][BluetoothSerial.cpp:423] esp_bt_gap_cb(): ESP_BT_GAP_DISC_RES_EVT properties=1
[ 21997][I][BluetoothSerial.cpp:426] esp_bt_gap_cb(): Scanned device: 66:1e:11:00:fd:1e
[ 22001][I][BluetoothSerial.cpp:454] esp_bt_gap_cb(): ESP_BT_GAP_DISC_RES_EVT : SPP_START_DISCOVERY_BDNAME : OBDII
[ 22012][I][BluetoothSerial.cpp:503] esp_bt_gap_cb(): ESP_BT_GAP_DISC_STATE_CHANGED_EVT stopped
[ 22025][I][BluetoothSerial.cpp:503] esp_bt_gap_cb(): ESP_BT_GAP_DISC_STATE_CHANGED_EVT stopped
[ 23308][I][BluetoothSerial.cpp:587] esp_bt_gap_cb(): ESP-BT_GAP_* unknown message: 16
[ 23438][I][BluetoothSerial.cpp:350] esp_spp_cb(): ESP_SPP_DISCOVERY_COMP_EVT num=1
[ 23438][D][BluetoothSerial.cpp:353] esp_spp_cb(): ESP_SPP_DISCOVERY_COMP_EVT: spp [0] channel: 1 service name:SPP slave
[ 23445][I][BluetoothSerial.cpp:361] esp_spp_cb(): ESP_SPP_DISCOVERY_COMP_EVT: spp connect to remote 66:1e:11:00:fd:1e channel 1
[ 23460][I][BluetoothSerial.cpp:402] esp_spp_cb(): ESP_SPP_CL_INIT_EVT handle:129 sec_id:55
[ 23587][I][BluetoothSerial.cpp:384] esp_spp_cb(): ESP_SPP_OPEN_EVT
Clearing input serial buffer
Sending the following command/query: AT D
        Received char: A
        Received char: T
        Received char: _
        Received char: D
        Received char: \r
        Received char: \r
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATDOK
Clearing input serial buffer
Sending the following command/query: AT Z
        Received char: A
        Received char: T
        Received char: _
        Received char: Z
        Received char: \r
        Received char: \r
        Received char: \r
        Received char: E
        Received char: L
        Received char: M
        Received char: 3
        Received char: 2
        Received char: 7
        Received char: _
        Received char: v
        Received char: 1
        Received char: .
        Received char: 5
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATZELM327v1.5
Clearing input serial buffer
Sending the following command/query: AT E0
        Received char: A
        Received char: T
        Received char: _
        Received char: E
        Received char: 0
        Received char: \r
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATE0OK
Clearing input serial buffer
Sending the following command/query: AT S0
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: OK
Clearing input serial buffer
Sending the following command/query: AT AL
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: OK
Clearing input serial buffer
Sending the following command/query: AT ST 00
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: OK
Clearing input serial buffer
Sending the following command/query: AT TP A7
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: OK
Connected to ELM327
Clearing input serial buffer
Sending the following command/query: AT Z
        Received char: \r
        Received char: \r
        Received char: E
        Received char: L
        Received char: M
        Received char: 3
        Received char: 2
        Received char: 7
        Received char: _
        Received char: v
        Received char: 1
        Received char: .
        Received char: 5
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ELM327v1.5
Clearing input serial buffer
Sending the following command/query: AT I
        Received char: A
        Received char: T
        Received char: _
        Received char: I
        Received char: \r
        Received char: E
        Received char: L
        Received char: M
        Received char: 3
        Received char: 2
        Received char: 7
        Received char: _
        Received char: v
        Received char: 1
        Received char: .
        Received char: 5
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATIELM327v1.5
Clearing input serial buffer
Sending the following command/query: AT SP7
        Received char: A
        Received char: T
        Received char: _
        Received char: S
        Received char: P
        Received char: 7
        Received char: \r
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATSP7OK
Clearing input serial buffer
Sending the following command/query: AT BI
        Received char: A
        Received char: T
        Received char: _
        Received char: B
        Received char: I
        Received char: \r
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATBIOK
Clearing input serial buffer
Sending the following command/query: AT CAF0
        Received char: A
        Received char: T
        Received char: _
        Received char: C
        Received char: A
        Received char: F
        Received char: 0
        Received char: \r
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATCAF0OK
Clearing input serial buffer
Sending the following command/query: AT L0
        Received char: A
        Received char: T
        Received char: _
        Received char: L
        Received char: 0
        Received char: \r
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATL0OK
Clearing input serial buffer
Sending the following command/query: AT DP
        Received char: A
        Received char: T
        Received char: _
        Received char: D
        Received char: P
        Received char: \r
        Received char: I
        Received char: S
        Received char: O
        Received char: _
        Received char: 1
        Received char: 5
        Received char: 7
        Received char: 6
        Received char: 5
        Received char: -
        Received char: 4
        Received char: _
        Received char: (
        Received char: C
        Received char: A
        Received char: N
        Received char: _
        Received char: 2
        Received char: 9
        Received char: /
        Received char: 5
        Received char: 0
        Received char: 0
        Received char: )
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATDPISO157654CAN29500
Clearing input serial buffer
Sending the following command/query: AT ST16
        Received char: A
        Received char: T
        Received char: _
        Received char: S
        Received char: T
        Received char: 1
        Received char: 6
        Received char: \r
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATST16OK
Clearing input serial buffer
Sending the following command/query: ATH1
        Received char: A
        Received char: T
        Received char: H
        Received char: 1
        Received char: \r
        Received char: O
        Received char: K
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: ATH1OK
Service: 34
PID: 10763
Long query detected
Query string: 222A0B1
Clearing input serial buffer
Sending the following command/query: 222A0B1
Received:
No error detected
Service: 34
PID: 652
Long query detected
Query string: 22028C1
Clearing input serial buffer
Sending the following command/query: 22028C1
SOC2: error
Received:
No error detected
NO DATA
NO DATA1
>[ 32019][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
00110000
18 DA F1 0A 03 7F 00 11 AA AA AA AA 
>[ 82334][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
002288CC
18 DA F1 0A 03 7F 8C 11 AA AA AA AA 
>[165991][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
2222002288CC
NO DATA
>[188651][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
22AA00BB
NO DATA
>[223424][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
222222AA00BB
NO DATA
>[285664][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
22AA00BB
NO DATA
>[300434][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
AA00BB
NO DATA
>[315781][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
00bb
NO DATA
>00BB
NO DATA
>[327959][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
00
?
>[406159][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
2200
NO DATA
>[440184][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
1100
NO DATA
>[549142][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
00110000
18 DA F1 0A 03 7F 00 11 AA AA AA AA 
>[596048][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
00112200
18 DA F1 0A 03 7F 20 11 AA AA AA AA 
>[626106][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
00114400
18 DA F1 0A 03 7F 40 11 AA AA AA AA 
>[674289][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
00110055
STOPPED1 0A 03 7F 05 11 AA AA AA AA 
>[753411][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
001100CC
18 DA F1 0A 03 7F 0C 11 AA AA AA AA 
>[790979][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0
001155CC
18 DA F1 0A 03 7F 5C 11 AA AA AA AA 
>[865070][I][BluetoothSerial.cpp:583] esp_bt_gap_cb(): ESP_BT_GAP_MODE_CHG_EVT: mode: 0

from elmduino.

Waldmensch1 avatar Waldmensch1 commented on August 24, 2024

I found another big list of PIDs. If you search on this page for „BMS Temperatur Pack Gesamt“ - how this record can be used in ElmDuino the proper way to get a value? https://www.goingelectric.de/forum/viewtopic.php?p=1758362&sid=f3168951a5a627b2930c870df144f35a#p1758362

This is the record
[CCAN=UDS,13708,0x17FC007B,1011,5000,REG={0x22,0x2A,0x0B},TYPE={+,24,8,MSB},CONV={-40,1,2},EXT] # BMS Temperatur Pack Gesamt

My interpretation would be
Command AT SH 17FC007B
queryPid( „222A0B“)
or
queryPid(0x22, 0x2A0B)
or
processPid(0x22, 0x2A0B, 1, 1, 1.0, 1.0)

from elmduino.

Waldmensch1 avatar Waldmensch1 commented on August 24, 2024

I googled a bit around: could it be that UDS need a specific handling which is not supported yet by ELMDuino? I have seen some descriptions that the session have to be changed from OBD2 to UDS by fire a command like 0x1003 or so

from elmduino.

jimwhitelaw avatar jimwhitelaw commented on August 24, 2024

I don’t know much about UDS, but since it operates at a layer “above” CAN, it should be possible to use ELMduino to implement the sending and receiving of UDS data. You would need to implement the command formation and data parsing yourself for the PIDS you are interested in. The good news is you have successfully established communication with your ECU and move forward.

Also, I note that your switch/case in your loop isn’t working quite the way it should. After each successful response, you should set the next cmd state and then break. As it is, all of the commands are run without respect to the cmd state, immediately after each other. That works for the blocking commands, but is going to cause problems on the processPIDS() commands as there’s no waiting for a response before the next command is sent. Have a close look at the multiple PIDs example program for the correct pattern.

from elmduino.

Waldmensch1 avatar Waldmensch1 commented on August 24, 2024

many thanks for the hint with the break. Copy/paste of one piece of code multiplies the proplem :)

I get at least a response on 1003 command. I'll check tomorrow where to go from there

Connected to ELM327
Clearing input serial buffer
Sending the following command/query: 1003
        Received char: 5
        Received char: 0
        Received char: 0
        Received char: 3
        Received char: 0
        Received char: 0
        Received char: 3
        Received char: 2
        Received char: 0
        Received char: 1
        Received char: F
        Received char: 4
        Received char: \r
        Received char: \r
        Received char: >
Delimiter found.
All chars received: 5003003201F4

from elmduino.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.