What is an IoT microcontroller

A microcontroller is a single-chip microcomputer designed for embedded applications. In the context of the Internet of Things (IoT), an embedded system with direct or gateway-mediated Internet connectivity forms the core of a physical thing. The physical thing is what we call an IoT device. Simply put, IoT devices can be industrial machines, computer hardware, consumer electronics, home appliances, vehicles, gadgets, appliances, sensors, actuators, and any piece of equipment with an embedded, Internet-connected computing system. An IoT implementation drives ubiquitous connectivity and information exchange between heterogeneous smart devices by extending the Internet Protocol (IP) communication beyond computer networking and mobile Internet services to billions of resource-constrained embedded systems. The spirit, when applied to the Internet of Things, is aimed to transform the way people interact with their environment through human-machine collaboration in cyber-physical systems such as smart cities, smart buildings, smart homes, smart factories, intelligent transportation systems, smart farms, and smart grids.

The brain of an IoT device

Microcontrollers are the brains of billions of IoT devices which provide sensing, actuation, control, and monitoring activities to implement different types of data-driven applications and services. Data from the interconnected devices is collected, shared, and synthesized into actionable insights which open up further possibilities to drive innovation and improve automation. The IoT architecture is implemented using layered stack with the perception layer at the bottom, the network layer and processing layer in the middle, the application layer on the top. The perception layer is where IoT devices reside and hence called the physical layer. The function of the perception layer is to interact with the physical environment through sensing and actuation. The network layer connects the things together and enables data exchanges throughout the network. The processing layer is more commonly known as the middleware layer. It ingests, stores, analyzes and processes data to mediate between the physical and application layers. The application layer provides the interface for the development and delivery of various practical IoT solutions and application-specific services. The application layer is where the user interacts with IoT applications and where the power of the IoT comes into play.

The IoT architecture

IoT devices work at the physical layer to capture information directly from the environment and interact with upper layers to run IoT applications which are built and deployed by an IoT platform. An IoT platform, which typically operates on a cloud infrastructure, acts as a software bridge between the things and the applications to support interoperability and abstraction. It enables access to the hardware features of the microcontrollers and abstracts the underlying resources from the embedded systems through a set of services that are used by IoT applications. The software system integrates smart devices into the IoT ecosystem by providing device connectivity, device management and remote data collection. It is the IoT platform that enables development and implementation of IoT features and functions into any device, brings the power of cloud computing, artificial intelligence and machine learning into the embedded systems, provides an application programming interface (API) to allow device integration with third party systems, and supervises the security status of the devices. Connected devices with growing sophistication are driving digital transformation. They need equally capable and forward-looking IoT platforms to turn data into value and bring the vast resources of the Internet closer to the physical world.

IoT devices must interact with the environment and IoT platform

An IoT device must often be able to interact in two directions: down to its sources of data such as sensors or other interoperable IoT devices, as well as up into the cloud backend that processes and transforms data to be used in IoT applications. It should have contextual machine intelligence to adapt with the changing environment based on the IoT insights. IoT devices usually need to support interoperable communication such that data contextualization can occur collectively to drive more informed and proactive decisions. IoT devices should be as self-managing as possible. The use of self-configuring, self-tuning, self-healing and self-monitoring devices makes a network very simple to implement, operate and scale in size. Collective intelligence originates in a cloud, but making decisions at the network edge, instead of in the cloud is critical to applications with a low latency requirement. Data processing, data storage and network connectivity therefore become essential capabilities required to transform a digital device into the entry point of the physical environment to the digital world. The device may also need to provide input/output (I/O) interfaces for integration with sensors and actuators. All the operations, interactions and communications performed by an IoT device are orchestrated by the microcontroller.

Embedded design

A microcontroller or a microcontroller unit (MCU) is a small, integrated circuit that incorporates everything needed to form a computing system. It typically consists of a central processing unit (CPU), on-board memory, interrupts, timer/counter, and I/O peripherals. The CPU performs arithmetic, logic data transfer, and I/O operations. It handles three types of information: data, addresses, and instructions. Memory on the microcontroller is used to store data, addresses, and instruction. An interrupt is a hardware or software mechanism for pausing execution of whatever a microcontroller is currently doing. Timers use the frequency of the internal clock to measure time intervals, generate delays, and provide the necessary clock signal. They can also be used to count the external events. An on-board pulse width modulation (PWM) device delivers varying amounts of power to execute various applications such as motor control, LED dimming and audio generation by varying the duty cycle of the pulses.

There are two types of memory: random-access memory (RAM), read-only memory (ROM). RAM is used as the data memory in an embedded system to store information for a program that is being executed. It has both read and write capabilities and also supports number crunching. RAM is volatile and provides only temporary storage. It may lose data when the power supply is interrupted. ROM is non-volatile, permanent memory. It is used as the program memory to store the application program (firmware) for which an embedded system is designed. The application program can be stored only once in microcontrollers with programmable read only memory (PROM) and cannot be reprogrammed or modified. Electrically erasable programmable read only memory (EEPROM) can be erased and reused. Flash memory is the updated version of EEPROM that has become the norm in embedded applications because of its significant speed and efficiency advantages over non-flash EEPROM.

Input/output (I/O) ports

Typical microcontrollers have parallel and serial I/O ports through which the peripheral devices can be interfaced with the CPU.

A parallel interface has multiple wires (or pins) that run parallel to each other to simultaneously send bits. Parallel data transmission is much faster, but it is challenging for parallel interfaces to maintain synchrony across the multiple wires over long physical length of the interconnection. The requirement for bulkier cables and more I/O pins presents another issue for embedded applications where the number of pins on the physically small integrated circuit is limited.

Despite slower data transmission, serial ports take center stage for their abilities to provide higher bandwidth, longer distance communication and more efficient use of pins and wires. Dozens of serial protocols have been introduced. They include UART (universal asynchronous receiver-transmitter) in which data is transferred without support from an external clock signal, and SPI (serial peripheral interface) and I2C (inter-integrated circuit) which are synchronous serial protocols.

There are digital or analog I/O ports. Digital I/O ports communicate with external devices using digital signals. Analog I/O ports need to integrate either an analog to digital (A/D) converter or digital to analog (D/A) converter in order to establish communication between the microcontroller and peripheral devices. Many microcontrollers have a number of digital or analog General Purpose Input/Output (GPIO) pins that accommodate sensors and actuators. The memory block and the I/O ports communicate with the CPU through electrical signal conductors known as buses. A bus is a communication interface shared by multiple devices. There are three types of buses: the data bus for carrying information, the address bus for identifying the location of the memory, and the control bus for determining the operation.

Microprocessor vs. microcontroller

Although there are embedded systems operated by microprocessors, microcontrollers have a ubiquitous presence in modern embedded systems. A microprocessor is a single-IC implementation of a CPU and does not have memory, peripherals and I/O ports embedded, therefore it cannot function as a stand-alone system. On the other hand, a microcontroller is a self-contained system that incorporates all functional blocks of a computer. An IoT device is often a system-on-chip (SoC) that integrates a microcontroller and a network transceiver.

Microprocessors are used in personal computers, servers or other general purpose computing systems. They have relatively high computational capacity in order to meet the challenge of executing complex tasks like software development, image processing and documents making. Microcontrollers are designed for running software to support specific tasks. The Internet of Things has specific requirements on devices’ power consumption, data rate, memory, communication range, physical volume, and cost. A fully layered network implementation for Internet connectivity introduces complexity for IoT device design. Most IoT devices are battery-powered wireless embedded systems. They don’t contain the network stack required for direct IP communication. A simplified stack is used to minimize the requirement for processing power and improve battery autonomy. A gateway is used for interfacing between local networks and the cloud backend.

While microprocessors have a clock frequency usually in the order of gigahertz, microcontrollers run at about 8 MHz to 50 MHz. A power saving mode can be found in many wireless IoT devices which awaken only to transmit or receive data. Battery autonomy is not a significant consideration in microprocessor-based systems.

Microprocessors are made with billions of miniature transistors configured in microchips, whereas microcontrollers are complementary metal-oxide semiconductor (CMOS) devices which are much less complicated in architecture and thus far cheaper than microprocessors.

Types of microcontrollers

Microcontrollers can be classified by different variants: bits, instruction set, architecture, and accessibility of program memory and data memory. The more bits (binary digits) the arithmetic logic unit (ALU) within the CPU can handle at a time, the faster the CPU can compute. Hence, we have 8-bit, 16-bit, 32-bit, and 64-bit microcontrollers which can handle 8, 16, 32, and 64 bits at a time, respectively. 32-bit cores, which have a much higher computational performance and access to a larger memory space than the 8- and 16-bit counterparts while maintaining a decent energy efficiency, are all the rage these days in low-power IoT applications. 64-bit microcontrollers are used in high-end systems.

A microcontroller may be an RISC (Reduced Instruction Set Computer) or CISC (Complex Instruction Set Computer). As instruction set architectures (ISA), ARM and x86 are ubiquitous names in the processor industry. The memory architecture of microcontrollers may be based what is known as Harvard architecture or Princeton architecture. The former separates storage and signal pathways for instructions and data. It contrasts with the latter, also known as von Neumann architecture, in which the same memory is shared between both instructions and data.