Board Component

The board component provides an API for setting GPIO pins to high or low, setting PWM, and working with analog and digital interrupts.

If you have GPIO pins you wish to control, use a board component.

Your GPIO pins can be present as:

  • The GPIO pins on a single-board computer (SBC).
  • A GPIO peripheral device that must connect to an external computer.
  • A PWM peripheral device that must connect to an SBC that has a CPU and GPIO pins.

In other words, the board of a machine is its signal wire hub. Signaling controls the flow of electricity to these pins to change their state between “high” (active) and “low” (inactive), and to send digital signals to and from other hardware.

Configuration

To use GPIO pins, you need to add a board component to your machine’s configuration. Go to your machine’s CONFIGURE page, and add a model that supports your board.

The following list shows the available board models. If your board is not among them, you may be able to use the pins on your board with an experimental periph.io-based modular component. This works for boards such as the RockPi S.

For additional configuration information, click on the model name:

Model
Description
ModelDescription
esp32An ESP32 microcontroller

API

The board API supports the following methods:

Method NameDescriptionviam-micro-server Support
SetGPIOSet the digital signal output of this pin to low (0V) or high (active, >0V).

GetGPIOGet if the digital signal output of this pin is high (active, >0V).

GetPWMGet the pin’s pulse-width modulation (PWM) duty cycle: a float [0.0, 1.0] representing the percentage of time the digital signal output by this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency).

SetPWMSet the pin’s Pulse-width modulation (PWM) duty cycle: a float [0.0, 1.0] indicating the percentage of time the digital signal output of this pin is in the high state (active, >0V) relative to the interval period of the PWM signal (interval period being the mathematical inverse of the PWM frequency).

PWMFrequencyGet the PWM frequency of the GPIO pin.

SetPWMFrequencySet the pin to the given PWM frequency (in Hz). When frequency is 0, it will use the board’s default PWM frequency.

GetDigitalInterruptValueGet the current value of a configured digital interrupt.

ReadAnalogReaderRead the current integer value of the digital signal output by the ADC.

WriteAnalogWrite an analog value to a pin on the board.

StreamTicksStart a stream of DigitalInterrupt ticks.

SetPowerModeSet the board to the indicated PowerMode.

AnalogByNameGet a configured Analog by name.

DigitalInterruptByNameGet a DigitalInterrupt by name.

GPIOPinByNameGet a GPIOPin by pin number.

GetGeometriesGet all the geometries associated with the board in its current configuration, in the frame of the board.

ReconfigureReconfigure this resource.

DoCommandExecute model-specific commands that are not otherwise defined by the component API.

NameGet the name of the digital interrupt.

GetResourceNameGet the ResourceName for this board with the given name.

CloseSafely shut down the resource and prevent further use.

Troubleshooting

If your board is not working as expected, follow these steps:

  1. Check your machine logs on the LOGS tab to check for errors.
  2. Review your board model’s documentation to ensure you have configured all required attributes.
  3. Check that all wires are securely connected.
  4. Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the board there.

If none of these steps work, reach out to us on the Community Discord and we will be happy to help.

Next steps

For general configuration and development info, see: