Appendix A: Annotated References
The numbers in the appendix and the MicroSims come from these sources.
The Bus Itself
- UM10204: I2C-bus specification and user manual, Rev. 7.0 - NXP Semiconductors, 1 October 2021.
The official definition of I2C. Revision 7.0 replaced "master/slave" with "controller/target". It lists the reserved addresses (
0000 XXXand1111 XXX). It gives the bit rates: 100 kbit/s standard mode, 400 kbit/s fast mode and 1 Mbit/s fast-mode plus. - I2C (Wikipedia) - a readable overview of the history, the open-drain design and the protocol.
- I2C tutorial (SparkFun) - a beginner-friendly walk through START, addresses, ACKs and pull-ups.
Programming the Bus
- machine.I2C (MicroPython documentation) - defines
I2C(id, scl=, sda=, freq=400000),scan()(all addresses from0x08to0x77; a device responds if it pulls SDA low after its address and write bit),readfrom_mem()andwriteto_mem(). - Raspberry Pi Pico Python SDK - the Pico's two I2C controllers and which pins they can use.
The Devices
- MPU-6000 and MPU-6050 Register Map and Descriptions (document RM-MPU-6000A-00, Rev. 4.2) - InvenSense.
The registers used here:
PWR_MGMT_1(0x6B),WHO_AM_I(0x75),ACCEL_XOUT_H(0x3B),GYRO_XOUT_H(0x43) andINT_PIN_CFG(0x37). The maker no longer hosts it at its old address, so search for the document number. A practical summary is on the Arduino Playground MPU-6050 page. - HMC5883L 3-Axis Digital Compass IC datasheet - Honeywell.
7-bit address
0x1E(8-bit0x3Cwrite and0x3Dread). Data registers0x03to0x08in X, Z, Y order with the high byte first. Default gain of 1,090 counts per gauss. Default mode is single measurement. - GY-271 module is not the HMC5883L (Arduino Forum) - a user finds out by scanning that a "GY-271" board answers at
0x0D, because it carries a QMC5883L. - Pololu VL53L0X library - open-source driver code. It shows the identification register (
0xC0, value0xEE) and the 16-bit range result read from register0x14 + 10 = 0x1E. Also see the Adafruit VL53L0X guide. - INA219 datasheet - Texas Instruments.
Default address
0x40(A0 and A1 grounded). Shunt voltage is 10 microvolts per step. Bus voltage is 4 millivolts per step in bits 15 to 3 (shift right by 3 first). The Adafruit INA219 guide covers the breakout board and its address jumpers. - SSD1306 datasheet - Solomon Systech. The OLED controller, including the I2C control byte (
0x00for commands,0x40for pixel data) and the page-based memory behind the 1,024-byte picture.
Sensor Fusion
- Sensor fusion (Wikipedia) - why and how measurements from several sensors are combined.
- Kalman filter (Wikipedia) - the more powerful relative of the complementary filter used in this appendix.
Related Pages in This Book
- Appendix A: The I2C Bus - the student appendix
- Instructor Notes - lesson script and misconceptions
- Chapter 8: Communication Protocols - the first look at I2C, SPI and UART
- Chapter 9: Temperature and Distance Sensors, Chapter 10: Motion and Light Sensors and Chapter 15: OLED Setup
- I2C Bus Scanner, I2C Collision-Avoidance Robot, I2C Two Sensors in a Maze and I2C Five-Device Sensor Fusion - the four MicroSims
- Maker Pi RP2040 Collision Avoidance Robot - the kit that uses the same back-up-and-turn plan