Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 16 of 16

Thread: Teensy 3.1 vs. Sparkfun OBD-II UART (STN1110)

  1. #1
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21

    Question Teensy 3.1 vs. Sparkfun OBD-II UART (STN1110)

    I am trying to get my teensy 3.1 to communicate with the STN1110 on board the Sparkfun OBD-II UART board (https://www.sparkfun.com/products/9555), but without much (any) luck.

    I have communicated with the OBD board with a simple serial connection on my Arduino, but when I hook the board up to the Teensy (serial3 port) I cannot seem to get any serial communication going. I have tried switching the TX/RX wires, just to make sure that that wasn't the case.

    I know the OBD likes 5v, but as far as I can read the Teensy is ok with 5v on the RX/TX pins? Any ideas as to what I am missing?

    Many thanks in advance

  2. #2
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21
    Just to add a bit of information that might be missing

    Code is available here: https://bitbucket.org/bomadsen/arduino/src
    In the obd scetch and BMOBD library. The code currently shows Serial1, but I have attached the board to Serial3 and changed the code locally.

    Wiring is pretty simple, board RX -> Pin 7, board TX -> Pin 8, board GND to GND. I have tried to switch RX/TX pins, but with the same non-existing result.

    If I touch the RX/TX pins on the board I can see the boards RX/TX diods flashing. But there is nothing when I send data to it.
    I can see a guy on the sparkfun page that moans about 3.3v vs. 5v, but as far as I can see from the STN1110 datasheet, it is 3.3v on the UART.

    Please let me know if you need any other information.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Quote Originally Posted by BoMadsen View Post
    board RX -> Pin 7, board TX -> Pin 8, board GND to GND.
    You might need to swap those 2 signals? Or maybe Sparkfun has already swapped then, so it's actually transmitting on the RX pin?

    Pin 7 on Teensy 3.1 is "RX3" and pin 8 is "TX3". It seems strange to connect the RX pin on this board to the RX3 pin on Teensy. Are they both trying to receive on the same pin? I'm honestly not sure... Sparkfun's schematic seems to show the wires swapped on the board itself. Confusing!

  4. #4
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21
    I share your confusion Which is why I tried to swap them a couple of times, but with seemingly the same non-existing result. But if everything else seems ok, I will try and swap some more tonight when I get home. Thanks

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    I can take a quick look at the code. I followed the link to your bitbuck, but it's not clear to me which part is the code you're using. I'll take another look if you'll post a more specific link to the exact code you're using. A link to the library would be good too. I followed a few from Sparkfun's page, but which one also wasn't clear to me.

  6. #6
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21
    Thanks for taking the time to do this, it is much appreciated!

    Code is really simple, sketch is here:
    https://bitbucket.org/bomadsen/ardui....ino?at=master

    Library is home developed here:
    https://bitbucket.org/bomadsen/ardui....cpp?at=master

    I don't think you need to dig too deep into the code, as it fails in the initial obd.begin() method

    Symptoms are: no data is received, and according to the UART TX/RX diods on the OBD board there is not serial activity what so ever. So unless I need to do some special magic to activate Serial3 (I know it says Serial1, but I have changed it in the local code to 3), I think I messed up on a hardware level instead.

  7. #7
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21
    I have just tried connecting directly to the OBD board using an FTDI cable as described here https://www.sparkfun.com/tutorials/294 , and it worked fine. So the board seems to be alright, so I just need to figure out where I have made an error in the Teensy setup

  8. #8
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21
    Paul, if we ever meet I am buying beer. It seems that I have sent you on a goose entirely brought on by my electronics incompetence. After having mocked about with the connections, it worked! So it must have been some kind of wiring issue
    I am sorry for the trouble, and beer is on me if we ever meet

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Glad you got it working.

  10. #10
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21
    I am sorry to resurrect this old thread, but I am once again stumped
    I have moved my project from the bread board to the actual project case, and now the communication with the OBD board is lost...again.

    Symptoms are:
    It seems that I can send commands to the board, but not receive any output from the board. This has been verified with the below program by the following: If I send the command ATZ (using the Serial Monitor in the arduino ide), I can see the board resetting because it turns all the leds on/off in sequence, but nothing is printed in the serial monitor.

    Setup is as follows:
    board TX to Teensy RX3/7, board RX to Teensy TX3/8, board gnd to Teensy gnd. These have all been verified with a multimeter on beep setting (I am sure it has a correct technical term, but I hope you understand what I mean).

    Program used to test the comms:
    Code:
    void setup()
    {
      Serial3.begin(9600);
      Serial.println("Ready!");
    }
    
    void loop()
    {
      if(Serial3.available())
      {
        char c = Serial3.read();
        Serial.print(c);
      }
      if(Serial.available())
      {
        char c = Serial.read();
        Serial3.print(c);
      }
    }
    Any ideas on what could cause the communication from the Teensy to the boad to work, but nothing from the board to the Teensy?

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Well, you could try something like this:

    Code:
    void setup() {
      Serial3.begin(300);
    }
    
    void loop() {
      Serial3.println("                 hello world                        ");
      delay(1500);
    }
    Printing mostly spaces has a lot of bits that are zero, and a slow baud rate maximizes the time those zeros will take, which makes observing the bursts of data easier with a multimeter.

    Then you can measure the voltage at the Teensy TX3 pin, and right on the FTDI board input, to see if it's getting the signal.

    Of course, make sure the FTDI and Teensy3 baud rates match. If you transmit much slower than the receiver, it will ignore the signal because every 0 bit looks like a break signal instead of a valid byte with a (high) stop bit.

  12. #12
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21
    Hi Paul,

    Thanks for the input, it is much appreciated.
    However, transmitting to the board seems to go ok. When I send the reset command ("ATZ\r") I can see the board resetting (because it flashes all its lights in sequence), but I am not getting the response it is supposed to send.

    But you are touching on something with all the zeroes, because I am at a loss on how to debug where the communication breaks down. I can see that the board thinks it is sending some data (as the UART TX diode flashes on the board), and I can measure that the TX of the board is connected to the RX of the teensy. But I can also see that nothing gets through when I try to Serial3.read(). Lacking any fancy electronic equipment, I am not sure how to debug this...

  13. #13
    While I am not using the Sparkfun board, I am having a similar issue. I have been using the OBD-II adapter made by Stanley Huang (http://arduinodev.com/hardware/obd-kit/) successfully with the Uno/Mega/Yun/Pro Mini(5v), but it seems a bit less cooperative with the Teensy 3.1 (I seriously love this board, btw). Like you, it does transmit as expected (reading "ATZ\r" from another Arduino) but I don't receive anything back. I have been able to initialize communication a handful of times, but it hasn't lasted more than just a few seconds. Granted, I worked through a number of other issues with my code which were causing problems, but I've stripped it down to the bare bones and I'm still having the same issues. I have been using Serial1 rather than Serial3, but I'm going to try out a few things today and (hopefully) figure out what the deal is. I picked up a Bus Pirate some time ago which I haven't yet figured out how to use, but this seems like a good opportunity. I'll post what I find.

  14. #14
    It would appear that my primary issue has less to do with the Teensy than I'd thought, and more to do with connections. I don't know if it's a grounding issue, but I was only able to successfully connect to the CAN when the adapter was plugged in after the car had been started (or at least was powered on). It's possible that you're having similar issues, but I'm not sure that's the case.

    In other news, the Bus Pirate doesn't seem like the right fit for UART/logic debugging - it's pretty tough to get the sampling rate matched up with the baud without any timing issues. In any case, adding a few lines of code to send debugging messages out the USB on the Teensy was much easier.

  15. #15
    Member
    Join Date
    Dec 2013
    Location
    57.011495,10.039845
    Posts
    21
    Hi Aaron,

    Thank you for sharing your experiences, I am glad you got it working

  16. #16
    Somehow I failed to mention that I also threw in a level-shifter. Since then, things have been working quite reliably. Have you tried that?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •