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

Thread: Serial communication to Arduino boards not working

  1. #1

    Serial communication with Arduino boards not working

    Hi,

    i tried a Pro Mini 3.3v, a Uno and a Mega to talk/receive to/from a Teensy 3.2 but it does not work.
    I'm using the EasyTransfer_TX/RX_Example and sure RX goes to TX and vise versa.
    I tried Serial1 and 2 and did set:
    Code:
    Serial.begin(9600);
    Serial2.begin(9600);
    ET.begin(details(mydata), &Serial2);
    On the Mega i tried Serial1...
    I tried in both directions...

    It works from Uno to Mega without problems.

    I'm really lost. Can it be IDE v1.6.13?
    Last edited by MrGlasspoole; 11-30-2016 at 03:36 AM.

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,506
    First up, have you set the device type as serial under the tools menu when programing the teensy? You need that if you want anything other than the Arduino terminal to see the USB serial traffic.

    Would suggest looking at the echo both teensy example and see what that shows you.

    And confirming, you are using Serial for data to/from PC on USB and Serial1 for data to/from pins 1 and 2. And have got Tx connected to RX and vice versa (not tx to tx and rx to rx)?

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,454
    Quote Originally Posted by MrGlasspoole View Post
    Hi,

    i tried a Pro Mini 3.3v, a Uno and a Mega to talk/receive to/from a Teensy 3.2 but it does not work.
    I'm using the EasyTransfer_TX/RX_Example and sure RX goes to TX and vise versa.
    I tried Serial1 and 2 and did set:
    Code:
    Serial.begin(9600);
    Serial2.begin(9600);
    ET.begin(details(mydata), &Serial2);
    On the Mega i tried Serial1...
    I tried in both directions...

    It works from Uno to Mega without problems.

    I'm really lost. Can it be IDE v1.6.13?
    on teensy, Serial is USB-serial and not hardware serial.
    to use hardware serial1 on teensy you must use Serial1.begin

  4. #4
    Quote Originally Posted by GremlinWrangler View Post
    First up, have you set the device type as serial under the tools menu when programing the teensy? You need that if you want anything other than the Arduino terminal to see the USB serial traffic.
    Yes but the example does not print anything it should just blink the LED.
    Quote Originally Posted by GremlinWrangler View Post
    And confirming, you are using Serial for data to/from PC on USB and Serial1 for data to/from pins 1 and 2. And have got Tx connected to RX and vice versa (not tx to tx and rx to rx)?
    Pin1(0) <> Arduino TX and Pin2(1) <> Arduino RX

    The only thing i do is adding
    Code:
    Serial1.begin(9600);
    and changing this serial to 1
    Code:
    ET.begin(details(mydata), &Serial1);
    on both sides:
    https://github.com/madsci1016/Arduin...TX_Example.pde
    https://github.com/madsci1016/Arduin...RX_Example.pde

    Quote Originally Posted by WMXZ View Post
    to use hardware serial1 on teensy you must use Serial1.begin
    I have serial2.begin there because i also tried it with Serial2 (RX2/TX2)

    I have now EchoBoth on the Teensy and the Mega if i type something and send i have output in both terminal.
    But it runs infinitely and just some random numbers behind "UART received:"
    Is that normal?
    Last edited by MrGlasspoole; 11-30-2016 at 12:40 PM.

  5. #5
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,506
    One complication here is that the mega will be running 5V logic so may not be getting clean results out of the Teensy 3.3.

    The infinite run will be because Echo Both sends data back out the hardware serial port, so you got two devices talking to each other endlessly, with some form of data mismatch going on.

    Given the hardware seems to be working would suggest editing the echo both example so they only seria1.print when data arrives from USB (remove the serial1 print on seria1RX), then connect the tx/rx of each board to itself (and not to the other board at all) and you should be able to echo data from the serial terminal out the port and back in again. Once that works on both boards leave the loop on one and connect the RX, which should give you the same message as seen on the local echo (leave the spare TX free).

    Also note difference between serial.print and serial.write as a potential source of numbers
    https://www.arduino.cc/en/Serial/Write
    https://www.arduino.cc/en/Serial/Print

  6. #6
    Ok i found the answer with google.
    The problem is 8 vs 32 bit: https://forum.pjrc.com/threads/36694...r-EasyTransfer
    After changing int to int16_t on both sides it works.

  7. #7
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,454
    Quote Originally Posted by MrGlasspoole View Post
    Yes but the example does not print anything it should just blink the LED.
    How should we have known, if there is not the whole code (see forum rule)?

  8. #8
    Because i wrote EasyTransfer_TX/RX_Example.
    Sorry - I thought since EasyTransfer is often recommended here...

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,720
    I've submitted a pull request to EasyTransfer.

    https://github.com/madsci1016/Arduin...ansfer/pull/14

    Hopefully Bill will merge this, so in the future EasyTransfer's examples will "just work" between 8 and 32 bit boards.

  10. #10
    I found some 2 years old code i used when i connected a Arduino to a BananaPi and had "buffer", "\r\n" and "flush" in my code...
    The Teensy has FIFO (build in buffer) does EasyTransfer take this into account?
    In the EasyTransfer examples i see delays (blocking)?

    So the question is: does EasyTransfer tap the full potential of the Teensy uart/serial features/speed?
    I also found this library: http://www.gammon.com.au/forum/?id=11428&reply=1#reply1

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,720
    The FIFOs on Serail1 and Serial2 are used automatically. Libraries like EasyTransfer never access these features directly.

Posting Permissions

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