5.9. Buses#

In modern electronics, most sensors don’t just output a raw analog voltage or a simple digital on/off signal. Instead, they communicate over a bus: a shared communication pathway that allows multiple devices (sensors, controllers, actuators) to exchange data with just a few wires.

../../_images/MutipleI2C_Devices-550x347.png

Buses use a digital communication protocol to exchange data between the microcontroller and sensors. This means that each sensor can send multiple readings e.g. a combined environmental sensor can monitor temperature, humidity, and pressure - all of which can be transmitted over the bus.

Aside from the advantage of digital communication over analog, buses also give:

  • Reduced and simpler wiring: Instead of one dedicated pin per sensor, many sensors can share the same lines. These lines can be daisy chained between sensors.

  • Scalability: Adding more devices is easy without redesigning the whole circuit.

  • Reliability: Many bus protocols include error detection and retry mechanisms.

5.9.1. Examples#

1-Wire#

As its name suggests, this protocol only needs a single data line (plus ground) to allow communication between a microcontroller and a sensor. Because of this, 1-Wire devices are extremely easy to wire up and can even run over fairly long cables. The trade-off is that the data rate is quite low, making the system suitable mainly for simple sensors such as the DS18B20 digital thermometer. It is not designed for high-speed data transfer, but its simplicity and minimal wiring make it attractive for basic sensing applications.

I2C#

I²C uses just two shared lines: one for data (SDA) and one for the clock (SCL). Multiple devices can be connected to the same bus, and each has a unique address that allows the microcontroller to identify it. This makes I²C very efficient for connecting many sensors, since the number of pins on the microcontroller does not increase as more devices are added. The downside is that I²C is relatively slow compared to other buses, and the communication distance is limited, which is why it is mostly used on printed circuit boards or in small embedded systems. Still, it is one of the most common interfaces found on modern sensor modules.

SPI#

SPI typically employs four lines: a clock signal, one line for data going into the sensor (MOSI), one line for data coming back (MISO), and a chip-select line to choose which device is active. Unlike I²C, SPI is not limited by addressing, but each device needs its own chip-select pin, which increases wiring if many sensors are connected. The major advantage of SPI is its high speed and ability to stream data continuously, making it ideal for applications like high-resolution displays, memory chips, or fast sensors such as accelerometers and ADCs.

CAN bus#

CAN bus (Controller Area Network) is a protocol designed for robust communication in demanding environments, particularly vehicles and industrial systems. It uses two twisted wires (CAN High and CAN Low) to allow many devices to communicate on the same network. CAN bus is unique in that it does not rely on a central controller: any device can transmit when the bus is free, and built-in arbitration ensures that higher-priority messages get through first. The protocol includes strong error detection, making it extremely reliable even in electrically noisy conditions. Because of this, CAN bus has become the standard for automotive electronics, linking everything from engine sensors to braking systems and infotainment units.