Skip to content
php-baremetal REGISTRY
Publish a package

php-baremetal/boards-seeed

bm-boards MIT

Board files of the Seeed Studio XIAO boards for php-baremetal: chip, memory, console, pin names and the on-board peripherals with their pins.

needs no platform HAL

boards-seeed · ESP32-S3

Seeed Studio XIAO ESP32-S3

The Seeed Studio XIAO ESP32-S3: ESP32-S3R8, 8 MB flash, 8 MB octal PSRAM, Wi-Fi, an I2C bus on D4/D5 and the XIAO pin names as PHP constants.

Board id seeed-xiao-esp32s3, file boards/esp32/seeed-xiao-esp32s3.json. Seeed Studio documents the board in its wiki.

Property Value
Chip ESP32-S3R8 (esp32s3)
PSRAM octal, 8 MB (in the chip)
Flash 8 MB
Console usb-jtag (native USB, USB-C connector)

This file describes the plain XIAO ESP32-S3. The Sense version (camera, microphone, microSD slot on the expansion board) and the Plus version (16 MB of flash, more pins) are different boards and are not in this package.

Pins

The pins key of the board file names the GPIOs as the board and the Arduino core name them. The values are GPIO numbers of the ESP32-S3, taken from variants/XIAO_ESP32S3/pins_arduino.h of the Arduino ESP32 core.

Name GPIO Also
D0 1 A0, T1
D1 2 A1, T2
D2 3 A2, T3
D3 4 A3, T4
D4 5 A4, T5, SDA
D5 6 A5, T6, SCL
D6 43 TX
D7 44 RX, SS
D8 7 A8, T7, SCK
D9 8 A9, T8, MISO
D10 9 A10, T9, MOSI
LED_BUILTIN 21

Every name in the "Also" column is a constant of its own with the same GPIO: Pin::SDA === Pin::D4. There is no A6 or A7: D6 and D7 are not analog pins, and the core skips those names.

Use the pins from PHP

The firmware registers Baremetal\Board\Pin, a final class with one integer constant per name of the table. Any function that takes a GPIO number takes them, such as gpio_mode(), gpio_write() and gpio_read() of ext-gpio.

The user LED (yellow, GPIO 21) is active-low, as the Seeed Studio wiki states: it lights when the pin is low and goes off when it is high.

php main.php, blink the user LED
<?php
use Baremetal\Board\Pin;

function setup(): void
{
    gpio_mode(Pin::LED_BUILTIN, GPIO_OUTPUT);
    gpio_write(Pin::LED_BUILTIN, 1); // off
}

function loop(int $tick): void
{
    gpio_write(Pin::LED_BUILTIN, $tick % 2);
    delay(500); // ext-sys
}

With the SDK option board-constants set to global (in extra.baremetal.options), the names are also global constants and the script can drop the class:

php main.php, with board-constants: global
<?php
function setup(): void
{
    gpio_mode(D10, GPIO_OUTPUT);
    gpio_mode(D0, GPIO_INPUT);
}

function loop(int $tick): void
{
    gpio_write(D10, gpio_read(D0));
}

Blocks

Block Type Keys Handled by Notes
network wifi none the SDK + ext-wifi The script connects with ext-wifi. The board has a U.FL connector for the external antenna.
i2c i2c sda D4 (GPIO 5), scl D5 (GPIO 6) ext-i2c Bus::onboard(); the XIAO's I2C pins.

The i2c block names its pins: the SDK replaces "D4" and "D5" with their GPIO numbers from pins when it loads the board. The keys are described in Board files; a project changes them with board overrides, where pin names work as well ("sda": "D2").

Use it in a project

bash in the project folder
composer require php-baremetal/boards-seeed
composer require php-baremetal/ext-gpio php-baremetal/ext-wifi php-baremetal/ext-i2c   # what you use
json composer.json, extra.baremetal
{
  "sdk": "esp32@^2.0",
  "board": "seeed-xiao-esp32s3",
  "runtime": "init-loop",
  "storage": "embedded"
}

Install only the drivers of the blocks the program uses: a block without its driver is left alone. The pin names need no package.

Notes

  • SS is GPIO 44, the same pin as D7 and RX, as the Arduino core defines it.
  • The console is the chip's native USB port (USB-Serial-JTAG), not a UART on D6/D7 (TX/RX).
  • The charge LED is wired to the battery charger, not to a GPIO.

Related