30  Reference: ESP32 Pinout, Power, and Signal Formula Cheat Sheet

Pin Maps and Interactive Calculators for Link Budget, Battery Life, and ADC Resolution

electronics
esp32
power
signal

30.1 Interactive Formula Reference

30.1.1 Interactive Calculators


30.2 Formula Cards

Putting Numbers to It

Let’s design a LoRaWAN sensor for EU868 using the formulas above. Goal: 5-year battery life on 2× AA batteries (2400 mAh).

Step 1: Choose spreading factor

  • Urban environment, gateway at 500m
  • Free Space Path Loss: \(\text{FSPL} = 20\log_{10}(500) + 20\log_{10}(868 \times 10^6) - 147.55 = 85.5\,\text{dB}\)
  • Link budget: \(P_{rx} = 14\,\text{dBm} + 2\,\text{dBi} + 2\,\text{dBi} - 85.5\,\text{dB} - 10\,\text{dB margin} = -77.5\,\text{dBm}\)
  • SF7 sensitivity is -123 dBm → link margin = \(-123 - (-77.5) = 45.5\,\text{dB}\) → SF7 works comfortably

Step 2: Calculate airtime and duty cycle

  • Payload: 12 bytes, SF7 → airtime ≈ 40 ms
  • EU868 duty cycle: 1% = 36 seconds TX per hour max
  • Messages allowed per hour: \(36\,\text{s} \div 0.04\,\text{s} = 900\) messages/hour max
  • We want 1 message every 10 minutes = 6 messages/hour → well within duty cycle (OK)

Step 3: Battery life calculation \[ \begin{align} \text{Sleep current: } & 1\,\mu\text{A}\\ \text{TX current: } & 30\,\text{mA} \text{ @ 14 dBm}\\ \text{TX time: } & 40\,\text{ms per message}\\ \text{Messages: } & 6/\text{hour} = 144/\text{day} \end{align} \]

Average current: \[ I_{avg} = \frac{1\,\mu\text{A} \times (24 \times 3600 - 144 \times 0.04) + 30\,\text{mA} \times (144 \times 0.04)}{24 \times 3600} = 0.0487\,\text{mA} \]

Battery life: \((2400\,\text{mAh} \times 0.8) \div 0.0487\,\text{mA} = 39,424\,\text{hours} = 1,643\,\text{days} = 4.5\,\text{years}\) (OK)

Key insight: Sleep current dominates! Even though TX is 30 mA vs 1 µA sleep, the device spends 99.93% of time sleeping. Reducing sleep current from 1 µA to 0.5 µA gains 1.25 years; reducing TX power from 14 dBm to 10 dBm (15 mA) only gains 2 months.


30.3 Pin-Out Reference

30.3.1 ESP32 Quick Reference


30.4 Conversion Tables

Use ESP32 Pin-Outs in Projects

Scenario: You need to connect a DHT22 temperature sensor, an I2C OLED display, and monitor battery voltage on an ESP32.

Step 1: Identify Required Interfaces

  • DHT22: 1-wire digital protocol (needs any GPIO)
  • OLED: I2C interface (needs SDA + SCL)
  • Battery voltage: Analog input (needs ADC)

Step 2: Consult Pin-Out Reference

  • I2C (default): SDA=GPIO21, SCL=GPIO22
    • Decision: Use default I2C pins for OLED (no conflicts, easier debugging)
  • ADC (12-bit): GPIO32-39 (ADC1), GPIO0,2,4,12-15,25-27 (ADC2)
    • Note: ADC2 unavailable when Wi-Fi active
    • Decision: Use GPIO34 (ADC1_6) for battery voltage - available while Wi-Fi is active, but input-only and without an internal pullup
  • DHT22 data pin: Needs any free GPIO
    • Avoid: GPIO0,2,4,5,12,15 on typical ESP32 boards (strapping pins can affect boot)
    • Avoid: GPIO34-39 (input-only, can’t use internal pullup)
    • Decision: Use GPIO16 when it is exposed on the chosen board and not reserved by another peripheral

Step 3: Validate No Conflicts

  • GPIO16 (DHT22): Available in this example board, not used by I2C or ADC
  • GPIO21/22 (OLED I2C): Default I2C, no conflicts
  • GPIO34 (battery ADC): ADC1, works with Wi-Fi enabled

Step 4: Reference Formulas for ADC

  • From formula card: ADC Resolution = Vref / 2^bits
  • ESP32: 12-bit ADC, 3.3V reference
  • Step size: 3.3V / 4096 = 0.8mV per step
  • For 0-5V battery (using voltage divider): Divider ratio = 5V/3.3V = 1.52
    • Use 10kΩ and 15kΩ resistors: (15kΩ/(10kΩ+15kΩ)) × 5V = 3V at GPIO34

Step 5: Code Pattern from Reference

# From Moving Average Pattern (reference card)
battery_filter = MovingAverage(window=10)

# From Sensor Reading Pattern (reference card)
def read_dht22_with_retry():
    for attempt in range(3):
        try:
            temp, humidity = dht.read()
            if temp > -40 and temp < 80:  # Valid range
                return temp, humidity
        except:
            time.sleep(0.1 * (2 ** attempt))
    return None, None

Result: Complete wiring plan and code skeleton in 5 minutes by referencing the Quick Reference Cards instead of searching through 4 different chapter pages and datasheets.

Time Saved: Without reference cards: 20-30 minutes (find I2C chapter, find ADC chapter, look up strapping pins, search for code patterns). With reference cards: 5 minutes (scan one page, make decisions).