u8g2
2.37.1Features
-
Support for a wide range of monochrome display controllers including SSD, SH, ST, UC, and IST series.
-
Dual-mode operation: U8g2 (full graphics) and U8x8 (text-only, direct-to-display).
-
Memory-optimized rendering using 1-page, 2-page, or full-frame buffer configurations.
-
Extensive font support with virtually no restriction on font height.
-
Comprehensive graphics primitives for drawing lines, boxes, circles, and frames.
-
Multiple communication protocol support: 3-wire/4-wire SPI, I2C (Hardware and Software), and 8-bit parallel (6800/8080).
-
Software-based display rotation for 0, 90, 180, and 270 degrees, plus mirroring support.
-
MUI (Minimal User Interface) subsystem for creating interactive menus and forms.
-
U8log component for emulating a serial terminal output on the display.
-
16-bit coordinate mode support for displays exceeding 240x240 pixel dimensions.
-
Support for specialized display technologies including E-Ink and VFD controllers.
-
Dynamic memory allocation options for page buffers to optimize RAM usage.
-
Integrated icon and symbol font libraries.
-
Tile-based coordinate system in U8x8 mode for extreme memory efficiency.
-
Hardware I2C pin remapping support for compatible microcontroller architectures.
Architecture
U8g2 is designed with a layered architecture that balances hardware abstraction with graphical flexibility. At the lowest level, the library interacts with display hardware through specific communication drivers (SPI, I2C, or Parallel). The U8x8 sub-library serves as the foundational layer, providing a direct-to-display interface that operates on 8x8 pixel tiles. This layer requires no RAM buffer in the microcontroller, making it suitable for the most resource-constrained environments.
Sitting above the hardware abstraction is the U8g2 graphics engine. This layer manages the rendering pipeline and provides the API for drawing primitives and complex fonts. A core architectural feature is the Page Buffer mechanism. To support high-resolution displays on microcontrollers with limited RAM, U8g2 can render the screen in horizontal slices (pages). The application uses a firstPage()/nextPage() loop to redraw the scene for each slice, which the library then transfers to the display controller. This allows for full graphical support even when the MCU cannot hold a complete frame buffer in memory.
Use Cases
This library is ideal for:
- Industrial Monitoring: Displaying real-time sensor data, telemetry, and diagnostic information on ruggedized monochrome LCDs.
- User Interfaces: Building interactive menus, settings screens, and forms using the MUI (Minimal User Interface) module.
- Portable Instrumentation: Implementing low-power visual feedback for handheld devices like multimeters, environmental sensors, or testers.
- System Logging: Utilizing the U8log component to create an on-screen terminal for real-time debugging without requiring a secondary PC connection.
- Battery-Powered Devices: Leveraging U8x8 mode to minimize CPU cycles and RAM usage, thereby extending the battery life of wearable or remote hardware.
- Retro Gaming and Hobbyist Projects: Rendering simple sprites and graphics on accessible platforms like Arduino, ESP32, and STM32.
Getting Started
To begin developing with U8g2, users should first identify their display controller and the desired communication interface. In the Arduino IDE, the library can be installed via the Library Manager. The setup process involves selecting a specific Constructor that matches the hardware; this constructor defines the controller type, the buffer strategy (Full, 1-page, or 2-page), and the physical pin connections.
Once the constructor is defined, the u8g2.begin() function initializes the display and sends the required setup sequence. Drawing operations are typically performed within a do...while loop using u8g2.firstPage() and u8g2.nextPage(). For developers working in pure C or porting to new platforms, the library provides a specific C-API and documentation for implementing custom hardware abstraction layers. Detailed reference manuals and setup guides for various controllers can be found in the official Wiki.
Related Projects (35)
View All 35 Projects →
E-OS — ESP32-S3 Handheld Console
A custom-built handheld gaming console powered by the ESP32-S3 and a dual-screen setup (TFT and OLED). It runs E-OS, a custom operating system built on FreeRTOS that features a dual-core architecture for dedicated rendering and logic. The project includes 15 custom-coded games and several applications, utilizing libraries like TFT_eSPI and U8g2 for high-performance graphics.
RisalDash
RisalDash is a C++ library for ESP32 and ESP8266 that automatically generates real-time web dashboards with zero front-end coding. It features a zero-waste architecture to minimize flash usage, built-in captive portal provisioning, and native integration with Home Assistant and AI agents via the Model Context Protocol (MCP).
ESP32 Flight Tracker
A real-time aircraft tracking system built for the ESP32-S3 that visualizes live flight data from the OpenSky Network API. It utilizes a dual-core FreeRTOS architecture to handle concurrent networking and high-speed rendering across a dual-display setup, featuring a hybrid map system optimized for hardware with limited PSRAM.
SkySweep32: Multi-band Passive Drone Detector
SkySweep32 is an ESP32-based passive drone detection system that monitors radio spectrum across the 900 MHz, 2.4 GHz, and 5.8 GHz bands. Utilizing FreeRTOS for concurrent signal processing, it identifies UAV control and video transmission patterns through hardware-accelerated scanning and signal fingerprinting.
M5_Crystal
M5_Crystal is a modular firmware for M5Stack devices like the M5StickCPlus2 and Cardputer, providing a suite of tools for Wi-Fi, NFC, and Bluetooth interaction. It utilizes the M5Unified and M5GFX libraries for hardware abstraction and is built on a custom wrapper system designed for rapid feature development.
ESP32 SoundFont (SF2) Sampler Synthesizer
A high-performance wavetable synthesizer firmware for ESP32-S3 and ESP32-P4 microcontrollers that plays SoundFont 2 (SF2) samples. It utilizes PSRAM for large sample banks, supports USB MIDI for plug-and-play connectivity, and features real-time audio effects like reverb and chorus.
QBIT
QBIT is an open-source desktop companion robot and personal IoT avatar based on the ESP32-C3. It features a custom monochrome animation system, integrated Wi-Fi management via NetWizard, and seamless Home Assistant integration through MQTT. The project includes a full-stack web platform for remote interaction, device claiming, and community animation sharing.
PixelRoot32 Game Engine
PixelRoot32 is a lightweight, modular 2D game engine written in C++17 for ESP32 microcontrollers and PC simulation. It features a scene-based architecture, NES-style audio synthesis, and a high-performance rendering pipeline optimized for embedded hardware using DMA transfers.