logo elektroda
logo elektroda
X
logo elektroda

Lilygo T-Connect with ESP32 - CAN bus and three RS485 on one board

p.kaczmarek2 1113 9

TL;DR

  • Lilygo T-Connect industrial board pairs an ESP32-S3-WROOM-1 with up to three RS485 buses and one CAN line.
  • It uses removable TD501D485H-A RS485 and TD501MCANFD CAN modules, plus USB-C, hardware USB, and a 7-12 V DC power section.
  • The tested version is N16R8, with 16 MB Flash and 8 MB RAM, and the board cost around PLN200.
  • APA102 LEDs blinked with FastLED, and RS485 loopback traffic sent on one port was received and verified on another.
  • A full four-RS485 setup is impossible because the ESP32 hardware only provides three UART controllers.
Generated by the language model.
ADVERTISEMENT
This content has been translated flag-pl » flag-en View the original version here
📢 Listen (AI):
  • LilyGO T-Connect board with ESP32 module, green screw terminals, and a connected USB‑C cable
    Here I will introduce the Lilygo T-Connect industrial board distinguished by its simultaneous support of up to three RS485 buses and one CAN line. I ordered it from China for around PLN200.
    Clear plastic case with LILYGO T-Connect board; label reads “ESP32-S3 RS485/CAN Bus” Clear plastic case with black foam and a label with barcode and Chinese text
    We open the distinctive box and pull out the plate. What strikes you immediately is the ESP32-S3-WROOM-1 module which is the heart of the T-Connect, here in the N16R8 version, i.e. with 16 MB Flash and 8 MB RAM.
    LilyGO T-Connect board with ESP32 module, three RS485 modules, and green screw terminal blocks
    In the corner we have a power section with a voltage-reducing inverter, allowing the whole thing to run on 7-12 V DC, a USB C connector and a QWIIC with UART. There is no USB to UART converter, as the ESP32-S3 supports hardware USB. In addition, we have two rows of goldpins with GPIO, ground, 3.3 V and 5 V pinout, and four APA102 LEDs.
    LilyGO T-Connect PCB with ESP32-S3-WROOM-1 module, USB-C port, and GPIO header pins
    The RS485 and CAN modules are interchangeable - they can be removed from the board.
    LilyGO T-Connect board with ESP32-S3, RS485/CAN screw terminals, and lit status LEDs
    RS485 is supported by the TD501D485H-A and CAN by the TD501MCANFD, both with insulation up to 2500 V.
    Graphic of LilyGO T-Connect ESP32-S3 board with RS485 and CAN modules and labeled specifications
    The pin map is shown in the graphic below:
    Pin map of the LilyGO T-Connect board with ESP32-S3, RS485/CAN terminals, and APA102 LEDs
    Dimensions:
    LilyGO T-Connect board with green screw terminals and labeled dimensions 94×83×13 mm
    GitHub of the project:
    https://github.com/Xinyuan-LilyGO/T-Connect




    Demo LED
    I use Visual Code with the PlatformIO extension for this type of project. PIO does not have natively uploaded tiles from T-Connect, but on their repository you can download the missing files. They contain board configurations, flash memory, etc. In this case I have the 16 MB version. Below is the file I used - I gave it to the boards folder:
    Code: JSON
    Log in, to see the code

    The next file to edit is platformio.ini, which is the project configuration. I have named it APA102 Blink, because with these four LEDs I want to blink. There I selected the appropriate platform (espressif32 @6.5.0), selected the board and partitions, and added the library to handle the LEDs - fastled/FastLED. I also enabled PSRAM and USB mode there.
    Code: Ini
    Log in, to see the code

    How does the APA102 work? The APA102 is an individually addressable colour LED with SPI communication.
    Pinout diagrams and photos of APA102 and APA102C LED packages, both 5×5 mm
    I have put the pin definitions, for now only from the APA102, in pin_config.h:
    Code: C / C++
    Log in, to see the code

    It remains to write the actual program. This is essentially an example from FastLED, showing a simple colour animation.
    Code: C / C++
    Log in, to see the code

    The result is this simple animation:






    Demo RS485
    The second thing I would like to show is the RS485 demo. Basically it is crucial here, it is what this board was created for. There could be as many as 4 RS485 lines on the board, but the ESP32 only has 3 hardware UART controllers, so one will be inactive. I started by writing the pins into the code:
    Code: C / C++
    Log in, to see the code

    The TD501MCANFD and TF501D485H locations can be swapped if necessary, they are not soldered. RS485 is simply the physical layer of the UART, so we use the HardwareSerial classes here normally. With begin we set the baud and the pins.
    Code: C / C++
    Log in, to see the code

    My demo sequentially sends writes through the first port and receives them from the second port. After receiving, it checks to see if what was expected has arrived. You still need to connect these two ports together:
    Lilygo T-Connect board with USB connected and screw terminals; green and red LEDs lit
    As you can see, everything works. The data is transferred correctly:
    Screenshot of RealTerm showing RS485 logs with repeated “PING:216–226” messages and OK statuses.

    CAN bus activation
    Basically everything as in the topic below, just set the appropriate pins:
    How to establish a CAN connection between two ESP32s using the LilyGO T-CAN485 as an example?

    Summary
    Very nice board, I also like the modularity for CAN and RS485, although it's a bit of a shame that ESP hardware only has three UARTs, so it won't be possible to have four RS485 active at once. In addition, I like the conveniently routed GPIOs and up to four coloured LEDs, on which you can conveniently show various operating and error statuses.
    Do you see a use for a board with as many as three RS485?

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 14333 posts with rating 12235, helped 648 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 21857599
    oscil1
    Level 23  
    p.kaczmarek2 wrote:
    There is no USB to UART converter, as the ESP32-S3 supports hardware USB.

    To use this for erial is annoying, because after a reset you lose the connection - and comX initialises again, which disconnects. Not very convenient. Convenient for hardware debugging instead - this USB has a hardware JTAG - but that's something the Fellow has already missed, as he's using a child Arduino in the form of Platformio.

    I don't know why all this code - because it's probably pretty obvious that if it's RS-485, it will work, and sending and receiving something is something trivial. Similarly, setting the colour of the LED.

    The board has the name "T-Connect" which I don't think the Author noticed - which segues immediately into what the designers had in mind. Not the diodes, but the communication,

    A very naive review.
  • ADVERTISEMENT
  • #3 21858506
    gulson
    System Administrator
    The remark about JTAG on the ESP32-S3 is basically accurate, but that would have to be a separate discussion.

    Demonstrating the basic functions of the board (LEDs, RS485, CAN) is the standard format for a short hardware review. So is 'Hello World' and it is clear that the topic is not exhausted at all and perhaps there will be a continuation - depending on interest.

    By the way, PlatformIO is a full-fledged environment, so calling it 'childish' is not very substantive.

    Substantive discussion is always welcome, while I would ask you to maintain a culture of expression, thank you.
  • #4 21858779
    oscil1
    Level 23  
    gulson wrote:
    By the way, PlatformIO is a full-fledged environment, so calling it "childish" isn't very substantive.


    Such a gold "industry" standard with ESP32 is ESP32-IDF. Platformio is convenient for hobbyists (but is this board of any use in a hobbyist setting?) and for simple projects. ESP32-IDF, however, requires more experience working with complex systems (generally experience building projects under Linux, as it uses tools derived from that environment).

    'Hello world' testing for boards like this IMO makes zero sense - well, unless it turns out to be badly designed and just doesn't work.

    An interesting test would be e.g. stability, speeds etc. similar - but certainly not flashing an LED.
  • ADVERTISEMENT
  • #5 21859252
    TechEkspert
    Editor
    I was interested in these interchangeable interface modules, I wonder what their lifespan is?

    I read the material about CAN and I wonder in which projects CAN will be better than Modbus RTU and at the same time ethernet will be too complex there while wireless connections unattractive?
  • ADVERTISEMENT
  • #6 21859442
    oscil1
    Level 23  
    TechEkspert wrote:
    and I wonder in which projects CAN will be better than Modbus RTU and at the same time ethernet will be too complex there while wireless connections will be unattractive?


    - Modbus-RTU is a master slave system and the slave will not transmit anything until the master asks it to. In CAN - there is no such structure - each module can transmit, have priorities - which makes it more suitable for real-time systems. In CAN, the nodes can "talk" to each other directly - in Modbus, they don't

    - CAN is much more fault-tolerant and resistant to interference. CAN also has the possibility to disconnect devices that generate too many errors. The structure of the CAN packet makes it extremely resistant to electrical interference. In addition, ACK (of course only at the level that the recipient received the packet, but not that it understood it) and error handling are already at the hardware level

    CAN requires a more powerful MCU - because the whole CAN stack has to be implemented. Modbus is more trivial to implement and can therefore be easily put on very small MCUs.

    Ethernet - generally needs overly complex cabling, switches are more power hungry, for that it is of course unmatched when it comes to speed. But CAN and Modbus are not used to transmit, for example, camera images.

    WiFi and other berzones have the fundamental disadvantage that they penetrate obstacles badly, especially metal ones, and are sensitive to electromagnetic interference - which disqualifies them in industrial control systems.

    By the way, I use CAN transceivers for an unusual function - namely when I need to transmit I2C over a longer distance. SDA and SCL are converted to separate differential pairs. This works perfectly, and my devices e.g. work on many oil rigs under extreme conditions
  • #7 21859471
    TechEkspert
    Editor
    It will be interesting to see if one day the T1L single-pair ethernet will make its way onto a wider scale.
  • #8 21859500
    oscil1
    Level 23  
    TechEkspert wrote:
    I wonder if one day T1L single-pair ethernet will come into wider use.

    It's already popular - but you didn't ask about SPE. Even in one car you now have CAN, CAN FD and SPE
  • #9 21860184
    TechEkspert
    Editor
    All in all, SPE and T1L are topics I would like to read about on the electrode right after the practical guide Modbus RTU and CAN.

    I've seen a few demos from Microchip of a single pair ethernet, they transmitted video from a camera that fed from that single pair, data went to a display that also fed and communicated from a single pair.
  • #10 21860401
    oscil1
    Level 23  
    In fact, IMO the 10BASE-T1S is interesting because it enables the so-called miultidrop.
📢 Listen (AI):
ADVERTISEMENT