Skip to main content

Board Configuration

To target a specific hardware board or peripherical, you need to configure the pins, I2C, SPI, etc... This is done by loading the board configuration package for your specific hardware.

The inserted board configuration exposes a pins object that you can use to configure drivers.

import { pins } from "@dsboard/adafruit_qt_py_c3"
tip

In Visual Studio Code, on the file menu, click on the wand icon and select the board configuration. If your board is already connectd, DeviceScript will automatically detect it and load the correct board configuration.

Once the board configuration is imported, you can use the pins export to reference named pins from the board

import { pins } from "@dsboard/adafruit_qt_py_c3"
import { startLightBulb } from "@devicescript/servers"

const lightBulb = startLightBulb({
pin: pins.A0_D0,
})

Available Boards

You can find the list of supported devices and configuration in the devices catalog.

If your board system-on-chip (SoC) is supported (ESP32, RP2040, ...) but the pin configuration is not yet available, you have 2 options: create a new board configuration file or configure the board by code.

Configuration by Code

Some board configuration are generic and the I2C pins are not configured by default. For example, the pico-w board configuration does not configure the I2C pins and the code below configure them by code.

You can configure the board by code using the configureHardware function.

I2C

import { pins } from "@dsboard/pico_w"
import { configureHardware } from "@devicescript/servers"

configureHardware({
i2c: {
pinSDA: pins.GP4,
pinSCL: pins.GP5,
},
})

Configuration by file

This is a more advanced scenario where you want to fork an existing board configuration and publish configuration for a different board.

Refer to the Add board documentation to learn how to create a new board configuration file.