IO1: How embedded and IoT systems are different
Microcontrollers are not small laptops
🎯You'll be able to
Explain how a microcontroller differs from a computer in memory, storage, operating system and power, and what that means for code.
🏠The everyday picture
A pocket calculator and a laptop can both add numbers. The calculator runs for a year on a tiny battery, starts instantly and does one job. The laptop can do anything, but needs charging every day.
📘What it really is
-
Memory: a laptop has gigabytes of RAM; a typical microcontroller has kilobytes to a few hundred kilobytes, sometimes a few megabytes with extra chips. Every buffer and library counts.
-
Storage: firmware and data sit in flash memory, often a few megabytes. Flash wears out after many writes, so you write less often than you would to a laptop's disk.
-
No full operating system: many devices run one program in a loop, or a small real-time operating system (RTOS) such as FreeRTOS. There's no desktop, no user accounts and often no file system unless you add one.
-
Speed: tens to hundreds of megahertz, enough for sensing and messaging, not for heavy processing.
-
Power modes: the chip can sleep, keeping only a clock and a little memory alive, using thousands of times less current than when awake.
-
Languages: C and C++ are most common. MicroPython runs Python on larger microcontrollers, which this path uses for its practice kit because it's easier to read.
📝A worked example
Input: a learner wants to keep a week of readings in RAM on a chip with 320 KB of RAM.
Steps:
- Work out the size: one reading as JSON is about 100 bytes; a week at one every 15 minutes is 672 readings, about 67 KB.
- Compare: that's a fifth of all RAM, and RAM is lost in deep sleep or a reset anyway.
- Decide: keep readings in flash, a few at a time, and keep RAM for the work of the current wake.
Expected output: the reasoning that leads to JalSetu's flash buffer (IO8 explains it in full).
🌍Where it's used
- Wearables fit their code and data into small chips to save power and space.
- Smart meters run for years on the same firmware with little memory.
- Toys and appliances use the cheapest chip that can do the job, so code size affects cost.
📝Case scenario
A team ported a web-style library that built large JSON strings to a small chip. The device crashed every few hours when memory ran out in pieces. Building messages in a fixed buffer and reusing it stopped the crashes.
🖱️Try it
Look up the memory of one microcontroller board (for example an ESP32 or a Raspberry Pi Pico) on its maker's site. Compare its RAM and flash with your phone's. Success: two numbers for each, with the source named.
⚠️Common mistakes
- Assuming plenty of memory. Sign: crashes after hours of running. Fix: plan buffer sizes and reuse memory.
- Writing to flash on every change. Sign: worn-out flash after months. Fix: batch writes and spread them.
- Treating sleep as optional. Sign: a battery that lasts days. Fix: design around sleep from the start (IO3).
🛠️For your project
Project 1's state lives in RTC memory and Project 2's readings live in flash, because RAM doesn't survive deep sleep.
✅Quick check
Why do IoT devices keep long-term data in flash rather than RAM?
Show the answer
RAM is small and loses its contents in deep sleep or a reset; flash keeps them.
Why is writing to flash on every small change a problem?
Show the answer
Flash wears out after many writes, and each write costs power and time.
