Bare-metal I²C driver on STM32
Write an I²C driver from scratch using only the STM32 register manual, read a BMP280 sensor, and check every byte on a logic analyser.
What this proves to recruiters
- You can work from a reference manual, without libraries.
- You understand I²C at the signal level.
- You debug with real tools, like embedded teams do.
Skills you will use
- Register-level C
- I²C protocol
- Logic analyser
- Datasheets
Parts list
You can buy the listed parts online here:
| Part | Qty | Approx. price | Shop |
|---|---|---|---|
| STM32F411 “Black Pill” board | 1 | ₹550 | Find on Amazon |
| ST-Link V2 programmer | 1 | ₹350 | Find on Amazon |
| BMP280 pressure and temperature sensor module | 1 | ₹120 | Find on Amazon |
| USB logic analyser, 8 channels, 24 MHz | 1 | ₹650 | Find on Amazon |
| Breadboard, 830 points | 1 | ₹90 | Find on Amazon |
| Jumper wire set (male-male and male-female) | 1 | ₹120 | Find on Amazon |
| Total, about | ₹1,900 | ||
Prices are rough online prices in India and change with the seller. You may already have some parts, or find them in your college lab.
As an Amazon Associate I earn from qualifying purchases. Buying through these links costs you nothing extra and helps keep this site free.
Free software
- STM32CubeIDE (only for building and debugging)
- PulseView / sigrok for the logic analyser
- STM32F411 reference manual
Steps
- Enable the GPIO and I²C clocks in RCC, and set the pins to alternate-function open-drain.
- Set the I²C timing registers for 100 kHz from your APB clock.
- Write functions for start, address, write byte, read byte and stop, checking the status flags at each step.
- Read the BMP280 chip-ID register (0xD0) and check it returns 0x58.
- Capture the transfer on the logic analyser and decode it in PulseView.
- Read the calibration data and convert raw readings into temperature and pressure.
Make it stand out
- Add timeouts so a stuck bus never hangs your program.
- Use DMA to read the sensor.
Put it on your resume
Wrote a register-level I²C driver for STM32 without vendor libraries; read a BMP280 sensor and verified transfers with a logic analyser.
Replace each [x] with a number you measured. Real numbers make a line believable.
Keep going
This project fits stage 2, “Bare-metal and peripherals”, of the Embedded systems and firmware roadmap. See also how freshers get into embedded C developer jobs.
More Embedded systems and firmware projects
- Wi-Fi thermometer with an OLED displayBeginner1 weekend~₹1,050
- FreeRTOS data logger with SD card and web viewIntermediate2–3 weekends~₹1,050
- Smart plant watering with a phone dashboardBeginner1–2 weekends~₹900
- Line-following robot with PID controlIntermediate2–3 weekends~₹1,850
- Linux character driver for an LED on Raspberry PiAdvanced3–4 weekends~₹5,900