# espressif/arduino-esp32 architecture

> Architecture diagram of the GitHub repository espressif/arduino-esp32, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/espressif/arduino-esp32
- Repository: https://github.com/espressif/arduino-esp32

## Overview

Arduino-ESP32 is a hardware-support core and runtime for Arduino sketches on ESP32-family SoCs, also usable as an ESP-IDF component. The principal workflow is runtime startup, sketch setup/loop dispatch, then sketch code using core APIs and peripheral or service libraries to interact with hardware and network peers. The tree and excerpts support the startup and selected network, HTTP/TLS, BLE, Zigbee, and web-server relationships; other library capabilities are represented without asserting unsampled internal call wiring.

Main entry points: [`libraries/HTTPClient/src/HTTPClient.cpp`](https://github.com/espressif/arduino-esp32/blob/master/libraries/HTTPClient/src/HTTPClient.cpp) (HTTP client), [`cores/esp32/Arduino.h`](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Arduino.h) (Arduino API), [`cores/esp32/main.cpp`](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp) (Arduino startup), [`cores/esp32/esp32-hal.h`](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal.h) (ESP32 HAL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Sketch Runtime"]
  node_main["Arduino startup<br/>[main.cpp]"]
  node_arduino["Arduino API<br/>[Arduino.h]"]
end

subgraph group_hardware["Hardware APIs"]
  node_hal["ESP32 HAL<br/>[esp32-hal.h]"]
  node_wire["I2C and SPI<br/>[Wire.cpp]"]
  node_usb["USB device/host<br/>[USBHID.cpp]"]
end

subgraph group_connectivity["Connectivity"]
  node_network["Network manager<br/>[NetworkManager.cpp]"]
  node_wifi["Wi-Fi<br/>[WiFi.cpp]"]
  node_eth["Ethernet<br/>[ETH.cpp]"]
  node_http["HTTP client<br/>[HTTPClient.cpp]"]
  node_tls["TLS transport<br/>[ssl_client.cpp]"]
  node_ble["Bluetooth LE<br/>[BLEDevice.cpp]"]
  node_zigbee["Zigbee endpoints<br/>[ZigbeeHandlers.cpp]"]
  node_openthread["OpenThread<br/>[OThread.cpp]"]
end

subgraph group_services["Device Services"]
  node_webserver["HTTP server<br/>[WebServer.cpp]"]
  node_matter["Matter devices<br/>[Matter.cpp]"]
  node_ota["Firmware updates<br/>[Updater.cpp]"]
end

subgraph group_storage["Storage"]
  node_fs["Filesystem APIs<br/>[FS.cpp]"]
  node_flashfs["Flash filesystems<br/>[LittleFS.cpp]"]
  node_preferences["Persistent preferences<br/>[Preferences.cpp]"]
end

node_sketch(("Sketch setup/loop"))
node_peer(("Network peer"))
node_device(("ESP32 hardware"))

node_main -->|"initializes via"| node_arduino
node_main -->|"dispatches setup/loop"| node_sketch
node_sketch -->|"uses APIs"| node_arduino
node_arduino -->|"exposes hardware"| node_hal
node_sketch -->|"uses buses"| node_wire
node_sketch -->|"uses USB"| node_usb
node_sketch -->|"manages networking"| node_network
node_sketch -->|"uses Wi-Fi"| node_wifi
node_sketch -->|"uses Ethernet"| node_eth
node_network -->|"resolves/connects"| node_peer
node_sketch -->|"sends requests"| node_http
node_http -->|"uses secure transport"| node_tls
node_http -->|"exchanges HTTP"| node_peer
node_sketch -->|"uses BLE"| node_ble
node_sketch -->|"uses Zigbee"| node_zigbee
node_sketch -->|"uses Thread"| node_openthread
node_sketch -->|"serves requests"| node_webserver
node_webserver -->|"handles HTTP"| node_peer
node_sketch -->|"models devices"| node_matter
node_sketch -->|"updates firmware"| node_ota
node_sketch -->|"reads/writes files"| node_fs
node_fs -.->|"mounts filesystem"| node_flashfs
node_sketch -->|"stores settings"| node_preferences
node_hal -->|"controls peripherals"| node_device

click node_main "https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp"
click node_arduino "https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Arduino.h"
click node_hal "https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal.h"
click node_wire "https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/src/Wire.cpp"
click node_usb "https://github.com/espressif/arduino-esp32/blob/master/libraries/USB/src/USBHID.cpp"
click node_network "https://github.com/espressif/arduino-esp32/blob/master/libraries/Network/src/NetworkManager.cpp"
click node_wifi "https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFi.cpp"
click node_eth "https://github.com/espressif/arduino-esp32/blob/master/libraries/Ethernet/src/ETH.cpp"
click node_http "https://github.com/espressif/arduino-esp32/blob/master/libraries/HTTPClient/src/HTTPClient.cpp"
click node_tls "https://github.com/espressif/arduino-esp32/blob/master/libraries/NetworkClientSecure/src/ssl_client.cpp"
click node_ble "https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/src/BLEDevice.cpp"
click node_zigbee "https://github.com/espressif/arduino-esp32/blob/master/libraries/Zigbee/src/ZigbeeHandlers.cpp"
click node_openthread "https://github.com/espressif/arduino-esp32/blob/master/libraries/OpenThread/src/OThread.cpp"
click node_webserver "https://github.com/espressif/arduino-esp32/blob/master/libraries/WebServer/src/WebServer.cpp"
click node_matter "https://github.com/espressif/arduino-esp32/blob/master/libraries/Matter/src/Matter.cpp"
click node_ota "https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/src/Updater.cpp"
click node_fs "https://github.com/espressif/arduino-esp32/blob/master/libraries/FS/src/FS.cpp"
click node_flashfs "https://github.com/espressif/arduino-esp32/blob/master/libraries/LittleFS/src/LittleFS.cpp"
click node_preferences "https://github.com/espressif/arduino-esp32/blob/master/libraries/Preferences/src/Preferences.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_arduino toneBlue
class node_hal,node_wire,node_usb toneAmber
class node_network,node_wifi,node_eth,node_http,node_tls,node_ble,node_zigbee,node_openthread toneMint
class node_webserver,node_matter,node_ota toneRose
class node_fs,node_flashfs,node_preferences,node_sketch,node_peer,node_device toneIndigo
```

## Components

### Sketch Runtime

- [Arduino startup](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/main.cpp): `cores/esp32/main.cpp`
- [Arduino API](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Arduino.h): `cores/esp32/Arduino.h`

### Hardware APIs

- [ESP32 HAL](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal.h): `cores/esp32/esp32-hal.h`
- [I2C and SPI](https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/src/Wire.cpp): `libraries/Wire/src/Wire.cpp`
- [USB device/host](https://github.com/espressif/arduino-esp32/blob/master/libraries/USB/src/USBHID.cpp): `libraries/USB/src/USBHID.cpp`

### Connectivity

- [Network manager](https://github.com/espressif/arduino-esp32/blob/master/libraries/Network/src/NetworkManager.cpp): `libraries/Network/src/NetworkManager.cpp`
- [Wi-Fi](https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFi.cpp): `libraries/WiFi/src/WiFi.cpp`
- [Ethernet](https://github.com/espressif/arduino-esp32/blob/master/libraries/Ethernet/src/ETH.cpp): `libraries/Ethernet/src/ETH.cpp`
- [HTTP client](https://github.com/espressif/arduino-esp32/blob/master/libraries/HTTPClient/src/HTTPClient.cpp): `libraries/HTTPClient/src/HTTPClient.cpp`
- [TLS transport](https://github.com/espressif/arduino-esp32/blob/master/libraries/NetworkClientSecure/src/ssl_client.cpp): `libraries/NetworkClientSecure/src/ssl_client.cpp`
- [Bluetooth LE](https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/src/BLEDevice.cpp): `libraries/BLE/src/BLEDevice.cpp`
- [Zigbee endpoints](https://github.com/espressif/arduino-esp32/blob/master/libraries/Zigbee/src/ZigbeeHandlers.cpp): `libraries/Zigbee/src/ZigbeeHandlers.cpp`
- [OpenThread](https://github.com/espressif/arduino-esp32/blob/master/libraries/OpenThread/src/OThread.cpp): `libraries/OpenThread/src/OThread.cpp`

### Device Services

- [HTTP server](https://github.com/espressif/arduino-esp32/blob/master/libraries/WebServer/src/WebServer.cpp): `libraries/WebServer/src/WebServer.cpp`
- [Matter devices](https://github.com/espressif/arduino-esp32/blob/master/libraries/Matter/src/Matter.cpp): `libraries/Matter/src/Matter.cpp`
- [Firmware updates](https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/src/Updater.cpp): `libraries/Update/src/Updater.cpp`

### Storage

- [Filesystem APIs](https://github.com/espressif/arduino-esp32/blob/master/libraries/FS/src/FS.cpp): `libraries/FS/src/FS.cpp`
- [Flash filesystems](https://github.com/espressif/arduino-esp32/blob/master/libraries/LittleFS/src/LittleFS.cpp): `libraries/LittleFS/src/LittleFS.cpp`
- [Persistent preferences](https://github.com/espressif/arduino-esp32/blob/master/libraries/Preferences/src/Preferences.cpp): `libraries/Preferences/src/Preferences.cpp`

### Other components

- **Sketch setup/loop**
- **Network peer**
- **ESP32 hardware**

## Connections

- Arduino startup → Arduino API: initializes via
- Arduino startup → Sketch setup/loop: dispatches setup/loop
- Sketch setup/loop → Arduino API: uses APIs
- Arduino API → ESP32 HAL: exposes hardware
- Sketch setup/loop → I2C and SPI: uses buses
- Sketch setup/loop → USB device/host: uses USB
- Sketch setup/loop → Network manager: manages networking
- Sketch setup/loop → Wi-Fi: uses Wi-Fi
- Sketch setup/loop → Ethernet: uses Ethernet
- Network manager → Network peer: resolves/connects
- Sketch setup/loop → HTTP client: sends requests
- HTTP client → TLS transport: uses secure transport
- HTTP client → Network peer: exchanges HTTP
- Sketch setup/loop → Bluetooth LE: uses BLE
- Sketch setup/loop → Zigbee endpoints: uses Zigbee
- Sketch setup/loop → OpenThread: uses Thread
- Sketch setup/loop → HTTP server: serves requests
- HTTP server → Network peer: handles HTTP
- Sketch setup/loop → Matter devices: models devices
- Sketch setup/loop → Firmware updates: updates firmware
- Sketch setup/loop → Filesystem APIs: reads/writes files
- Filesystem APIs → Flash filesystems: mounts filesystem
- Sketch setup/loop → Persistent preferences: stores settings
- ESP32 HAL → ESP32 hardware: controls peripherals
