Linux ↔ ESP32 RS485 communication stack using ESP-IDF and Linux userspace UART programming.
This project demonstrates bidirectional RS485 communication between:
- Linux userspace UART application
- ESP32 firmware using ESP-IDF
- RS485 transceiver modules
The project focuses on low-level serial communication concepts including:
- UART configuration
- RS485 transport
- packet-based communication
- Linux serial programming with
termios - ESP-IDF UART driver usage
- communication debugging and testing
Linux UART Application
↕
USB ↔ RS485 Adapter
↕
RS485 Bus
↕
ESP32 UART + RS485 Module
linux-rs485-stack/
│
├── esp_rs485_driver/
│ ├── main/
│ ├── CMakeLists.txt
│ └── sdkconfig
│
├── linux_uart_app/
│ └── uart_app.c
│
├── README.md
├── .gitignore
└── .gitattributes
- POSIX UART serial programming
- UART configuration using
termios - Blocking UART RX/TX
- Raw byte stream handling
- Graceful application shutdown using signal handling
- Continuous UART receive loop
- ESP-IDF UART driver
- RS485 packet transmission
- Packet checksum generation
- UART RX/TX debugging
- Continuous packet transmission testing
| Parameter | Value |
|---|---|
| Baudrate | 115200 |
| Data Bits | 8 |
| Stop Bits | 1 |
| Parity | None |
| Flow Control | Disabled |
AA 55 01 56
| Byte | Description |
|---|---|
| AA | Start Byte |
| 55 | Command |
| 01 | Data |
| 56 | Checksum |
Compile:
gcc uart_app.c -o uart_appRun:
sudo ./uart_appBuild firmware:
idf.py buildFlash firmware:
idf.py flashOpen serial monitor:
idf.py monitor- ESP32 Development Board
- RS485 UART Module
- USB ↔ RS485 Adapter
- Linux Host Machine / VM
- UART communication verified
- RS485 transmission verified
- Linux UART RX/TX verified
- ESP32 UART TX verified
- Packet transmission verified
- CRC16 packet validation
- Packet parser state machine
- Timeout handling
- Retry mechanism
- Non-blocking UART
- Multithreaded Linux UART handling
- Modbus RTU support
- Packet framing improvements
- C
- ESP-IDF
- FreeRTOS
- POSIX Serial Programming
- UART
- RS485
- Linux