Modular resource and module configuration details
This page contains reference material. For quick instructions on configuring a module on your machine, see Configure hardware on your machine.
Modular resource configuration details
The modular resource card allows you to configure attributes for the resource.
The following image shows an example of a configured modular resource, specifically an ultrasonic sensor component.
This modular component is made available by the ultrasonic
module.
See module configuration.

{
"name": "sensor-1",
"model": "viam:ultrasonic:sensor",
"api": "rdk:component:sensor",
"attributes": {
"trigger_pin": "13",
"echo_interrupt_pin": "15",
"board": "board-1",
"timeout_ms": 500
},
"depends_on": []
}
{
"name": "<your-model-instance-name>",
"model": "<namespace>:<module-name>:<model-name>",
"api": "<model-API-namespace>:<component|service>:<model-name>",
"attributes": {
"<relevant attributes--see module Readme>"
},
"depends_on": []
}
The following properties are available for modular resources:
Name | Type | Required? | Description |
---|---|---|---|
attributes | object | Sometimes Required | Any configuration attributes for your model Check the module’s GitHub Readme for information about available configuration attributes for a resource. |
name | string | Required | What you want to name this instance of your modular resource. |
api | string | Required | The API namespace triplet. |
model | string | Required | The full model namespace triplet of the modular resource’s model. |
depends_on | array | Optional | The name of components you want to confirm are available on your machine alongside your modular resource. Often a board. Unnecessary if you coded implicit dependencies. |
Module configuration details
The following image shows an example of a configured module in a machine’s config.
This ultrasonic sensor in the previous section is provided by the ultrasonic
module shown here.

Examples:
"modules": [
{
"type": "registry",
"name": "viam_ultrasonic",
"module_id": "viam:ultrasonic",
"version": "0.0.2"
},
{
"type": "registry",
"name": "viam_tflite_cpu",
"module_id": "viam:tflite_cpu",
"version": "latest"
},
{
"type": "registry",
"name": "viam_raspberry-pi",
"module_id": "viam:raspberry-pi",
"version": "1.1.0"
},
]
The config of both a module and a corresponding modular resource resembles the following:
{
"components": [
{
"name": "<your-model-instance-name>",
"model": "<module-namespace>:<module-name>:<model-name>",
"api": "<model-API-namespace>:<component|service>:<model-name>",
"attributes": {}
}
],
"modules": [
{
"type": "registry",
"name": "<module-namespace>_<module-name>",
"module_id": "<module-namespace>:<module-name>",
"version": "<module-version>",
"env": {
"MY_VAR": "<some-value>",
"PATH": "<example-folder>:${environment.PATH}"
}
}
]
}
The following is an example configuration for the Intel Realsense module.
The configuration adds viam:camera:realsense
as a modular resource from the module viam:realsense
.
The model is configured as a component with the name myRealsenseCamera1
.
{
"components": [
{
"name": "myRealsenseCamera1",
"model": "viam:camera:realsense",
"api": "rdk:component:camera",
"attributes": {
"sensors": ["color", "depth"]
},
"depends_on": []
}
],
"modules": [
{
"type": "registry",
"name": "viam_realsense",
"module_id": "viam:realsense",
"version": "0.0.11"
}
]
}
The following properties are configurable for each module.
You can add and edit env
by switching from Builder to JSON mode in the CONFIGURE tab.
Name | Type | Required? | Description |
---|---|---|---|
version | string | Required | You can specify:
|
type | string | Required | registry or local , depending on whether the module is in the Viam Registry or is only available locally on your computer. |
module_id | string | Required | The module author’s organization namespace or UUID, then a colon, then the name of the module. Identical to the first two pieces of the model namespace triplet. <module namespace>:<module name> . |
name | string | Required | A name for this instance of the module. |
env | object | Optional | Environment variables available to the module. For example { "API_KEY": "${environment.API_KEY}" } . Some modules require that you set environment variables as part of configuration. Check the module’s readme for more information. See environment variables. |
Module versioning
You can configure how each module on your machine updates itself when a newer version becomes available from the Viam Registry. By default, a newly-added module is set to pin to the latest release (Latest) of the version you added.
To change the update strategy for your module, set the Pinned version type for your module in its module card on the CONFIGURE tab.

The following update options are available:
- Patch (X.Y.Z): Do not update to any other version.
- Minor (X.Y.*): Only update to newer patch releases of the same minor release branch.
The module will automatically restart and update itself whenever new updates within the same minor release are available in the Viam Registry.
For example, use this option to permit a module with version
1.2.3
to update to version1.2.4
or1.2.5
but not1.3.0
or2.0.0
. - Major (X.*): Only update to newer minor releases of the same major release branch.
The module will automatically restart and update itself whenever new updates within the same major release are available in the Viam Registry.
For example, use this option to permit a module with version
1.2.3
to update to version1.2.4
or1.3.0
but not2.0.0
or3.0.0
. - Latest (
latest
): Always update to the latest version of this module available from the Viam Registry as soon as a new version becomes available. This is the default. - Latest with prerelease (
latest-with-prerelease
): Always update to the latest release or prerelease version of this module available from the Viam Registry as soon as the new version becomes available.
When using the Patch (X.Y.Z) version type, you may select any patch version of the module from the Version dropdown menu, including past versions if desired.
The current deployed version of your module and the latest version of that module available from the Viam Registry are shown on this module card for your reference.
Caution
For any version type other than Patch (X.Y.Z), the module will upgrade as soon as an update that matches that specified version type is available, which will restart the module. If, for example, the module provides a motor component, and the motor is running, it will stop while the module upgrades.
Environment variables
Each module has access to the following default environment variables. Not all of these variables are automatically available on local modules; you can manually set variables your module requires if necessary.
Name | Description | Automatically set on local modules? |
---|---|---|
VIAM_HOME | The root of the viam-server configuration.Default for Linux, macOS, and WSL: Default for Windows: | |
VIAM_MODULE_ROOT | The root of the module install directory. The module process uses this directory as its current working directory (cwd ). This variable is useful for file navigation that is relative to the root of the module.Example: | |
VIAM_RESOURCE_CONFIGURATION_TIMEOUT | Duration that resources are allowed to configure or reconfigure. Example: 4m0s Default: 1 minute. | |
VIAM_MODULE_STARTUP_TIMEOUT | Duration that modules are allowed to start up. Example: 7m15s Default: 5 minutes. | |
VIAM_MODULE_DATA | A persistent folder location a module can use to store data across reboots and versions. This location is a good place to store python virtual environments. Example: | |
VIAM_MODULE_ID | The module ID of the module. Example: viam:realsense | |
VIAM_API_KEY | An API key with access to the machine where this instance of the module is running. | |
VIAM_API_KEY_ID | The ID of the API key with access to the machine where this instance of the module is running. | |
VIAM_MACHINE_PART_ID | The ID of the part where this instance of the module is running. | |
VIAM_MACHINE_ID | The ID of the machine where this instance of the module is running. | |
VIAM_MACHINE_FQDN | The fully qualified domain name of the machine where this instance of the module is running. | |
VIAM_LOCATION_ID | The ID of the location that owns the machine where this instance of the module is running. | |
VIAM_PRIMARY_ORG_ID | The ID of the organization that owns the machine where this instance of the module is running. |
Set additional environment variables
You can configure additional environment variables for your module, using your choice of variable name and value.
For example, you could create a variable MODULE_USER
with a string value:
{
"modules": [
{
...
"env": {
"MODULE_USER": "my-username"
}
}
]
}
To access any system environment variable that viam-server
has access to, use the notation ${environment.<ENV-VAR-NAME>}
where <ENV-VAR-NAME>
represents a system environment variable, like PATH
, USER
, or PWD
.
For example, you can use ${environment.HOME}
to access the HOME
environment variable for the user running viam-server
:
{
"modules": [
{
...
"env": {
"PATH": "/home/username/bin:${environment.PATH}"
}
}
]
}
Access environment variables from your module
You can access module environment variables from within your module code in the same way you would access any other environment variables.
For example, you could use the following Python code to access the VIAM_HOME
variable:
import os
viam_home = os.environ.get("VIAM_HOME")
Configure an unlisted module
To configure a module that is uploaded to the Viam Registry but has visibility set to Unlisted, you need to manually add the module to your configuration:
Navigate to the module’s page in the Viam Registry, using the link to the module.
Find the Unlisted module usage section.
Copy the module configuration JSON snippet.
In the Viam app, navigate to the CONFIGURE tab of the machine you want to configure.
Switch to JSON mode.
Paste the copied module configuration into your
modules
array.Copy the model configuration snippet for the model you want to use, and add it to your
components
orservices
array (as appropriate). For example:"components": [ { "name": "sensor-1", "api": "rdk:component:sensor", "model": "jessamy:hello-world:hello-camera", "attributes": {} }, ... ], "modules": [ { "type": "registry", "name": "jessamyhello-world", "module_id": "jessamy:hello-world", "version": "latest" } ]
"<components|services>": [ { "name": "<resource-name>", "api": "<model-API-namespace>:<component|service>:<model-name>", "model": "<module-namespace>:<module-name>:<model-name>", "attributes": {} } ], "modules": [ { "type": "registry", "name": "<module-namespace><module-name>", "module_id": "<module-namespace>:<module-name>", "version": "latest" } ]
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!