CHAPTER8

Wire

This chapter discusses the following functions:

  • begin()
  • beginTransmission()
  • write()
  • endTransmission()
  • read()
  • available()
  • requestFrom()
  • onReceive()
  • onRequest()

The hardware needed to use the examples in this chapter includes:

  • Arduino Uno x 2
  • Arduino Due
  • Silicon Labs Sensor EXP board

You can find the code downloads for this chapter at http://www.wiley.com/go/arduinosketches on the Download Code tab. The code is in the Chapter 8 folder and individually named according to the code filenames noted throughout this chapter.

Introducing Wire

Connection wires I2C, short for Inter-IC bus, is a serial bus designed to enable access to numerous devices. The Arduino's hardware serial bus can connect only to one device at a time, and SPI (see Chapter 7) can talk to three devices. In 1982, Philips created the I2C standard, capable of addressing hundreds of devices, using only two wires. It was first used to connect peripherals together in a television set, but since then, I2C has been used in cars, computer systems, and hobbyist electronics, to name a few. It is an easy and inexpensive way to interconnect dozens (if not hundreds) of devices on a same network.

Originally, only a few I2C devices existed, but today there are hundreds of devices. Temperature sensors, pressure sensors, accelerometers, displays, and even EEPROM memory can all be accessed by I2C, using simple reads and writes. An EEPOM device controlled by I2C is illustrated in Figure 8-1.

Figure 8-1: I2C EEPROM integrated ...

Get Arduino Sketches: Tools and Techniques for Programming Wizardry now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.