Previous
Lifecycle of a module
If your physical or virtual hardware is not supported by an existing registry module, you can create a new module to add support for it.
This tutorial series walks you through creating a custom module in Python or Go.
In this tutorial series, you’ll create a hello-world module with two models:
hello-camera): Returns an image from a configured file path on your machinehello-sensor): Returns a random numberYou’ll learn how to:
Before you start, it’s important to understand the terminology:
Module = A package that contains one or more models
hello-world moduleModel = A specific implementation of a Viam component API
exampleorg:hello-world:hello-cameraComponent = An instance of a model configured on a machine
In this tutorial:
hello-world (the package)hello-camera (implements Camera API)hello-sensor (implements Sensor API)camera-1, camera-2, sensor-1, etc. using these modelsEach model can only implement one API. Since our example hardware has two capabilities (returning images and returning numbers), and the Camera API can’t return numbers while the Sensor API can’t return images, we need two separate models in the same module.
This tutorial is divided into 5 parts:
| Part | Time | What you’ll do |
|---|---|---|
| Part 1: Prerequisites and setup | 15-20 min | Install CLI, set up your development environment, understand module architecture |
| Part 2: Choose an API and generate code | 15 min | Select the right API for your hardware, generate module structure with CLI |
| Part 3: Implement your module | 30-40 min | Implement configuration validation, reconfiguration, and API methods |
| Part 4: Test your module locally | 20 min | Use hot reload to test your module on a real machine |
| Part 5: Multiple models | 20-25 min | (Advanced) Add a second model to your module |
Total time: ~2 hours | Difficulty: Intermediate
Before you begin, make sure you have:
viam-serverSee Part 1 for detailed setup instructions.
Create a module when:
graph TD
A[Choose API] --> B[Generate Code]
B --> C[Implement]
C --> D[Test Locally]
D --> E[Deploy]
E --> F[Share]
For different hardware platforms:
For different module types:
Ready to create your first module?
Begin Part 1: Prerequisites and setup →
Once you complete this tutorial:
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!