logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 351 1
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • LilyGO T-Connect board with ESP32 module, green screw terminals, and a connected USB‑C cable
    Here I will present an industrial Lilygo T-Connect board distinguished by its simultaneous support of up to three RS485 buses and one CAN line. I ordered it from China for around £200.
    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 immediately catches our eye 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.


    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 you won't be able 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 14139 posts with rating 12000, helped 644 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.
📢 Listen (AI):
ADVERTISEMENT