ECEdge

Exam: GATE 2027 exams are on 6, 7, 13, 14, 20 and 21 February 2027. Official GATE 2027 site

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

Start of an I²C read from address 0x76SCLSDAS1110110WStart: SDA falls while SCL is high. Then the 7-bit address 0x76= 111 0110, then W (0) for write; the sensor then pulls SDA lowto acknowledge.
SDA falls while SCL is high (start), then the address follows, most significant bit first.

Parts list

You can buy the listed parts online here:

PartQtyApprox. priceShop
STM32F411 “Black Pill” board1₹550Find on Amazon
ST-Link V2 programmer1₹350Find on Amazon
BMP280 pressure and temperature sensor module1₹120Find on Amazon
USB logic analyser, 8 channels, 24 MHz1₹650Find on Amazon
Breadboard, 830 points1₹90Find on Amazon
Jumper wire set (male-male and male-female)1₹120Find 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

  1. Enable the GPIO and I²C clocks in RCC, and set the pins to alternate-function open-drain.
  2. Set the I²C timing registers for 100 kHz from your APB clock.
  3. Write functions for start, address, write byte, read byte and stop, checking the status flags at each step.
  4. Read the BMP280 chip-ID register (0xD0) and check it returns 0x58.
  5. Capture the transfer on the logic analyser and decode it in PulseView.
  6. 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

All 49 project ideas