A lightweight and efficient port of the popular ITEAD Nextion Display Library, tailored for STM32 microcontrollers using HAL drivers and C++ support. This library simplifies serial communication between STM32 and Nextion HMI displays, enabling seamless GUI integration in embedded systems.
- 🔌 UART-based communication via STM32 HAL
- 🧾 Control pages, text fields, buttons, variables and more
- 🔁 Simple API to send/receive Nextion commands
- 💡 Designed for STM32CubeIDE with C++ enabled
- ⚡ Compatible with STM32F1, F4, and other STM32 families
⚠️ Note: This library is written in C++. Make sure your STM32 project is configured to support C++ (.cppfiles, proper C++ toolchain, andextern "C"where needed for HAL compatibility).
- STM32CubeIDE or STM32CubeMX
- STM32 HAL UART enabled
- C++ toolchain support in your STM32 project
- Nextion HMI display & Nextion Editor
├── Core
│ ├── Inc
│ │ └── nextion.h # C++ class interface
│ └── Src
│ └── nextion.cpp # Class implementation
├── README.md
-
Include the header in your
.cppfile:#include "nextion.h"
-
Create a
Nextioninstance and initialize:extern UART_HandleTypeDef huart1; Nextion nex(&huart1);
-
Send commands to the Nextion display:
nex.sendCommand("page 0"); nex.setText("t0", "Hello World!");
-
Read response (if needed):
std::string result = nex.receive();
- Use
.cppfiles for all your logic using this library. - Wrap C headers like
main.hor HAL includes inextern "C"if included in.cppfiles. - Ensure STM32CubeIDE is set to compile C++ files (rename
main.ctomain.cppif needed). - Disable unused C++ features (like RTTI/exceptions) in project settings for smaller binaries.
Contributions are welcome! Please feel free to fork this project, submit pull requests, or open issues to improve the library.
This project is licensed under the MIT License.
Developed by Aldrin Rebellow
🔗 LinkedIn