examples/peripherals/i2c/i2c_u8g2/README.md
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-H4 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|---|
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example demonstrates how to use the U8G2 graphics library with SSD1306 display over I2C interface using the new ESP-IDF I2C master driver. The demo showcases various U8G2 features in a continuous loop, including:
The project features a modular design with demo functions separated into dedicated source files for better maintainability and code organization. You could always add or remove various showcases to test out the graphic features in u8g2 library.
To run this example, you should have:
If you are using a display other than SSD1306 that is supported by the u8g2 library, you can modify the u8g2_Setup_ssd1306_i2c_128x64_noname_f function in main/i2c_u8g2_main.c to match your specific display controller. For details, please refer to: https://github.com/olikraus/u8g2/wiki/u8g2setupc.
Run menuconfig to configure the project settings:
idf.py menuconfig
Navigate to Example Configuration where you can configure:
All parameters can be adjusted without code modification to match your hardware setup.
Enter idf.py -p PORT flash monitor to build, flash and monitor the project.
idf.py -p PORT flash monitor
(To exit the serial monitor, type Ctrl-].)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
The display will show a continuous demo loop with various graphics demonstrations. And the terminal will print log meanwhile:
I (303) U8G2: Starting U8G2 display demo program (menuconfig based configuration)
I (303) U8G2: I2C Configuration: SDA=GPIO5, SCL=GPIO4, Freq=400000Hz, Timeout=1000ms
I (313) U8G2: Display Configuration: Address=0x3C
I (313) U8G2: Initializing display...
I (313) U8G2: GPIO and delay initialization completed
I (323) U8G2: I2C master driver initialized successfully
I (623) U8G2: Setting power mode...
I (623) U8G2: Display initialization completed
I (623) U8G2: Starting U8G2 demo sequence
I (2663) U8G2: Demo cycle: 1
I (2663) DEMO: Text Display
I (5693) DEMO: Geometric Shapes
I (8723) DEMO: Pixel Operations
I (11753) DEMO: Progress Bar
I (15283) DEMO: Animation Effects
I (24083) DEMO: Bitmap Display
esp_driver_i2c) instead of the legacy drivermenuconfig without code changes(For any technical queries, please open an issue on GitHub. We will get back to you as soon as possible.)