each command,to the ECU is not instant and you must read all responses, i see you are not, so that means, the RX buffer is full of responses, and the next time you do look, it fill of all previous responses.
The ecu will send data, up to near 20 characters long. or errors.
The elm does this translation. and has no flow control be that HW,or SW, (no DTR pins, no xon/xoff) you must write smart code to get it work right, takes hard work.
here are some examples.
? (bad command)
no_data , attmepting to read a PID not supported by your car/ecu.
searching... (the ECU is busy, you must wait for at and if not, it halts the search, spits out and error and you get to try again,
and others.
here is just 1 command to the MAF, and the response.
0110 cr. response in hex next. see that?
30313130 D 3431 20 3130 20 3032 20 3045 20 DD3E:
nut shell.
you must send a command, the read all chars sent back ,then parse the for errors, if error repeat after a long delay, when you get OK, you have good data. It is not easy.
The ECU can get real busy, "spark, fuel injection, fancy EPA monitors. and can delay responses," If you read the ELM327 data sheet they tell you its a toy. (STN excepted?)
ok if you remove my SEEED BT set up code for your BT RN code (id love to get your RN setups)
yours will work.
here is my mpg SEEED project. see end of this post for full code.
http://www.fixkick.com/ELM327/taurus-sim/hacked.html#MPG
now my bug.:?
i can connect 1st time, with the RN41. $$$ , I,30, SR,112233DDEEFF, C (default code 1234 is good) and give all the ECU commands I want... .
on second connect it fails, i must do RN hard reset or SF,1 soft reset, or it will never connect again to ELM.BT. using C ,or Cxx , any ideas.. on my bug? Thanks!
MY STACK
D
Settings
BTA=0006664BFB38
BTName=MY41
Baudrt(SW4)=115K
Mode =Mstr
Authen=1
PinCod=1234
Bonded=0
Rem=112233DDEEFF
ASK MORE QUESTIONS, all is fresh in my mind now....
my actual code is here.
http://www.fixkick.com/ELM327/taurus-sim/Arduino/compiler/arduino-1.0.5/my-code/MPG/MPG-H5/seeed/seeed.ino