IoT_Spring_2025_Lecture_Notes
IoT_Spring_2025_Lecture_Notes
January 6, 2025
2
Contents
2 Microcontrollers 11
2.1 Why Do We Need a Microcontroller? Why Not Just Use a Microprocessor? 11
2.1.1 Microcontroller vs. Microprocessor . . . . . . . . . . . . . . . . . 11
2.1.2 Why Do We Need a Microcontroller? . . . . . . . . . . . . . . . . 11
2.1.3 Why Not Just Use a Microprocessor? . . . . . . . . . . . . . . . . 12
2.1.4 When to Use a Microprocessor . . . . . . . . . . . . . . . . . . . . 12
2.1.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2 Introduction to Microcontrollers . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Case Study: ESP32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Case Study: Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.5 Case Study: Particle Photon . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.6 Comparison: ESP32 vs Arduino vs Photon . . . . . . . . . . . . . . . . . 15
2.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.8 Purpose of SRAM vs Flash Memory on ESP32 . . . . . . . . . . . . . . . 15
3
4 CONTENTS
5 PCBs 25
5.1 PCB Design with Microcontrollers: Why and When? . . . . . . . . . . . 25
6 SoCs vs MCUs 27
6.1 Can a Microcontroller Be Considered an SoC? . . . . . . . . . . . . . . . 27
Chapter 1
2. Star Network: All devices are connected to a central hub, which manages com-
munication and data exchange.
5
6 CHAPTER 1. INTRODUCTION TO IOT USING CASE STUDIES
• Key Components:
• Considerations:
• Key Components:
– Sensors:
∗ Traffic Cameras: For vehicle detection and traffic density estimation.
∗ Air Quality Sensors: Measure pollutants such as PM2.5 and NOx.
– Communication Network:
∗ LoRaWAN for low-power, wide-area air quality data transfer.
∗ Cellular/Wi-Fi for high-bandwidth traffic camera feeds.
– Processing:
∗ Edge: Basic object detection and filtering in smart cameras.
∗ Cloud: Aggregated traffic analysis and pollution mapping.
• Considerations:
1.2. CASE STUDIES 7
• Key Components:
• Considerations:
• Key Components:
• Considerations:
– Collect data from the environment (e.g., GPS, flow sensors) or act upon the
system (e.g., valves, motors).
– Require optimization for power, durability, and accuracy.
– Edge Processing:
∗ Ideal for real-time tasks and latency-sensitive operations.
∗ Reduces bandwidth requirements by filtering and processing data locally.
– Cloud Processing:
∗ Suitable for large-scale analytics and storage.
∗ Supports centralized control and integration of complex models.
• Communication Networks:
– Enable data transfer between IoT devices and the processing systems.
– Choice depends on bandwidth needs, power constraints, and range require-
ments (e.g., LoRaWAN, 5G).
– IoT devices must implement encryption, secure boot, and robust protocols to
protect against breaches.
– Centralized data (in the cloud) must follow compliance regulations (e.g., GDPR).
• Software Stack:
– Includes on-device software (lightweight OS like FreeRTOS), middleware (for
communication and device management), and cloud platforms (for analytics
and storage).
2. How can IoT systems ensure scalability and security in large-scale applications?
3. Propose another application of IoT and identify its core components and consider-
ations.
Chapter 2
Microcontrollers
2. Compact and Power-Efficient: MCUs are smaller and consume less power, mak-
ing them ideal for low-power, battery-operated devices like remote controls or
IoT devices.
4. Ease of Use: MCUs are easier to set up for small, dedicated tasks since they do
not require an external memory or peripheral interface.
11
12 CHAPTER 2. MICROCONTROLLERS
• Higher Power Consumption: MPUs consume more power and are not ideal for
portable or low-power applications.
• Overkill for Simple Tasks: Using a microprocessor for simple tasks like blinking
an LED or reading a sensor is like using a bulldozer to plant a flower—unnecessary
and inefficient.
2.1.5 Conclusion
We use microcontrollers in embedded systems because they are cost-effective, com-
pact, energy-efficient, and tailored for specific tasks. In contrast, microprocessors are
better suited for general-purpose, high-performance computing.
Technical Specifications
Feature Details
Processor Dual-core Xtensa LX6, 240 MHz
Voltage 3.3V
Flash Memory 4 MB (varies by model)
RAM 520 KB SRAM
Wi-Fi 802.11 b/g/n
Bluetooth v4.2 BR/EDR + BLE
GPIO Pins 34 (with ADC, PWM, SPI, I2C, etc.)
• Other OS Options:
• Optional RTOS:
Technical Specifications
Feature Details
Processor ARM Cortex-M3, 120 MHz
Voltage 3.3V
Flash Memory 1 MB
RAM 128 KB SRAM
Wi-Fi 802.11 b/g/n (Broadcom chipset)
GPIO Pins 18
Cloud Integration Full Particle Cloud support
• Provides built-in cloud functionality for remote monitoring and firmware updates.
2.6. COMPARISON: ESP32 VS ARDUINO VS PHOTON 15
2.7 Conclusion
• ESP32: Ideal for high-performance IoT and wireless applications.
• Key Characteristics:
2. Flash Memory
• Purpose: Permanent storage for the program code and static data.
• Key Characteristics:
• Flash: Provides a large, reliable storage area for program code and persistent data.
Together, SRAM and Flash memory enable the ESP32 to function efficiently in a
wide variety of applications, from running real-time tasks to storing IoT configurations
and firmware.
Chapter 3
The compilation and upload process in the Arduino ecosystem transforms your sketch
(code) written in the Arduino IDE into machine code that runs on the microcontroller.
Below is the step-by-step explanation of the process:
3.2 Preprocessing
When you click Verify or Upload:
1. The IDE adds necessary includes like #include <Arduino.h>.
2. Combines multiple files (if any) into one.
3. Processes macros such as #define.
3.3 Compilation
The preprocessed sketch is compiled into machine code:
• C++ Conversion: The sketch is converted into a .cpp file.
• Compiler Invocation: The IDE uses the GCC toolchain to compile the code:
– AVR GCC for Arduino Uno or Mega.
– Xtensa GCC for ESP32.
– ARM GCC for ARM-based boards.
• Linking: Combines the compiled files into an executable binary.
17
18 CHAPTER 3. COMPILATION FLOW: FROM SKETCH TO BOARD
3. Transferring the binary using a protocol like avrdude (AVR) or esptool.py (ESP32).
Sketch (.ino)
↓
Preprocessing
↓
C++ Code (.cpp)
↓
Compilation
↓
Binary File (.hex/.bin)
↓
Upload to Microcontroller
↓
Execution
This flow ensures the Arduino board executes your intended program efficiently.
Features:
1. The compiler and the target system architecture are the same.
2. The program can be directly executed after compilation.
3. No additional tools or configurations are needed for cross-platform compatibility.
Examples:
1. Compiling a program on an Intel processor based machine with x86-64 ISA for
execution on an Intel machine with the same ISA.
3.8.2 Cross-Compilation
Cross-compilation involves compiling code on one platform to run on a different platform
(the target).
Features:
1. The compiler generates machine code suitable for a target platform different from
the host.
2. Requires a toolchain (cross-compiler) specific to the target architecture.
3. Used in embedded systems, IoT devices, and other cases where the target has
limited resources.
Examples:
1. Compiling Arduino sketches on a computer and uploading them to an Arduino
board (host: PC, target: microcontroller).
2. Cross-compiling for ARM-based systems (e.g., Raspberry Pi) on an x86 desktop.
3.8.3 Comparison
Aspect Native Compila- Cross-Compilation
tion
Definition Compilation for the Compilation for a dif-
same platform ferent platform
Compiler Native compiler Cross-compiler
Target System Same as the host Different from the
host
Ease of Setup Easy, minimal config- Requires toolchains
uration and setup
Use Cases Local application de- Embedded systems,
velopment IoT, and cross-
platform projects
20 CHAPTER 3. COMPILATION FLOW: FROM SKETCH TO BOARD
4.1 Introduction
The ESP32 is a highly versatile microcontroller, widely used in embedded systems and
IoT applications. One of its key strengths is its integration with FreeRTOS, a real-time
operating system (RTOS) that provides multitasking and system management capabili-
ties. This chapter explores the role of FreeRTOS in ESP32 development, its inclusion in
compiled binaries, and the benefits it offers for embedded applications.
21
22 CHAPTER 4. FREERTOS IN COMPILED ESP32 BINARIES
freertos/port.c
freertos/queue.c
• Real-Time Scheduling: Ensures tasks are executed within precise time con-
straints.
• System-Level Features: Manages system tasks like Wi-Fi, Bluetooth, and low-
power modes seamlessly.
4.7. CONCLUSION 23
4.7 Conclusion
The inclusion of FreeRTOS in ESP32 binaries is crucial for leveraging the full potential
of the microcontroller. It simplifies the development of real-time, multitasking appli-
cations, enabling developers to focus on application logic rather than low-level system
management.
24 CHAPTER 4. FREERTOS IN COMPILED ESP32 BINARIES
Chapter 5
PCBs
• Compact and Durable Systems: PCBs are more compact, durable, and profes-
sional compared to fragile breadboard setups.
• Improved Signal Integrity: PCBs reduce noise, interference, and loose connec-
tions, which are critical in sensitive or high-speed circuits.
• Mass Production: PCBs enable uniform and efficient manufacturing for large-
scale production.
• Power and Heat Management: PCBs provide efficient power distribution and
allow for heat dissipation through thermal vias or heat sinks.
• Custom Enclosure Fit: PCBs can be designed to fit specific mechanical enclo-
sures, improving aesthetics and functionality.
• Long-Term Reliability: PCBs are less prone to wear and tear, simplifying main-
tenance and troubleshooting with labeled traces.
– ESP32 microcontroller
– Flash memory, antenna, crystal oscillator, and power regulation circuitry
• It simplifies using the ESP32 by providing solder pads or pin headers for easy
integration.
25
26 CHAPTER 5. PCBS
Conclusion
Transitioning to PCB design from microcontroller modules like ESP32-WROOM ensures
reliability, scalability, and a professional finish, especially in complex or mass-production
applications.
Chapter 6
SoCs vs MCUs
Microcontroller Characteristics
• A microcontroller typically includes:
• Example microcontrollers:
27
28 CHAPTER 6. SOCS VS MCUS
– SoCs: More powerful, capable of running operating systems like Linux, used
in complex systems (e.g., smartphones, IoT hubs).
• Peripheral Integration:
Examples
• Microcontroller as SoC:
– ESP32: Dual-core processor, RAM, flash, Wi-Fi, and Bluetooth in one chip.
– STM32F4: Cortex-M CPU, RAM, flash, and peripherals.
• Traditional SoC:
Conclusion
• A microcontroller can be considered a basic form of SoC because it integrates
most system components onto a single chip.
• However, SoCs generally refer to more powerful and feature-rich chips used in
advanced systems, while microcontrollers are optimized for simpler, low-power
applications.