|
| 1 | +# Custom Hardware |
| 2 | + |
| 3 | +Example of connecting to a LiveKit room with bidirectional audio on custom ESP32-S3 hardware. Unlike the `minimal` example (which uses the `codec_board` abstraction), this example manually initializes I2C, I2S, and audio codecs (ES8311 + ES7210) using pin assignments extracted from the board schematic. Use this as a starting point when your board isn't supported by `codec_board`. |
| 4 | + |
| 5 | +The [Waveshare ESP32-S3-Touch-LCD-1.83](https://www.waveshare.com/esp32-s3-touch-lcd-1.83.htm) is used as a concrete example, but the approach works for any ESP32-S3 board with I2S audio codecs — just update the pin definitions and codec configuration in `board.c`. |
| 6 | + |
| 7 | +For a step-by-step walkthrough of this example, see the companion blog post: [Building a voice agent frontend on custom ESP32 hardware](https://livekit.io/blog/esp32-custom-hardware-quickstart). |
| 8 | + |
| 9 | +## Configuration |
| 10 | + |
| 11 | +> [!TIP] |
| 12 | +> Options can either be set through *menuconfig* or added to *sdkconfig* as shown below. |
| 13 | +
|
| 14 | +### Credentials |
| 15 | + |
| 16 | +**Option A**: Use a LiveKit Sandbox to get up and running quickly. Setup a LiveKit Sandbox from your [Cloud Project](https://cloud.livekit.io/projects/p_/sandbox), and use its ID in your configuration: |
| 17 | + |
| 18 | +```ini |
| 19 | +CONFIG_LK_EXAMPLE_USE_SANDBOX=y |
| 20 | +CONFIG_LK_EXAMPLE_SANDBOX_ID="my-project-xxxxxx" |
| 21 | +``` |
| 22 | + |
| 23 | +**Option B**: Specify a server URL and pregenerated token: |
| 24 | + |
| 25 | +```ini |
| 26 | +CONFIG_LK_EXAMPLE_USE_PREGENERATED=y |
| 27 | +CONFIG_LK_EXAMPLE_TOKEN="your-jwt-token" |
| 28 | +CONFIG_LK_EXAMPLE_SERVER_URL="ws://localhost:7880" |
| 29 | +``` |
| 30 | + |
| 31 | +### Network |
| 32 | + |
| 33 | +Connect using WiFi as follows: |
| 34 | + |
| 35 | +```ini |
| 36 | +CONFIG_LK_EXAMPLE_USE_WIFI=y |
| 37 | +CONFIG_LK_EXAMPLE_WIFI_SSID="<your SSID>" |
| 38 | +CONFIG_LK_EXAMPLE_WIFI_PASSWORD="<your password>" |
| 39 | +``` |
| 40 | + |
| 41 | +> **Note:** The ESP32-S3 only supports 2.4 GHz WiFi. |
| 42 | +
|
| 43 | +### Board adaptation |
| 44 | + |
| 45 | +This example is configured for the Waveshare ESP32-S3-Touch-LCD-1.83. To adapt it to your own board: |
| 46 | + |
| 47 | +1. Update the pin definitions at the top of `main/board.c` (I2C, I2S, PA enable). |
| 48 | +2. Update the codec I2C addresses if your board uses different address strapping. |
| 49 | +3. If your board has no PMU, remove the `init_pmu()` call from `board_init()`. |
| 50 | +4. If your board uses different codecs, replace the ES8311/ES7210 initialization with the appropriate driver calls. |
| 51 | + |
| 52 | +## Build & Flash |
| 53 | + |
| 54 | +Navigate to this directory in your terminal. Run the following command to build your application, flash it to your board, and monitor serial output: |
| 55 | + |
| 56 | +```sh |
| 57 | +idf.py flash monitor |
| 58 | +``` |
| 59 | + |
| 60 | +Once running, the example will establish a network connection, connect to a LiveKit room, and print the following message: |
| 61 | + |
| 62 | +```txt |
| 63 | +I (3200) livekit_example: Room state changed: CONNECTED |
| 64 | +``` |
| 65 | + |
| 66 | +## Next Steps |
| 67 | + |
| 68 | +With a room connection established, you can connect another client (another ESP32, [LiveKit Meet](https://meet.livekit.io), etc.) or dispatch an [agent](https://docs.livekit.io/agents/) to talk with. |
0 commit comments