Arduino Basics
Arduino Basics
• I2C The two connections for the I2C bus are called
SCL and SDA.
• These are available on a standard Arduino board using
analog pin 5 for SCL, which provides a clock signal,
and analog pin 4 for SDL, which is for transfer of data
(on the Mega, use digital pin 20 for SDA and pin 21 for
SCL).
• One device on the I2C bus is considered the master
device. Its job is to coordinate the transfer of
information between the other devices (slaves) that are
attached.
• There must be only one master, and in most cases the
Arduino is the master, controlling the other chips
attached to it. Figure 13-1 depicts an I2C master with
multiple I2C slaves.
An I2C master with one or more I2C slaves
SPI
• SPI Recent Arduino releases (from release
0019) include a library that allows
communication with SPI devices. SPI has
separate input (labelled “MOSI”) and output
(labelled “MISO”) lines and a clock line. These
three lines are connected to the respective
lines on one or more slaves. Slaves are
identified by signalling with the Slave Select
(SS) line. Figure shows the SPI connections.
BME280 I2C or SPI Temperature
Humidity Pressure Sensor
Responding to Changes in Voltage