Microcontrollers (Arduino)

You’re probably reading this on a computer that consists of a central processor, some memory chips, some file storage (magnetic drive or more memory chips), a keyboard or touch-panel, and an LCD screen. These items are the basics of all computing: processing, volatile (temporary) storage, nonvolatile storage, input devices and output devices.

Mechatronic and IoT devices are just the same, except everything is much smaller; they are typically powered by a microcontroller which is a term for devices that combine all the traditional parts of a computer onto a single chip (or an integrated multi-chip module).

Just how small can vary. The range of scale and power available for IoT devices encompasses:

  1. 8-bit microcontroller devices (such as the well known Arduino family), size around 5cm, costing under $5
  2. 32-bit microcontroller devices, size around 5-10cm, costing under $10
  3. Small form-factor PCs (such as Raspberry Pi, and various similar devices), size under 10cm, costing under $100

I am going to talk about these kinds of devices in the following chapters. At the low-end, the Arduino and similar are excellent but are not powerful enough to connect to the internet on their own. At the high end, there’s a place for the more powerful and expensive devices in some projects, but often they are unnecessarily complex.

In the *microcontroller( realm you typically have the following resources:

  • For processing you have a processor that runs between 1 and 100 million instructions per second (MIPS).
  • For memory, you typically have a frustratingly small amount of RAM, from 1kB to a few hundred kB.
  • For file storage, you have somewhere from 8k to a few megabytes of FLASH memory. *For input and output you have from two to twenty digital “pins”, and some communication interfaces such as Asynchronous serial, Inter-IC communications Bus (I2C), Bluetooth, or WiFi. Under the control of your programs, the Input/Output (IO) pins can be used singly or in groups to control buttons, lights, sensors and screens.

Microcontrollers

Above: Classes of embedded computers: L-R DigiSpark, Arduino Nano, NodeMCU, Raspberry Pi

A modern 32-bit microcontroller is about as powerful as a home computer from the 1990s, but shrunk to the size of a postage stamp.

These devices can be programmed in assembly language or traditional “middle level” languages such as C and C++. Some of the more recent devices are able to run higher-level languages such as Python, Javascript or Lua.

To develop program code for a microcontroller you write your programs on a normal sized computer and then “upload” the program to the microcontroller. This can be done with a wired connection or sometimes over wireless links.