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

Thread: Esp32 Teensy4.1 Serial Communication

  1. #1
    Junior Member
    Join Date
    Mar 2023

    Esp32 Teensy4.1 Serial Communication

    Hello, I am a beginner. I am trying to send it from esp32 to teensy 4.1 but I cannot. I have tried to use SPI and UART but I have failed both. I have connected my rx pin to tx pin also I have common ground.
    I have a simple code but it still does not work. Do you have an example code for transferring basic data like temperature?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Quote Originally Posted by iesadcal View Post
    Do you have an example code for transferring basic data like temperature?
    Yes, check out Bill Porter's EasyTransfer library. It's included with the Teensyduino installer. For non-Teensy boards, I'm sure you can find a copy online.

  3. #3
    UART is generally simpler than SPI since you don't need to worry about things like who is the bus master and whether the clock is running. Each direction can act independently without needing to worry about the other.

    In terms of hardware it should be very simple, connect Tx from device 1 to Rx on device 2 (and vica versa if you need communications in both directions). Connect the grounds. Power both units up.

    Possible hardware issues or things to do for reliable operation:
    ESP32 and T4.1 are both 3.3 volt IO so levels shouldn't be an issue. Watch out when connecting 5V parts to 3.3V parts, you need to make sure the 3.3V part can cope with 5V on the input pins.
    Try to power both up at the same time otherwise you can end up powering the chip through the IO pin protection circuits. This isn't advised and can damage the parts (more a long term issue than an instant failure). If this could happen put a resistor (say 30 to 100 ohms) in series with the data connections, this will limit the currents that can flow and protect the parts.
    Rx and Tx naming can get confusing - is that my transmit or something elses transmit to me.... always double check you don't have things crossed over, it's very easy to do once connections start getting more than a couple of wires.
    Don't get RS232 and TTL serial mixed up. They are the same protocol and use the same UART in the chips but RS232 uses a line driver to boost the voltages and so get larger distances. True RS232 can have up to +/- 15V on the lines, enough to fry a processor if connected directly. RS232 also inverts the voltages, it idles low rather than high.

    On the software side make sure both ends are set at the same baud rate and options (8 bit, no parity, 1 stop bit is a fairly standard default) and that flow control is turned off (normally the default).

    That should be all you need to do to get basic data transfer working. If one end sends a byte it should show up on the other end.
    For more complex data you may need to worry about data framing and making sure you are reading the data fast enough that the hardware receive buffer doesn't overflow. But neither of those issues should stop you from seeing data.

Posting Permissions

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