The I²C Bus
This chapter covered the following concepts:
- I²C uses two data lines to enable digital communication between the Arduino and multiple slave devices (so long as they have different addresses).
- The Arduino Wire library can be used to facilitate communicate with I²C devices connected to pins A4 and A5.
- I²C communication can be employed alongside shift registers and serial communication to create more complex systems.
- You can create fonts in Processing to generate dynamically-updating on-screen displays.
- Processing can be used to display parsed serial data obtained from I²C devices connected to the Arduino.
- Arduino Uno
- USB A-B Cable
- Red LED
- Yellow LEDs (x3)
- Green LEDs (x4)
- 220Ω Resistors (x8)
- 4.7kΩ Resistors (x2)
- SN74HC595N Shift Register
- TC74A0-5.0VAT I²C Temperature Sensor
- Jumper Wires
- Arduino Wire Library Reference
- Temperature Conversion Formulas
- 74HC595 Shift Register Datasheet (PDF)
- TC74 Datasheet (PDF)
- In figure 8-8, the wiring to the right-most pin of the TC74 is incorrect in the book. It needs to be connected to 5V. The correct version is shown in the following colored wiring diagram.
Color Wiring Diagrams
Follow along with this video for a visual tutorial about the I²C Bus:
Watch a demo of the temperature monitor created in the chapter:
All code is licensed via the GNU GPL v3. Code is maintained and updated on GitHub. The download zip linked above always contains the most recent version of the code examples that have been pushed to the GitHub Code Repository.
Taking it Further
Use I²C devices to enable all kinds of exciting new projects:
- Add an I²C DAC to your Arduino to enable true analog output.
- Add an I²C gyroscope or accelerometer to detect tilting and movement.
- Use an ²C barometric pressure sensor paired with the temperature and light sensors that you’ve already used to make a great weather station.
References & Credits
- Figure 8-2: TC74 ID Table Credit: © 2013 Microchip Technology Inc. (source, PDF)
- Figure 8-3: AD7414 ID Table Credit: Analog Devices, Inc., www.analog.com (source, PDF)
- Figure 8-5: TC74 Write Format Table Credit: © 2013 Microchip Technology Inc. (source, PDF)
- Figure 8-6: TC74 Register Table Credit: © 2013 Microchip Technology Inc. (source, PDF)