# Overview

Everything inside a Kode Dot on one page: the two chips, the screen, the sensors, the radios and the ports, with the page that documents each one.

## What it is

A Kode Dot is a pocket computer with the hardware already wired: a screen you
touch, six buttons, sensors that know how it is moving, a microphone and a
speaker, three short-range radios, a battery, a microSD slot and a header to
plug your own hardware into. Two chips run it. The ESP32-P4 is the one your
code runs on and the one every part below answers to; the ESP32-C5 beside it
is the Wi-Fi and Bluetooth radio, and a few things that never reach the P4
hang off it too.

This section is one page per part. Each page says what the part does, how
it is wired to the P4, what its numbers are, what goes wrong, and ends with
a program you can paste and run.

## How it is connected

```mermaid
flowchart LR
  p4["ESP32-P4"]
  p4 -- "I2C, GPIO4/5" --> i2c["Shared I2C bus"]
  i2c --> imu["QMI8658A 0x6A"]
  i2c --> mag["QMC5883P 0x2C"]
  i2c --> codec["ES8311 0x18"]
  i2c --> exp["TCA6408 0x20"]
  i2c --> led["KTD2026 0x30"]
  i2c --> pmic["BQ25896 0x6B"]
  i2c --> gauge["CW2217 0x64"]
  i2c --> hap["AW86233 0x5A"]
  i2c --> touch["Touch 0x15 / 0x5A"]
  p4 -- "MIPI-DSI" --> panel["AMOLED"]
  p4 -- "SDIO" --> sd["microSD"]
  p4 -- "SDIO + UART" --> c5["ESP32-C5"]
  p4 -- "SPI" --> nfc["ST25R3916B"]
```

*One shared I2C bus carries most of the board; the screen, the card and the radio have buses of their own*

Most parts sit on one I2C bus, `GPIO4` for data and `GPIO5` for clock at
400 kHz, which `kode_bsp_init` brings up and owns. The screen has its own
MIPI-DSI link, the microSD its own SDIO bus, the NFC reader an SPI bus, and
the C5 a second SDIO bus plus a UART. The infrared pair and the 125 kHz RFID
front end are plain GPIOs on the P4's RMT, LEDC and ADC.

Two boards make the device: the main board with the chips and most parts,
and an antenna board behind the back of the case with NFC, RFID, the haptic
driver and the magnetic connector, joined by a 20-way flex that carries SPI,
I2C and power. That is why a part on the antenna board answers on the same
bus as everything else.

## The parts

| Part | What it is | Page |
| --- | --- | --- |
| Two chips | ESP32-P4 for your code, ESP32-C5 for Wi-Fi and Bluetooth, and what each one owns | `device/soc` |
| Buttons | A four-way pad and two singles, five through an expander and one on a pin | `device/input` |
| Status LED | One RGB LED behind a KTD2026 current driver | `device/led` |
| microSD card | A slot on 4-bit SDIO, powered from the C5 | `device/storage` |
| Display | A 2.06-inch AMOLED, 410 by 502, with capacitive touch, over MIPI-DSI | `device/display` |
| Motion | A QMI8658A accelerometer and gyroscope, and a QMC5883P compass | `device/motion/overview` |
| Audio | An ES8311 codec, a microphone and a speaker behind an NS4150B amplifier | `device/audio/overview` |
| Haptic motor | A linear resonant actuator behind an AW86233 driver | `device/haptic` |
| Infrared | Two emitters and a 38 kHz receiver on the RMT peripheral | `device/infrared` |
| NFC | An ST25R3916B reader at 13.56 MHz on the antenna board | `device/nfc` |
| RFID | A 125 kHz front end with no reader chip: the P4 makes the field | `device/rfid` |
| Power and battery | A BQ25896 charger, a CW2217 fuel gauge, USB-C in and 5 V out | `device/power` |
| Expansion | The 20-pin header with 14 GPIOs, and the four magnetic pads that carry USB | `device/expansion` |

## Specifications

The I2C addresses, which are what you write code against. They come from the
production board's own design, revision V1.

| Part | Address |
| --- | --- |
| Bus | `SDA` `GPIO4`, `SCL` `GPIO5`, 400 kHz. Expander interrupt on `GPIO6` |
| QMI8658A, accelerometer and gyroscope | `0x6A` |
| QMC5883P, compass | `0x2C` |
| ES8311, audio codec | `0x18` |
| TCA6408, buttons and panel power | `0x20` |
| KTD2026, LED driver | `0x30` |
| BQ25896, charger | `0x6B` |
| CW2217, fuel gauge | `0x64` |
| AW86233, haptic driver | `0x5A` |
| CST820 or CST916E, touch | `0x15` or `0x5A`, by panel supplier |

## Gotchas

> **WARNING**
>
> **Touch works on one board and not on another.** Two panel suppliers ship the
> same display behind different touch controllers, at `0x15` or `0x5A`. Do not
> hardcode one: probe both at start-up and bind whichever answers, as
> `kode_bsp_init` does. Bind one by hand and touch is dead on every board from
> the other supplier.

> **WARNING**
>
> **The microSD and the speaker both went missing at once.** Both depend on the
> C5: it powers the card and it enables the amplifier. When the two fail
> together, look at what the C5 is running before you open a storage or audio
> driver.

> **NOTE**
>
> **There is no sub-GHz radio in a Kode Dot.** Wi-Fi and Bluetooth are on the
> C5; sub-GHz and LoRa are on the modules that carry them, see
> `modules/overview`. Nothing connects to a network until your app brings the
> radio up.

## In the SDK

- [`kbsp`](https://github.com/kodediy/kode-sdk/tree/main/components/kbsp): the board support package in `kode-sdk`, which brings the bus and the panel up.
- [`kdrv`](https://github.com/kodediy/kode-sdk/tree/main/components/kdrv): one driver per part, linked from each part's page.
