Go Down

Topic: Bike interface OBD (Read 14 times) previous topic - next topic

o5i_

#45
Jun 11, 2014, 09:51 pm Last Edit: Jun 11, 2014, 09:59 pm by o5i_ Reason: 1
I think i need to explain the problem.
If i use this code:
Code: [Select]

void setup() {
 Serial.begin(9600);    
 Serial1.begin(9600);
}
void loop() {
 if (Serial1.available()) {
   Serial.println(Serial1.read());
 }
}

i get:
Code: [Select]

103
217
123
229
103
217
123
229
103
217
123
229
103
217
123
235
103
217
123
0
103
217
123
0
103
217
123
235
103
217


But if i connect the wideband directly to the pc and printing values using Putty i get this:
Code: [Select]

14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8
14.8


If i do:
Code: [Select]
void setup() {
  Serial.begin(9600);   
  Serial1.begin(9600);
}
void loop() {
  if (Serial1.available()) {
    Serial.write(Serial1.read());
  }
}



i recieve this:
Code: [Select]
{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{åëgÙ{


Why putty shows me the right value but arduino does not??? Its just a serial connection... Is there a option for Serial read that can do that?

robtillaart

void setup()
{
 Serial.begin(9600);    
 Serial1.begin(9600);
}
void loop()
{
 if (Serial1.available())
 {
   Serial.print(Serial1.read(), DEC); //  print as decimal might help
 }
}
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

o5i_

Hi, i tried, but its just the same...
I think something in reading function is wrong because if i do serial read  to serial write it should be the same as it shows if i connect it directly but it isnt.....

robtillaart

the reading function returns an int  (2 bytes) and the write() wants a byte as param
That is why I proposed to use print () iso write() as print() can print int's
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

o5i_

dont know whats wrong... is it some ascii thing?

o5i_

#50
Jun 28, 2014, 07:38 pm Last Edit: Jun 28, 2014, 07:40 pm by o5i_ Reason: 1
Hi, im back from Holidays...
I added the cardslot to the board and tried if the sketch work but it didnt work, dont know why... If i try the sd example it works verry well and it is just the same... If i put everything in setup section it works but if i do the writing section to the loop it doesnt work...
I tested the circuit whit the z-diode but it is not the best choice, i think an opto-coupler work better...
http://fish.x64.me/doc/sdslogger01.ino

Go Up