← Back to programme Day 3 · Session 2 · Theory

Embedded Systems — The Backbone of IoT

View presentation slides ↗

Computers, processors & microcontrollers

  • Operating system: a manager of resources provided by the underlying architecture.
  • A computer: combines a central processing unit (CPU), random access memory (RAM), read-only memory (ROM), and input/output (I/O) ports.
  • A processor: often called the Central Processing Unit (CPU) — the primary component of a computer that performs most of the data processing and calculations. It acts as the "brain" of the system, responsible for fetching, decoding, and executing instructions.
  • A microcontroller: contains all the components of a computer (processor, memory, I/O) on a single chip. Microcontrollers are designed for embedded applications.
Block diagram of a computer showing the processor, RAM, ROM, input/output ports, external circuits, and physical devices connected by address, data, and control buses
Figure. A computer's building blocks — processor, RAM, ROM, and I/O ports — connected by address, data, and control buses.
Block diagram of a processor's internals showing registers, the control unit, the ALU, and the bus interface unit connected to code, system, private peripheral, and advanced high-performance buses
Figure. Inside the processor — registers, control unit, ALU, and bus interface unit.

Introduction to embedded systems

  • Embed: to incorporate or integrate something into a larger system.
  • Embedded system: a computational system based on the integration of both software and hardware, built to perform specific tasks.

There are two classifications of embedded systems:

  1. Transformative: collects data from inputs, makes decisions, and affects its environment by driving actuators.
  2. Reactive: collects data in a continuous fashion.

Embedded systems make use of specialized ICs called microcontrollers, which bundle features to simplify monitoring and control (an MCU = CPU + peripherals + support circuits + memory).

Diagram comparing a transformative embedded system, which takes environment inputs through sensors and drives actuators, against a reactive system, which continuously converts inputs to outputs
Figure. Transformative systems sense, decide, and act on their environment; reactive systems continuously convert inputs to outputs.

Example: a microcontroller inside a washing machine controls wash cycles; in a fridge, it monitors temperature. At DSAIL, water level monitoring sensors track water level changes along rivers.

Operations of an embedded system

  • Closed loop control: controlling an output variable based on one or more input measurements — for example, adjusting temperature or changing direction.
  • Sequencing: controlling an output through a sequence of steps.
  • Signal conditioning and processing: averaging together sensor readings, conditioning signals, filtering out noise.
  • Communication and processing: interacting with other systems and subsystems.
DSAIL field deployment

Camera trap

A DSAIL camera trap mounted on a post in a grassy field
DSAIL field deployment

Water level sensor

A solar-powered water level sensor node floating on a river
DSAIL field deployment

Acoustics sensor

A solar-powered acoustics sensor mounted outside a university building

Attributes of an embedded system

  • Interfacing with inputs and outputs: embedded computers need to sense the environment and issue control commands in response (analog, digital, ADC, DAC).
  • Specialized peripheral hardware circuits: signals often must be processed before conversion to the digital domain for the CPU — amplification, scaling down signals, filtering noise.
  • Concurrency: embedded controllers must manage multiple activities concurrently, often with precise control of timing.
  • Responsiveness: providing enough responsiveness by sharing the CPU's time across many activities.
    • The processor must be fast enough to complete critical processing before its deadline; developers should optimize code to do necessary work with very few instructions.
    • The processor needs to stay focused on critical processing.
    • Processing and communication should be split.
  • Reliability and fault handling: embedded systems are expected to work correctly and reliably — unlike normal computers, the user cannot simply reboot them. The impact of failure should be minimized.
  • Diagnostics: it should be easy to find and repair a faulty component quickly. Hard-coded diagnostics support is common in printers, scanners, and fridges.
  • Constraints: embedded systems must not be too large, expensive, or heavy.
A printer's diagnostic display showing a 'Toner Low' warning with a prompt to prepare a new toner cartridge
Figure. Hard-coded diagnostics, such as this printer's toner warning, let a fault be found and resolved quickly.

Embedded system essential: digital data transmission

Digital data transmission is the transfer of data between two or more digital devices, in the form of bits, over channels such as fiber optic, conductor, or wireless links. It can be either parallel or serial.

Parallel data transmission
  • Multiple data bits are sent at the same time over multiple channels.
  • Data reaches the receiver in one go.
  • More channels.
  • Very expensive.
Serial data transmission
  • Data bits are sent through a single channel, one after the other.
  • One communication channel.
  • Less expensive.
  • Uses shift registers — a digital conveyor belt with memory cells called flip-flops.
  • A clock signal controls everything.
  • With every clock pulse, the binary value inside the register moves one step, bit after bit, until the whole digital word has moved through.
  • Can include a start bit and a stop bit.
Diagram of a transmitting device and receiving device made of shift registers, showing D2, D1, D0 flip-flops clocked in series to send serial data one bit at a time
Figure. A transmitting shift register flattens a parallel byte into a serial bitstream; a receiving shift register rebuilds it on the other end.

Serial communication

Serial communication falls into two main categories:

  • Synchronous — a clock signal is needed.
  • Asynchronous — a clock signal is not needed.

Under synchronous communication, one common method is:

SPI (Serial Peripheral Interface)

  • Involves two ICs / shift registers working together: the controller/master and the target/slave.
  • Movement of bits is bidirectional — half duplex.
  • The controller is more powerful, since it controls the clock and the chip select.
  • Common pins: MOSI/COTI, MISO/CITO, SCK, CS.
  • Demerits: no data acknowledgement once sent, no per-target addressing (a chip-select line is needed for every target), and no error-checking mechanism.
Waveform diagram of SPI signals A, B, and C showing the clock and data lines toggling over time
Figure. SPI signal timing across the clock and data lines.
Diagram of an MCU connected to three SPI peripherals, each with its own chip-select line alongside shared SCK, COTI, and CITO lines
Figure. An MCU driving multiple SPI peripherals, each with its own chip-select (CS) line.
Quiz

In an SPI network, three signals are observed on the pins of a certain target device. It is known that in this mode, the data is clocked in on the rising edge of the clock. Note that the MSB (Most Significant Bit) is transmitted first in any data word in SPI. Identify the correct answer.

I2C — Inter-Integrated Circuit

A protocol widely used in serial communication, introduced by Philips Semiconductors in 1982.

  • Two-wire communication (SDA — Serial Data, SCL — Serial Clock).
  • Half duplex — can transmit in two directions, but not simultaneously.
  • Addressing: each target is identified with a unique 7-bit or 10-bit address.
  • Error handling includes NACK/ACK bits to confirm successful data transmission.

Steps

  1. Start: the master initiates communication by pulling the SDA line low while SCL remains high.
  2. Addressing: the master sends the 7-bit address of the target slave, followed by a read/write bit.
  3. Acknowledgement: the addressed slave responds by pulling SDA low during the next clock pulse.
  4. Data transfer: data is sent in 8-bit frames, each followed by an ACK/NACK bit.
  5. Stop condition: the master ends communication by releasing SDA to high while SCL is high.
I2C timing diagram showing SDA and SCL signals for a start condition, a 7-bit address, a read/write bit, an acknowledgement, an 8-bit data frame, and a stop condition
Figure. An I2C transaction: start condition, address frame, acknowledgement, data frame, and stop condition on the SDA/SCL lines.

UART (Universal Asynchronous Receiver/Transmitter)

Under asynchronous communication, the common method is UART:

  • No clock.
  • Data transmission rate — the baud rate — is measured in bits per second.
  • The baud rate is prearranged between the transmitter and the receiver.
  • Common connections: TX and RX.
  • Some UARTs can be configured as synchronous: USART (Universal Synchronous/Asynchronous Receiver/Transmitter).
  • Framing bits are required at the beginning and end of the data.
  • Data transmission usually follows one of two patterns: 8-bit transmission, or 8-bit transmission plus a parity bit.
  • Parity pattern: an error-checking mechanism that helps ensure data is correctly received.
UART waveform diagram starting in an idle state, with markers labelled A through E indicating the start bit, data bits, and stop bit
Figure. A UART frame — the line idles high, then a start bit, data bits, and a stop bit carry one word of data.
Diagram of Device 1 and Device 2 connected via crossed TX and RX lines, each showing a waveform on its transmit line
Figure. Two UART devices connected TX-to-RX and RX-to-TX.
Quiz

The data pattern of a certain asynchronous communication link is represented in the diagram above, starting in an idle state. Identify what each of the labelled points (A through E) represents.

Analog communication (AnalogIn)

With the ADC, a continuous analog wave is sampled and converted to a digital number. Below is the master pipeline for an analog sensor:

Analog sensor data pipeline
1. Physical event (e.g. heat) drives an analog sensor, producing a continuous analog signal.
2. The ADC peripheral samples the wave and turns it into a binary number — a parallel digital byte (e.g. 10110011).
3. A TX shift register flattens the byte into a single-file line of bits — a serial channel, one wire, bit by bit.
4. An RX shift register rebuilds the single-file bits back into a parallel digital byte (10110011).
5. The byte lands in CPU memory, via an interrupt-driven or Direct Memory Access approach.

Embedded systems — Internet of Things connection

  • Embedded systems are the backbone of IoT.
  • An IoT device is an embedded system connected to the internet.
Diagram of the IoT key building blocks: smart things connected through gateways and networks, to middleware, to applications
Figure. The IoT stack: smart things → gateways/networks → middleware → applications.
Handwritten notes sketching an IoT data flow: sensor nodes and actuators, through a connectivity module (LoRa, NB-IoT, LoRaWAN, GSM), to a receiver/gateway embedded system, a network service over the internet, and an application server for storage and dashboards
Figure. The end-to-end flow, sketched out: sensor nodes and actuators feed a connectivity module (LoRa / NB-IoT / LoRaWAN / GSM), which reaches a receiver/gateway (itself an embedded system), then a network service over the internet, and finally an application server for storage and dashboards.

Connectivity: wireless sensor networks

Low-power wireless protocols are designed to transmit data using very little energy, allowing IoT devices to last a long time on constrained power sources like batteries. The two strengths of these protocols are low power and self configuration.

Categories

  • Short range protocols: BLE (Bluetooth Low Energy).
  • Medium range protocols: Zigbee.
  • Long range protocols: unlicensed — LoRaWAN, Sigfox; licensed — NB-IoT, LTE.
Focus

Let's focus on LoRaWAN.

LoRaWAN

  • LoRa: a physical radio communication technique based on CSS technology, developed by Semtech, a producer of analog and mixed-signal semiconductors. LoRa is used for sending small amounts of data over long distances — the record stands at 960 miles — making it well suited for IoT.
  • LoRaWAN: a Media Access Control (MAC) layer protocol built on top of LoRa modulation. It's the software layer that defines how to use the LoRa hardware.
  • LoRaWAN is developed and maintained by the LoRa Alliance, based in Fremont, California — a non-profit technology ecosystem of which Semtech is a founding member.
System diagram of a water level sensor node built from an RFM95 transceiver, Arduino Nano, HC-SR04 sensor, TXS0108E level shifter, battery, and power regulation modules, uplinking through a LoRaWAN gateway and The Things Network via MQTT to a Kenet InfluxDB machine, feeding anomaly detection and a dashboard
Figure. A DSAIL water level sensor node — RFM95 transceiver, Arduino Nano, HC-SR04, and power regulation — uplinking via a LoRaWAN gateway and The Things Network to a Kenet InfluxDB instance, feeding anomaly detection and a dashboard.

Setting up a LoRaWAN network — what's needed

  • A LoRaWAN gateway (e.g. Kerlink, The Things Industries, MultiTech).
  • Internet access for the gateway (LTE, ethernet, or Wi-Fi).
  • Power supply for the gateway.
  • A sensor node.
  • A network server (e.g. Actility, The Things Network).
  • A cloud service to store the data and run visualization tools.
Hardware

LoRaWAN gateway

An outdoor-mounted LoRaWAN gateway unit with weatherproof casing and antenna port
Hardware

Wall-mounted gateway & antenna

A wall-mounted LoRaWAN gateway with an external antenna on a bracket

Practical