When it comes to the Internet of Things (IoT) and smart objects, computational ability is often driven by devices called microcontrollers, or MCUs. Essentially scaled-down computers, MCUs operate smart devices by providing processing power, memory, and input/output peripherals.

In this article, we’re going into detail on the essentials of microcontrollers for IoT.

 

What are microcontrollers?

Most IoT devices have to be small and work based on relatively low energy consumption. This is particularly true for resource-constrained devices, which might operate far from a central system and use low-powered batteries to function.

Such IoT devices need something less heavy duty than the type of processor found in a typical personal computer. For this, they use microcontrollers.

When trying to understand the place microcontrollers occupy in IoT, we’re going to look at an IoT technology stack for an embedded device and how the MCU interacts within it.

For example, a simplified IoT stack for a smart camera device might look something like this:

  1. Communication protocol layer
  2. Hardware abstraction layer (HAL)
  3. RTOS/OS layer

The MCU operates at the hardware abstraction layer, acting as a bridge to allow the other two layers to interact, and runs the chosen RTOS/OS that operates the device.

 

Set up a simulated IoT Video surveillance device on your PC in minutes.

Our full-stack demos give you access to the Nabto Platform so you can try it now. We specialize in secure, low-latency, P2P connectivity. Get the demo app to try it.

Microcontroller vs. microprocessor

One common question regarding microcontrollers that’s often heard concerns the difference between MCUs and microprocessors.

A microprocessor is a single integrated chip that contains a device’s CPU. However, it doesn’t contain any RAM or ROM memory, or any other peripherals a device may have. The chip instead relies on inputs/outputs (I/Os) to connect to memory and peripherals.

On the other hand, a microcontroller has the CPU, RAM and ROM, as well as peripherals all embedded onto a single chip, effectively making it a computer itself.

Now, this heavily embedded chip, of course, has lower performance capabilities than a microprocessor-powered computer, but when it comes to typical IoT devices, such as smart industrial machines, microcontrollers are a much better choice. They can provide sufficient computing power while keeping costs, complexity, and energy usage low.

Microcontroller features

With hundreds of MCUs on the market, it’s important to understand their common features before deciding on the best MCU for an IoT project.

Bits

For this primary distinction between MCUs, there are 5 different options currently available:

4-8 bit

These are used in remote controls, and other constrained and inexpensive applications. Generally, they are not fit for use in IoT applications, since they lack the computing and memory needed for handling internet.

8 bit

Mostly used in cost-constrained but more elaborate applications than the 4-8 bit. With the correct setup, these can be used in IoT applications, sometimes running an RTOS, but mostly with a simple control loop. The well-known Arduino project is an example of an 8-bit design. Even though 8-bit systems can handle Internet, they normally lack the compute power and memory requirements to do it properly with encryption and strong authentication protocols.

16 bit

While these are of course an option, the 16-bit architecture is not incredibly common in IoT. Implementations will typically switch between an 8-bit or 32-bit MCU.

32 bit*

This is the normal entry point for IoT applications, unless the application can fit 8-bit architecture and has cost constraints. The price difference between 8 and 32-bit architectures is small enough, however, that developers should think twice before choosing 8 bit.

Whether the MCUs run an RTOS or OS mostly depends on the compute power of the MCU, and/or the presence of a memory management unit (MMU).

Do note, in these systems, clock frequency is an important design factor as well. Clocks above 100MHz (especially GHz designs) usually require extra thought on PCB design, since the PCB traces can begin to interfere with others. Raspberry Pi is a well known 32-bit design.

64 bit

These are reserved for high-end systems, usually Linux or another OS. You typically need a specific (compute intensity) reason to jump from a 32-bit to a 64-bit system.

Architecture

The majority of MCUs use one of the following architectures: ARM, MIPS, or X86, though now there’s the new RISC-V architecture we’ll also consider.

We’re going to take a look at these different specifications and their primary features. As will be seen, ARM, MIPS, and RISC-V are similar in many ways, while X86 possesses significant differences from the others.

 

  1. Different instruction set architectures (ISAs). The ISA of microcontroller architecture dictates the format of instructions managed by the CPU. ARM, MIPS, and RISC-V all have reduced instruction set computer (RISC) ISAs, while X86 uses complex instruction set computers (CISC), which supports more complex and flexible instructions. RISC requires a set length for instructions, specifically 16 (ARM) and 32 (MIPS) registers.
  2. Different processing power. Overall, X86 has more processing power and high performance. In contrast, ARM, RISC-V, and MIPS don’t require as much processing power due to simpler, set-length instructions dictated by RISC architecture, lending themselves to applications that don’t require high performance.
  3. Different energy consumption. X86 uses more energy to function and support higher processing power. MIPS uses less power and ARM has even greater efficiency.
  4. Proprietary vs. open source. RISC-V is open source, while ARM, MIPS, and X86 are all proprietary. While using RISC-V for a microcontroller design means you won’t have to pay royalties, system support lacks and documentation is limited.

Different processors in each of these categories will also have different RAM, number of GPIO pins, and connectivity options.

RAM

This varies greatly, from around 16B at the lowest end on the 8-bit MCUs, to about 4.5MB on 32 and 64-bit MCUs. To many, the more RAM the better, but this will increase costs substantially.

GPIO

General-purpose input/output are the pins that allow connectivity of various hardware, such as sensors to the CPU. Like RAM, the number of GPIOs range substantially to accommodate all types of device stacks.

Connectivity

Different CPUs come with different connectivity options, including Wi-Fi protocols, Bluetooth, and wired ethernet ports.

RTOS/OS for microcontrollers

There are a few operating system options for MCUs. Here’s what you’ll find on the market:

RTOS

Short for “real-time operating system,” this software component can execute only one program at a time, but rapidly switches between programming tasks in order to accomplish multiple tasks simultaneously.

RTOS delivers what’s known as deterministic, hard, real-time responses to external events. In practice, this means it can provide highly responsive processing for limited predetermined tasks far quicker than a traditional OS, which can be an advantage when it comes to an IoT device.

You can read more here on how to choose the best RTOS for IoT.

OS

This is a “traditional” operating system, such as Linux. Unlike its “real time” counterpart, an OS provides non-deterministic, soft, real-time responses, meaning it’s more effective at processing large quantities of different tasks than an RTOS, but requires a lot more processing power.

Because of this, OS software is usually only found on 32 and 64-bit MCUs that have MMU units. You can read more on the advantages and disadvantages of OS versus RTOS here.

Bare metal

Some CPUs have no operating system software at all. Instead, the firmware is written directly onto the hardware—the result is bare metal programming. This is very common with older generation embedded devices and MCUs for IoT.

However, as MCU processing power has advanced, and come down in cost, fewer devices are operated bare metal. Having said that, it is still used when an MCU has low memory, or when direct control over every piece of hardware is needed to meet very strict timing requirements.

Choosing the best microcontroller for IoT

As mentioned, many microcontrollers are used in IoT projects. A substantial list of common commercial MCUs will be provided in this blog’s follow up, but for now, we’re going to explain how to choose the best microcontroller for IoT.

Memory

The amount of memory will, of course, have a fundamental impact on the overall performance of the device. Therefore, memory requirements for a device’s programming tasks must be carefully calculated—both RAM and ROM.

Also, ensure the decision is future-proofed by arranging for enough spare capacity to handle the demands placed on it by future updates.

Power

Power requirements is another major consideration when it comes to choosing the best MCU.

For instance, an IoT smart medical device, like a hearing aid, can run on a low-power battery. On the other hand, heavy smart industrial equipment will consume lots of electricity, but you’ll want the device to be as energy efficient as possible.

Internet and other communication protocols

How will your IoT device connect to the application? What type of data will the device be pushing, and where? Does it need to interact with other devices locally?

For example, a residential smart alarm system may need Wi-Fi protocols, while an office IoT HVAC system may require wired ethernet. For local device communication, Bluetooth or Thread network could be needed, and remote devices outside Wi-Fi range require 4G data connectivity.

Connection ports

To work out how many GPIOs are needed on a microcontroller, first define the data inputs the device requires. Also, bear in mind, there are both digital ports and analog ports on a CPU, which process different types of data inputs and outputs.

Architecture

Remember, most applications run off ARM, MIPS, or X86 architecture. Therefore, make sure your choice can support the complexity of your device and system, including the I/Os and data processing and how much power that requires.

Dev support and community

If your team or organization has no prior experience working with MCUs, dev support offered by the manufacturer and the developer community is crucial.

Check for comprehensive documentation from the manufacturer, and sites like StackOverflow or Reddit for community support. You can also find plenty of useful tutorials on our blog.

Cost

Always keep one eye on the future when considering microcontroller costs. There is no point building a prototype with a board that can become prohibitively expensive to scale and take to market. Also, be aware, some MCUs come with licensing fees for individual device drivers.

Security

Security is a significant consideration for all IoT projects and needs to be engineered across the stack. Standard security features on commercial boards include cryptographic bootloaders and hardware accelerators, shield layers, and memory protection units.

Final word on microcontrollers for IoT

Choosing the best option for an MCU can be complex and frustrating. Hopefully you can now go into the process a bit more informed and a lot more certain about exactly what to look for in your IoT microcontrollers.

We’re going to follow this up with a supplemental post, examining the top microcontroller options as well as their specifications, so then, you’ll have everything you need to get started.

Want to learn more about P2P IoT?

Please visit the:
P2P IoT Academy

Deep dive Into our documentation?

Please visit the:
Nabto Platform Overview

Try our demo for Video Surveillance?

Please visit the:
Nabto Edge
Video Cam Demo

Looking for other Great posts?

###