How to connect STM32 Blue Pill with 16x2 character LCD module using Arduino IDE?
December 30 2024
37
Inquiry
Global electronic component supplier AMPHEO PTY LTD: Rich inventory for one-stop shopping. Inquire easily, and receive fast, customized solutions and quotes.
QUICK RFQ
ADD TO RFQ LIST
The STM32 Blue Pill (STM32F103C8T6) can interface with a 16x2 LCD module using the I2C protocol (recommended) or direct GPIO connections.
The STM32 Blue Pill (STM32F103C8T6) can interface with a 16x2 LCD module using the I2C protocol (recommended) or direct GPIO connections. Below are steps for both methods.
🛠️ 1. Components Required
- STM32 Blue Pill (STM32F103C8T6)
- 16x2 LCD Module
- I2C LCD Adapter Module (for I2C method)
- Breadboard
- Jumper Wires
📌 Method 1: Using I2C Interface (Recommended)
⚡ Pin Connections (I2C Adapter on LCD)
I2C LCD Pin | STM32 Pin | Description |
---|---|---|
VCC | 3.3V | Power Supply |
GND | GND | Ground |
SDA | PB7 | I2C Data Line |
SCL | PB6 | I2C Clock Line |
📦 Install Required Libraries
In Arduino IDE, go to:
- Sketch > Include Library > Manage Libraries
- Search and install:
LiquidCrystal_I2C
💻 I2C LCD Code Example
🚀 Upload and Test
- Select Generic STM32F103C Series in Tools > Board.
- Ensure Upload Method: is set to STM32CubeProgrammer (SWD) or Serial.
- Upload the code.
- You should see the text "STM32 + LCD" and "Hello World!" displayed.
📌 Method 2: Direct GPIO Interface (Without I2C)
If you're not using an I2C module, connect the LCD directly to GPIO pins.
⚡ Pin Connections (Direct GPIO)
LCD Pin | STM32 Pin | Description |
---|---|---|
VSS | GND | Ground |
VCC | 3.3V | Power |
VEE | Potentiometer (for contrast) | Contrast Control |
RS | PA0 | Register Select |
RW | GND | Read/Write (GND for Write mode) |
E | PA1 | Enable |
D4 | PA2 | Data Bit 4 |
D5 | PA3 | Data Bit 5 |
D6 | PA4 | Data Bit 6 |
D7 | PA5 | Data Bit 7 |
A | 3.3V | LED Anode |
K | GND | LED Cathode |
📦 Install Required Library
- Go to Sketch > Include Library > Manage Libraries.
- Search and install:
LiquidCrystal
💻 GPIO LCD Code Example
🚀 Upload and Test
- Select Generic STM32F103C Series in Tools > Board.
- Upload the code.
- Text "STM32 + LCD" and "Direct GPIO!" should display on the screen.
🛡️ Troubleshooting
- I2C Issue: Check the I2C address (0x27 or 0x3F). Use an I2C Scanner sketch to verify.
- Display Issue: Adjust the contrast potentiometer on the LCD.
- Wiring: Double-check pin connections.
- Ensure STM32 drivers are correctly installed in Arduino IDE.
Populer Posts
AGFA006R16A2I3E
Intel
AGFB014R24B3I3E
Intel
M2S090TS-1FCSG325I
Microchip Technology
MPFS250T-1FCSG536T2
Microchip Technology
5ASTFD5K3F40I5NES
Intel
AGIC035R39A2I1VB
Intel
1SX280HN2F43I1VG
Intel
M2S025T-1VF256
Microchip Technology
5ASXMB5G4F40I5N
Intel
MPFS095TL-FCSG536I
Microchip Technology
10AS016E3F29E1HG
Intel
M2S150-FCG1152
Microchip Technology