# 📶 Cheatsheet: ESP32 BLE Gadget: Build a Two-Way Phone Device

> This cheatsheet is part of the paid section. Sign in and purchase the course to view the full content.

One-page lookup card for the whole course: board basics, toolchain, BLE two-way communication, and hardening.

---

## Module 1: Set Up and Flash Your First Sketch

### 1.1 Meet the ESP32 Dev Board

**Three meanings of "ESP32"**

| Term | Meaning |
| --- | --- |
| Chip | The bare Espressif SoC (e.g. ESP32-D0WD) |
| Module | Chip + flash + antenna (e.g. ESP32-WROOM-32) |
| Dev board | Module + USB, regulator, buttons (e.g. DevKitC) |

**Board parts and pin safety**

| Item | What to know |
| --- | --- |
| Logic level | **3.3 V only**. Never feed 5 V into a GPIO |
| Power | USB (5 V) or 3.3 V pin; board regulator handles the rest |
| Safe GPIOs | Most general pins; check your board's pinout |
| Avoid | **GPIO 6 to 11** (wired to internal flash) |
| Strapping pins | GPIO 0, 2, 12, 15 affect boot mode; use with care |
| Input-only | GPIO 34 to 39 (no output, no pull-up) |
| Boot / Reset | Hold BOOT, tap EN to enter flash mode if upload stalls |

> [!WARNING]
> 5 V on a 3.3 V GPIO destroys the pin or the chip. Double-check wiring before powering.

### 1.2 Install PlatformIO and Flash a Blink Sketch

**Install chain**

```steps
1. Install VS Code.
2. Install the PlatformIO IDE extension.
3. Open PlatformIO Home, then New Project.
4. Name the project, pick your board (e.g. `Espressif ESP32 Dev Module`), pick the Arduino framework.
5. Write code in `src/main.cpp`, then Build and Upload.
```

**Project layout**

```tree
my-gadget/
  platformio.ini
  src/
    main.cpp
  lib/
  test/
```

**`platformio.ini` essentials**

```ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
```

**Blink sketch**

```cpp
#include <Arduino.h>

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
}
```
