I2C Exercises
~55 min
uFerris uses an I/O expander. An I/O expander is used to expand the number of GPIO pins on a controller. The expander communicates over I2C to configure and control GPIO pins. This means we can get many more GPIO using only two I2C lines!
The expander used is the TCA6424, and the first exercise would be to find out its address.
Exercise A: Bus Scan
- Find a ready I2C example in the esp-hal I2C documentation
- Identify the Instantiate, Configure, and Control steps
- Adapt the pins to match the uFerris board (check your pinout card for SDA and SCL)
- Scan all addresses (0x01–0x7F) by attempting a write to each — note which devices respond
Exercise B: GPIO over I2C
The uFerris board uses a TCA6424 I/O expander — its address should have appeared when scanning in Exercise A.
- Configure a pin on the I/O expander as output
- Blink an LED connected to the I/O expander
Exercise C: Adaptation Challenge
- Configure a pin on the I/O expander as input
- Read the button state through the I/O expander
- Use it to control the LED — same logic as the GPIO exercise, but entirely over I2C
Cross-HAL Comparison
How do other HALs handle I2C? Navigate the documentation for these two libraries and find how they approach the same tasks:
Compare how each HAL handles Instantiate, Configure, and Control for I2C.