This project reads data from a FATEK PLC over Modbus RTU (RS485) and shows status messages on a HUB75 LED matrix panel.
The firmware runs on ESP32 and uses two FreeRTOS tasks:
- one task for Modbus communication;
- one task for LED matrix rendering.
- Reads PLC coils and registers (
M,D,R) through Modbus RTU. - Converts selected register ranges into text.
- Chooses a display scenario based on PLC state.
- Shows 3-line messages with centered text and smooth scrolling.
- Detects PLC communication timeout and shows error status.
The firmware always shows only one active scenario, based on this priority order (top = highest priority):
-
Scenario 6 - Communication error
Condition: Modbus communication timeout.
Display:Acest post este INDISPONIBIL E0 -
Scenario 7 - Unavailable
Condition:M120 = 0(only when communication is OK).
Display:Acest post este INDISPONIBIL E1 -
Scenario 5 - Pause finished
Condition:M99 = 1andD0 > 0. -
Scenario 4 - Pause
Condition:M97 = 1andD0 > 0. -
Scenario 3 - Function display
Condition:M94 = 1, exactly one ofM71..M79 = 1, andD0 > 0. -
Scenario 1 / 1.1 / 1.2 - Welcome states (
D0 = 0)- Scenario 1:
M320 = 1 - Scenario 1.1:
M322 = 1 - Scenario 1.2:
M321 = 1
Internal text selection order in code:1.2->1.1->1.
- Scenario 1:
-
Scenario 2 - Amount introduced
Condition:D0 > 0(used when higher-priority scenarios are not active).
Some lines are static and some lines scroll from right to left, based on scenario and text length.
M71..M79(0x817..0x81F): select active function group in Scenario 3 (exactly one active).M94(0x82E): enables Scenario 3 logic.M97(0x831): enables Scenario 4 (Pause).M99(0x833): enables Scenario 5 (Pause finished).M120(0x848): availability flag (0-> Scenario 7 unavailable message).M320(0x910): Scenario 1 (welcome + minimum amount).M321(0x911): Scenario 1.2 (welcome variant with Boxa + ATM message).M322(0x912): Scenario 1.1 (welcome variant with tokens message).
D0(0x1770): core amount/status condition (D0 = 0for welcome states,D0 > 0for amount-based states).D10(0x177A): used in Scenario 1 to buildminim X Lei/Leu.D47..D49(0x179F..0x17A1): time/value formatting for Scenario 3 and Scenario 5.D57..D59(0x17A9..0x17AB): time/value formatting for Scenario 4.
- Used ranges:
R10..R99(0x0A..0x63) andR110..R199(0x6E..0xC7). - These registers hold ASCII text payload for Scenario 3.
- Mapping by active
Mbit:M71-> line 1 fromR10..R19, line 2 fromR110..R119M72-> line 1 fromR20..R29, line 2 fromR120..R129M73-> line 1 fromR30..R39, line 2 fromR130..R139M74-> line 1 fromR40..R49, line 2 fromR140..R149M75-> line 1 fromR50..R59, line 2 fromR150..R159M76-> line 1 fromR60..R69, line 2 fromR160..R169M77-> line 1 fromR70..R79, line 2 fromR170..R179M78-> line 1 fromR80..R89, line 2 fromR180..R189M79-> line 1 fromR90..R99, line 2 fromR190..R199
The display uses RGB colors from code (via color565 conversion):
- White:
(255, 255, 255)for welcome messages (Scenarios 1/1.1/1.2) - Light green:
(128, 255, 128)for Scenario 2 - Red:
(255, 0, 0)for Scenarios 6 and 7 - Orange:
(255, 128, 0)for Scenario 4 title - Pink:
(255, 128, 128)for Scenario 5 title lines - Blue accent:
(128, 128, 255)for time lines in Scenarios 3/4/5
Scenario 3 line colors by function bit:
M71:(0, 255, 128)M72:(0, 128, 255)M73:(255, 0, 255)M74:(0, 255, 255)M75:(128, 255, 0)M76:(255, 0, 128)M77:(128, 0, 255)M78:(0, 255, 0)M79:(255, 255, 0)
- MCU: ESP32
- PLC link: RS485 (Modbus RTU)
- Matrix: HUB75, configured as
64x32, chain1 - HUB75 to ESP32 pin mapping used in this project:
R1->GPIO25G1->GPIO26B1->GPIO27R2->GPIO14G2->GPIO12B2->GPIO13A->GPIO23B->GPIO19C->GPIO18D->GPIO5E->-1(not used for current panel setup)LAT->GPIO32OE->GPIO15CLK->GPIO33
- Modbus serial defaults in code:
- RX:
16 - TX:
17 - RE/DE:
4 - Baud:
115200 - Slave ID:
1
- RX:
For deeper technical details about FATEK register maps, addressing, and protocol behaviour, use the manuals below (local PDFs under Manuale/ when you have them in your copy of the project) and the official references.
- Modbus Organization — specifications — Modbus Application Protocol (function codes, PDU framing).
- Check FATEK official documentation / downloads on fatek.com for the latest PLC manuals for your CPU series (register maps may vary by model).
| Document | Path (relative to repo root) |
|---|---|
| PLC binary communication protocol (user manual, EN) | Manuale/08_M_PLC_Binary_Communication_Protocol_User_Manual_en.pdf |
| FB / FBs reference (B1 / B1z) | Manuale/FATEK_FB_FBs_B1_B1z.pdf |
| WinProladder manual (EN) | Manuale/Comunicare/FATEK manuals/WinProladder_Manual_en.pdf |
| Supplement chapters | Manuale/Chapter_12.pdf, Manuale/Appendix1.pdf, Manuale/Apendix 2.pdf |
These explain how FATEK exposes coils/registers over communication and how addressing relates to ladder programming tools.
Folder: Manuale/Comunicare/Curs ModBus RTU/
| Topic | File |
|---|---|
| Overview / history | Modbus+History+and+Overview.pdf |
| RTU vs ASCII | Modbus+RTU+vs+ASCII.pdf |
| Message structure | Modbus+Message+Structure.pdf |
| Function codes | Modbus+Function+Codes.pdf |
| Addressing | Modbus+Addressing.pdf |
| Serial / transmission | Modbus+Serial+Transmission+Modes.pdf |
| RS485 physical layer intro | RS485+Serial+Communication+Standard.pdf |
| Troubleshooting | Modbus+RS485+Troubleshooting+Quick+Reference.pdf |
| Course notes | Modbus_RS485_Course_Notes-Laurens_Vanhoyland.pdf |
Folder: Manuale/Comunicare/RS485 proiect/documentatie/
modbusprotocolspecification.pdf— Modbus protocol specification copyMAX485.pdf— RS485 transceiver datasheet notesChapter_13.pdf,Modbus_RS485_Course_Notes-Laurens_Vanhoyland.pdf
Note: If Manuale/ is not in your GitHub clone, copy these folders from your archive or download manuals from FATEK / Modbus.org so links stay meaningful locally.
main/main.ino- main firmware, display scenarios, task creation.main/FATEKModbus.h- Modbus data structures and API.main/FATEKModbus.cpp- Modbus polling, parsing, error handling, communication state.
This project uses:
ESP32-HUB75-MatrixPanel-I2S-DMA(HUB75 library)eModbus(Modbus RTU client on ESP32)Arduino Core for ESP32(Arduino core/framework components)
This repository is licensed under GNU General Public License v3.0 (GPL-3.0).
See the full license text in the LICENSE file.
This project includes or depends on third-party software with permissive/compatible licenses:
- HUB75 library (
ESP32-HUB75-MatrixPanel-I2S-DMA) - MIT License - GitHub - eModbus - MIT License - GitHub
- Arduino core/framework parts - LGPL-compatible usage - GitHub
Compatibility note:
- MIT-licensed code is compatible with GPL-3.0 and can be used in a larger GPL project.
- Arduino LGPL components are also compatible with this use model.
Important obligations kept by this project:
- Original copyright/license notices from MIT dependencies must be preserved.
- Third-party license terms remain valid for their own code parts.
- This project-level license (GPL-3.0) applies to the project as distributed.
If you redistribute this project, keep this README.md, the LICENSE file, and all required third-party attribution/license notices.



