CHAPTER 4

TinyML and Embedded AI

What is TinyML?

TinyML (Tiny Machine Learning) represents the extreme edge of AI deployment—running neural networks on microcontrollers with as little as 1KB RAM, 1MHz processors, and microwatt power consumption. These ultra-resource-constrained devices enable always-on AI in battery-powered sensors, wearables, and IoT endpoints that operate for months or years on coin cell batteries.

TinyML sits at the intersection of embedded systems and machine learning, bringing intelligence to the billions of microcontrollers deployed globally—devices previously considered too limited for AI workloads.

Hardware Constraints

Microcontroller Specifications

Typical TinyML hardware specifications:

Component Typical Range Example (ARM Cortex-M4)
Flash Memory 64KB - 2MB 512KB
SRAM 8KB - 256KB 96KB
Clock Speed 48MHz - 200MHz 80MHz
Power 1mW - 100mW ~5mW active
Cost $1 - $10 $3

Compare this to smartphones with 6-12GB RAM, 3GHz processors, and watt-scale power budgets. TinyML operates with 1000x less memory, 100x slower processors, and 1000x less power.

Memory Architecture

Microcontrollers have two memory types:

A 100KB model fits in Flash, but intermediate activations must fit in SRAM—often just 32-64KB. This is the primary bottleneck.

TensorFlow Lite Micro

Architecture

TensorFlow Lite Micro (TFLM) is Google's framework for running ML on microcontrollers. It's a stripped-down version of TensorFlow Lite designed for extreme resource constraints:

Example: Keyword Spotting

// TensorFlow Lite Micro inference (C++)
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "model.h"  // Converted TFLite model

constexpr int kTensorArenaSize = 10 * 1024;  // 10KB for activations
uint8_t tensor_arena[kTensorArenaSize];

// Setup
static tflite::MicroMutableOpResolver<6> micro_op_resolver;
micro_op_resolver.AddConv2D();
micro_op_resolver.AddDepthwiseConv2D();
micro_op_resolver.AddFullyConnected();
micro_op_resolver.AddSoftmax();
micro_op_resolver.AddReshape();
micro_op_resolver.AddQuantize();

static tflite::MicroInterpreter interpreter(
    model, micro_op_resolver, tensor_arena, kTensorArenaSize);

interpreter.AllocateTensors();

// Inference
TfLiteTensor* input = interpreter.input(0);
// Fill input with audio features
for (int i = 0; i < input->bytes; i++) {
    input->data.uint8[i] = audio_features[i];
}

interpreter.Invoke();

TfLiteTensor* output = interpreter.output(0);
uint8_t prediction = output->data.uint8[0];

Model Design for TinyML

Ultra-Compact Architectures

Standard architectures (ResNet, BERT) are far too large. TinyML requires purpose-built models:

Depthwise Separable Convolutions

Standard convolutions are computationally expensive. Depthwise separable convolutions factorize into:

// Standard Conv2D: C_in × C_out × K × K multiplies
Standard: 64 × 128 × 3 × 3 = 73,728 multiply-adds

// Depthwise Separable: (C_in × K × K) + (C_in × C_out × 1 × 1)
Depthwise: (64 × 3 × 3) + (64 × 128 × 1 × 1) = 576 + 8,192 = 8,768

Reduction: 73,728 / 8,768 = 8.4x fewer operations!

Binary and Ternary Networks

Extreme quantization where weights are constrained to:

This enables 32x compression beyond INT8 quantization, crucial for sub-10KB models.

TinyML Use Cases

Always-On Keyword Detection

Listen continuously for wake words ("Hey Siri", "OK Google") with <1mW power draw. Model detects keyword locally, then wakes main processor for full speech recognition.

Model: 14KB DS-CNN
Input: 40 MFCC features × 10 frames
Output: 4 classes (yes, no, unknown, silence)
Latency: 5ms per inference
Power: 0.8mW continuous
Accuracy: 92% on speech commands dataset

Predictive Maintenance Sensors

Industrial vibration sensors analyze motor/bearing health. Detect anomalies locally, transmit only alerts—not raw vibration data.

Environmental Monitoring

Wildlife cameras with on-device animal classification. Capture images only when target species detected, preserving battery and storage.

Gesture Recognition

Wearable devices detecting hand gestures from accelerometer/gyroscope. No image data, extreme privacy preservation.

Health Monitoring

Wearable ECG monitors detecting arrhythmias, fall detection in elderly care devices, seizure prediction from EEG.

Training TinyML Models

Training Pipeline

  1. Design Architecture: Ensure model fits memory constraints (check Flash and SRAM requirements)
  2. Train with Quantization Awareness: Simulate INT8 arithmetic during training
  3. Optimize: Prune aggressively (80-95% sparsity common)
  4. Convert: Export to TensorFlow Lite Micro format
  5. Benchmark: Measure on actual microcontroller hardware
// Training for TinyML with size constraints
model = Sequential([
    DepthwiseConv2D(kernel_size=3, depth_multiplier=1),
    BatchNormalization(),
    ReLU(),
    DepthwiseConv2D(kernel_size=3, depth_multiplier=1),
    GlobalAveragePooling2D(),
    Dense(4, activation='softmax')
])

# Quantization-aware training
quant_model = quantize_model(model)
quant_model.compile(optimizer='adam', loss='categorical_crossentropy')
quant_model.fit(train_data, epochs=50)

# Convert to TFLite Micro
converter = tf.lite.TFLiteConverter.from_keras_model(quant_model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
tflite_model = converter.convert()

# Check size constraints
print(f"Model size: {len(tflite_model)} bytes")
assert len(tflite_model) < 100_000, "Model too large for 512KB Flash!"

Data Collection Challenges

TinyML often targets niche applications with limited labeled data. Strategies:

Power Optimization

Energy Breakdown

Where does power go in TinyML inference?

Component Power (mW) Percentage
Core Computation 1.2 40%
Memory Access 1.5 50%
I/O (Sensors) 0.3 10%

Memory access dominates! Reducing data movement is critical.

Power-Saving Techniques

// Cascaded inference for power saving
void loop() {
    // Tier 1: Ultra-cheap binary classifier (0.5mW, 2ms)
    if (cheap_detector.has_activity()) {
        // Tier 2: Full model only when needed (5mW, 10ms)
        result = full_model.infer();
        if (result.confidence > 0.8) {
            transmit_alert(result);
        }
    }
    sleep_until_next_window();  // Deep sleep between inferences
}

Development Tools and Frameworks

TensorFlow Lite Micro

Google's official framework. Supports most common layers, optimized for ARM Cortex-M.

Edge Impulse

End-to-end platform for building TinyML applications. Handles data collection, training, optimization, and deployment.

Arduino IDE + TinyML

Accessible development environment for prototyping. Libraries for common models (keyword spotting, gesture recognition).

STM32Cube.AI

STMicroelectronics' toolkit for deploying AI on STM32 microcontrollers. Automated optimization and code generation.

Arm Ethos-U

Microcontroller-class neural processing unit. 256 MAC/cycle, INT8/INT16 support, 0.5 TOPS/W efficiency.

Real-World Deployment

Arduino Nano 33 BLE Sense Example

Popular TinyML prototyping platform with integrated sensors:

// Complete gesture recognition on Arduino
#include 
#include 
#include "model.h"

void setup() {
    IMU.begin();
    interpreter = new tflite::MicroInterpreter(...);
    interpreter->AllocateTensors();
}

void loop() {
    float ax, ay, az;
    if (IMU.accelerationAvailable()) {
        IMU.readAcceleration(ax, ay, az);

        // Fill input tensor
        input_tensor->data.f[buffer_index++] = ax;
        input_tensor->data.f[buffer_index++] = ay;
        input_tensor->data.f[buffer_index++] = az;

        if (buffer_index >= 384) {  // 128 samples × 3 axes
            interpreter->Invoke();
            int gesture = argmax(output_tensor);
            Serial.println(gesture_names[gesture]);
            buffer_index = 0;
        }
    }
}

Battery Life Calculations

// Calculate battery life for TinyML deployment
Battery: 1000mAh (CR2032 coin cell)
Inference: 5mW for 10ms
Sleep: 5µW
Duty Cycle: Infer once per second

Active Power: 5mW × 10ms = 50µJ per inference
Sleep Power: 5µW × 990ms = 4.95µJ per cycle
Total per inference: ~55µJ

Power per second: 55µJ × 1 = 55µJ
Average power: 55µW

Battery life: 1000mAh × 3V = 3000mWh = 10,800,000mWs
Lifetime: 10,800,000mWs / 0.055mW = 196,363,636 seconds
         = 3,272,727 minutes = 6.2 years!

Result: Multi-year deployment on coin cell battery

弘益人間 TinyML Principle:

TinyML democratizes AI by bringing intelligence to the most resource-constrained devices, enabling IoT applications that benefit humanity—from wildlife conservation to elderly care—without requiring expensive hardware or constant internet connectivity.

Challenges and Future Directions

Current Limitations

Emerging Technologies

Summary

TinyML enables AI on microcontrollers with extreme resource constraints—kilobytes of RAM, megahertz processors, milliwatt power budgets. Key enablers include:

  • TensorFlow Lite Micro: Optimized framework for microcontrollers
  • Ultra-compact models: Depthwise separable convolutions, binary/ternary networks, aggressive pruning
  • Quantization: INT8 and even binary quantization for maximum compression
  • Power optimization: Duty cycling, cascaded inference, voltage scaling

TinyML unlocks always-on AI applications—keyword spotting, predictive maintenance, environmental monitoring—running for years on battery power. This brings intelligence to billions of edge devices, enabling privacy-preserving, offline-capable AI at massive scale.

Review Questions

  1. What are typical hardware specifications for TinyML microcontrollers?
  2. How does TensorFlow Lite Micro differ from standard TensorFlow Lite?
  3. Explain why depthwise separable convolutions are important for TinyML.
  4. What are binary and ternary neural networks, and why are they used in TinyML?
  5. Describe three real-world TinyML use cases and their requirements.
  6. Why does memory access consume more power than computation in TinyML?
  7. What is cascaded inference, and how does it save power?
  8. Calculate battery life for a device doing 1ms inference at 10mW every 10 seconds, sleeping at 10µW, with a 500mAh battery.
  9. What are the main challenges in developing TinyML applications?
  10. Name three emerging technologies that could advance TinyML capabilities.

Korea Digital Transformation Detailed Mapping

Korea operates digital transformation through a comprehensive governance system. Digital Government: Digital Platform Government Committee (established September 2022, under the President)·Ministry of the Interior and Safety Digital Government Bureau·e-Government Support Center·Gov.kr·National Citizen Service·KDIS (Korea Digital Information Society)·NIA (National Information Society Agency)·MOIS (Ministry of the Interior and Safety). K-DNS Infrastructure: Korea Internet & Security Agency (KISA) Korea Internet Center·KISA DNS Root Server·KRNIC (Korea Network Information Center)·BGP Korea·National Cyber Security Center (NCSC)·KCC (Korea Communications Commission)·MSIT (Ministry of Science and ICT)·NIA·NIPA. Korean Cloud Infrastructure: KT Cloud·NAVER Cloud (NCloud)·Samsung SDS Cloud·LG U+ Cloud·NHN Cloud·Kakao Enterprise Cloud·SK Telecom Cloud·KISA Cloud Security Assurance Program (CSAP)·KCMVP-validated cloud·ISMS-P (Information Security & Personal Information Management System). Korean Security Certifications: KISA ISMS-P certification·KCMVP (Korean Cryptographic Module Validation Program)·NIS (National Intelligence Service) "National Cryptographic Technology Operation Standards"·NCSC "National Cyber Security Strategy 2024-2028"·CC (Common Criteria) Korean evaluation bodies·EAL4·EAL5·KS X ISO/IEC 15408·19790·24759 Korean Profile. Korean Data Standards: NIA AI Hub·National Data Standardization Committee·Statistics Korea (KOSTAT)·MyData 4 Designated Combination Specialists (Samsung SDS, KICI, KOSTAT, KFTC)·National Institute of Korean Language·National Law Information Center·National Spatial Information Platform·National Spatial Data Center·Korean Spatial Information Standards. Finance and Fintech Standards: FSC (Financial Services Commission)·FSS (Financial Supervisory Service)·FIU (Financial Intelligence Unit)·BOK (Bank of Korea)·FSEC (Financial Security Institute)·KFTC (Korea Financial Telecommunications)·KSD (Korea Securities Depository)·KRX (Korea Exchange) 8-agency cooperation. 5G/6G Communications Infrastructure: 5G subscribers 35 million (2024)·5G base stations 350,000·6G commercialization target 2028·5G dedicated networks 16 operators·6G Acceleration Council (MSIT, 2024). K-Content: KOCCA (Korea Creative Content Agency)·MCST (Ministry of Culture, Sports and Tourism)·KCA (Korea Communications Agency)·Korea Culture Information Service Agency·Korean Film Archive·Korea Publishing Industry Promotion Agency. Data 3 Acts (Personal Information Protection Act·Credit Information Act·Telecommunications Network Act, 2020 enforcement)·Data Industry Act (2021)·Public Data Act (2013)·AI Framework Act (2026)·Digital Platform Government Framework Act (2024 proposed) — Korea digital transformation core legislation.

Korea Industrial, Research, Education Infrastructure Mapping

Korea operates its industrial ecosystem and standardization system through the following core infrastructure. Korea Top 5 Groups: Samsung, Hyundai Motor, LG, SK, Lotte. Each group operates standardization committees and ISO/IEC TC Korean secretariats. Samsung Electronics (semiconductors, displays, home appliances, telecom)·Hyundai Motor (automobiles, mobility)·LG Electronics (home appliances, displays, OLED)·SK hynix (memory)·LG Energy Solution·Samsung SDI (batteries)·POSCO Future M (materials)·Hyundai Mobis (parts). Korean IT Big Tech: NAVER (search, cloud, AI HyperCLOVA)·Kakao (messenger, payment, mobility, banking)·Coupang (e-commerce, logistics)·Karrot Market·Toss·Woowa Brothers. Korea Telcos: SK Telecom·KT·LG U+. 5G·5G dedicated networks·B2B cloud·AI businesses operating. Korea Top 7 Research Universities: Seoul National University·KAIST·POSTECH·Yonsei University·Korea University·UNIST·DGIST·GIST. All serve as standardization R&D bases and ISO/IEC/IEEE Korean chairs. Korea Government-affiliated National Research Institutes (26): KIST, KAERI, KIMM, KIER, KFRI, KRICT, KRIBB, KARI, KASI, KIGAM, KICT, KISTI, KETI, ETRI, NIMS, KIMS, KISDI, KOTRA, STEPI, KOEN, KICCE, KIET, KIPF, KIHASA, KICJ, KLRI. Korea Industrial Complexes / Tech Valleys: Pangyo Techno Valley·Dongtan·Gwanggyo·Songdo IBD·Yeouido·Gangnam·Sihwa·Banwol·Gumi·Ulsan·Changwon·Geoje·Yeosu·Onsan·Cheongju·Iksan·Gwangyang·POSCO Gwangyang Steel Mill·Asan Bay·Seosan·Songdo·Incheon Airport·Sejong·Cheongna·Geomdan. Korea Trade and Finance Infrastructure: Korea International Trade Association (KITA)·Korea Trade-Investment Promotion Agency (KOTRA)·Export-Import Bank of Korea (KEXIM)·Bank of Korea·Kookmin Bank·Shinhan·Hana·Woori·NH Nonghyup·IBK Industrial Bank·SC First Bank·Citi Bank Korea·HSBC Korea·DBS Korea — 14 Korean major banks and foreign banks. Korea K-POP / K-Content: HYBE·SM·YG·JYP 4 major entertainment companies·CJ ENM·tvN·MBC·KBS·SBS·EBS·YTN·Yonhap News TV·JTBC Korean broadcasting·NETFLIX Korea·Disney Plus·TVING·Wavve·Watcha·Coupang Play. Korea Gaming Industry: Nexon·NCsoft·Krafton·Netmarble·Kakao Games·Pearl Abyss·Com2uS·Gamevil·NHN·Smilegate·Webzen. Korea Automotive / Battery: Hyundai Motor·Kia·Genesis·LG Energy Solution·Samsung SDI·SK On·POSCO Future M·EcoPro·L&F battery cathode material suppliers. Korea Semiconductor: Samsung Electronics (HBM3E·HBM4)·SK hynix (HBM3E 12-Hi)·DB HiTek·SK siltron·SK Enpulse·Dongjin Semichem·Seoul Semiconductor·Simmtech·Samsung Display·LG Display.

Korea Standardization Infrastructure Mapping

Korea operates a comprehensive standards governance system through inter-ministerial cooperation. National Standards Council (under Prime Minister's Office, per Framework Act on National Standards Article 5) coordinates KATS (Korean Agency for Technology and Standards), MFDS (Ministry of Food and Drug Safety), MOTIE (Ministry of Trade, Industry and Energy), MSIT (Ministry of Science and ICT), MOIS (Ministry of the Interior and Safety), MOE (Ministry of Environment), MOHW (Ministry of Health and Welfare), MND (Ministry of National Defense), MCST (Ministry of Culture, Sports and Tourism), MOFA (Ministry of Foreign Affairs), MOJ (Ministry of Justice), and FSC (Financial Services Commission). Accreditation and Testing: KOLAS (Korea Laboratory Accreditation Scheme) accredits 800+ testing laboratories. KAS (Korea Accreditation System) accredits 50+ certification bodies. KTC (Korea Testing Certification), KTR (Korea Testing & Research Institute), KTL (Korea Testing Laboratory), and KCL (Korea Conformity Laboratories) provide conformance testing. Telecom and Cyber: KCC (Korea Communications Commission), KCA (Korea Communications Agency), TTA (Telecommunications Technology Association), IITP (Institute for Information & Communications Technology Planning & Evaluation), NIPA (National IT Industry Promotion Agency), KISA (Korea Internet & Security Agency), KCMVP (Korea Cryptographic Module Validation Program), NIS (National Intelligence Service), NSR (National Security Research Institute), and NCSC (National Cyber Security Center). National R&D Centers: KIST, ETRI, KAIST, Seoul National University, Yonsei University, Korea University, POSTECH, UNIST, GIST, DGIST, KISTI, KIER, KIMM, KRICT, KFRI, KRIBB. International Standards Cooperation: ISO TC/SC Korean secretariats, IEC TC/SC Korean secretariats, ITU-T Study Group Korean chairs, 3GPP RAN/SA Korean chairs, IEEE 802 Korean chairs, W3C Korea office, OASIS Korea office, IETF Korea cooperation, OECD CSTP, UN ESCAP, APEC SCSC Korean cooperation. Korean Industrial Standards (KS) Catalog: KS X (Information) 25,000+, KS A (Basic) 15,000+, KS B (Machinery) 25,000+, KS C (Electrical) 18,000+, KS D (Metallurgy) 12,000+, KS E (Mining) 5,000+, KS F (Construction) 18,000+, KS H (Food) 8,000+, KS I (Environment) 5,000+, KS J (Biology) 3,000+, KS K (Textile) 15,000+, KS L (Ceramics) 7,000+, KS M (Chemistry) 12,000+, KS P (Medical) 5,000+, KS Q (Quality Mgmt) 4,000+, KS R (Transport) 12,000+, KS S (Service) 3,000+, KS T (Packaging) 4,000+, KS V (Shipbuilding) 5,000+, KS W (Aerospace) 3,000+ — totaling 220,000+ Korean Industrial Standards. Key Acts: Personal Information Protection Act (Act 19234, effective Sept 15, 2024), Electronic Government Act, Electronic Signature Act, Act on Promotion of Information and Communications Network Utilization and Information Protection, Information and Communications Infrastructure Protection Act, Data Industry Act, Public Data Act, AI Framework Act (Act 20212, effective July 2026), Industrial Technology Innovation Promotion Act, Framework Act on Science and Technology — 70+ Korean standardization-related laws.