E02. Why ESP32: Architecture, Memory and When to Leave the Uno
Ask the ESP32 what chip it is and how much memory it has, then decide when an ESP32 is a better choice than the Uno.
Learning outcomes
- Say why makers move from the Uno to an ESP32 (Wi-Fi, Bluetooth, speed, memory)
- Explain the difference between Flash (where the sketch is stored) and RAM (working memory)
- Print the chip model, Flash size and free memory on Serial
- Choose an Uno or an ESP32 for a given project
Parts and preparation
ESP32 DevKit (classic ESP32 Dev Module recommended), USB data cable, Arduino IDE 2 with esp32 by Espressif Systems installed.
Before power: inspect wiring, confirm supply voltage and ensure all connected circuits share GND.
What you will do
Before Wi-Fi and sensors, get to know the board on your bench. Sketch 1 asks the ESP32 for its chip name, its Flash size and how much memory is free. Sketch 2 prints the free memory every 2 seconds, so you can compare it with the Wi-Fi sketches later.
Why move beyond the Uno?
The Uno is great for controlling things on your bench. Many projects now also need to talk to a phone or the internet - this is often called the Internet of Things (IoT). The ESP32 adds Wi-Fi and Bluetooth, runs much faster and has far more memory. Everything you learned on the Uno still applies: setup(), loop(), pins and Serial.
Uno and ESP32 side by side
The sketches look the same. The board underneath is very different.
| Feature | Uno R3 | Typical ESP32 DevKit |
|---|---|---|
| Speed | 16 MHz | Up to 240 MHz, often with two processor cores |
| Pin voltage | 5 V | 3.3 V |
| Flash (stores the sketch) | 32 KB | Usually 4 MB - over 100 times more |
| RAM (working memory) | 2 KB | Hundreds of KB |
| Wi-Fi / Bluetooth | No | Yes (on most ESP32 chips) |
Two kinds of memory
Flash is where your sketch is stored. It keeps its contents when the power is off.
RAM is working memory: it holds your variables while the sketch runs, and it empties at power-off. Wi-Fi and Bluetooth use a lot of RAM. The free RAM is called free heap, and ESP.getFreeHeap() tells you how much is left.
Some boards add extra RAM called PSRAM. You will not need it in this course.
| Memory | What it holds | Kept at power-off? |
|---|---|---|
| Flash | Your sketch | Yes |
| RAM | Variables and Wi-Fi / Bluetooth data while running | No |
When is the Uno enough?
Stay on the Uno for 5 V parts, shields and simple projects on your bench. Choose an ESP32 when you need Wi-Fi, Bluetooth, more memory or more speed - and accept its 3.3 V pins and different pin numbers.
| Choose | Typical reasons |
|---|---|
| Uno | 5 V parts, shields, simple local control - everything in the Uno course |
| ESP32 | Wi-Fi, Bluetooth, more memory, more speed, connected projects |
Board setting for every ESP32 lesson
Tools -> Board -> esp32 -> ESP32 Dev Module. Serial Monitor at 115200. If you have a C3, C6 or P4 board, pick its own entry in the Board menu instead.
Wiring and safe build sequence
- USB data cable from PC to ESP32 DevKit
- Select ESP32 Dev Module (or matching board) and the correct port
- No external parts required
Worked sketch 1: Ask the board about itself
Download .inoWhat this sketch is for: Upload, open Serial Monitor at 115200 and read the three answers. Press EN to see them again.
void setup() { // setup() runs once
Serial.begin(115200); // start Serial at the ESP32 speed
delay(500); // give the USB link time to start
Serial.print("Chip model: "); // a label
Serial.println(ESP.getChipModel()); // ask the ESP32 for its chip name
Serial.print("Flash size (bytes): "); // a label
Serial.println(ESP.getFlashChipSize()); // how much space there is for sketches
Serial.print("Free memory (bytes): "); // a label
Serial.println(ESP.getFreeHeap()); // how much working memory (RAM) is free
}
void loop() { // nothing to repeat in this sketch
}How the code works
- ESP.getChipModel(), ESP.getFlashChipSize() and ESP.getFreeHeap() are built into the ESP32 board package - no library needed.
- 4194304 bytes of Flash is 4 MB (4 x 1024 x 1024).
- Everything happens in setup(), so press EN (reset) to print it again.
Worked sketch 2: Watch the free memory
Download .inoWhat this sketch is for: Print the free memory every 2 seconds. Write the number down - in ESP32 Lesson 08 you will see how much Wi-Fi uses.
void setup() { // runs once
Serial.begin(115200); // start Serial at the ESP32 speed
}
void loop() { // runs over and over
Serial.print("Free memory: "); // a label
Serial.print(ESP.getFreeHeap()); // the free working memory (RAM)
Serial.println(" bytes"); // the unit, then a new line
delay(2000); // wait 2 seconds before the next line
}How the code works
- The number should stay about the same, because this sketch does not use more memory as it runs.
- If the number kept falling in a bigger sketch, something would be using up memory - a useful warning sign.
Test and record evidence
Practical evidence checklist
Common faults and checks
- Blank Serial Monitor: set it to 115200, then press EN (reset) on the board.
- Upload fails: use a data USB cable, check the board and port, hold BOOT while uploading on some DevKits.
- ESP is not declared: the Board menu is set to an Uno - choose ESP32 Dev Module.
Check your understanding
Q1. Name two things an ESP32 has that an Uno R3 does not.
Show answer
Any two of: Wi-Fi, Bluetooth, much more memory, much more speed.
Q2. What is stored in Flash?
Show answer
Your sketch. It stays there when the power is off.
Q3. What is RAM used for?
Show answer
Working memory - variables and Wi-Fi / Bluetooth data while the sketch runs.
Q4. What does ESP.getFreeHeap() tell you?
Show answer
How much working memory (RAM) is free.
Q5. When is the Uno still the better choice?
Show answer
5 V parts, shields and simple projects with no Wi-Fi or Bluetooth.
Q6. What Serial speed do the ESP32 sketches use?
Show answer
115200.
Q7. Which Board menu entry do the ESP32 lessons use?
Show answer
ESP32 Dev Module.