Previous
Create a mobile app
To write control logic for your machine that will run without a user interface, you can use the Python, Go, or C++ SDK. The SDKs each include similar methods to hit Viam’s gRPC API endpoints.
You can run your code directly on the machine’s single-board computer (SBC), or you can run it from a separate computer connected to the internet or to the same local network as your machine’s SBC or microcontroller.
We recommend running your code on a laptop, desktop, or server if:
The client code will establish a connection to the instance of viam-server
on your machine’s SBC over LAN or WAN.
We recommend running your code on the SBC that directly controls your hardware if:
Install your preferred Viam SDK on the computer or SBC where you plan to run the control script.
If you are using the Python SDK, set up a virtual environment to package the SDK inside before running your code, avoiding conflicts with other projects or your system.
For macOS (both Intel x86_64
and Apple Silicon) or Linux (x86
, aarch64
, armv6l
), run the following commands:
Windows is not supported. If you are using Windows, use the Windows Subsystem for Linux (WSL) and install the Python SDK using the preceding instructions for Linux. For other unsupported systems, see Installing from source.
If you intend to use the ML (machine learning) model service, use the following command instead, which installs additional required dependencies along with the Python SDK:
Run the following command to install the Viam Go SDK:
Follow the instructions on the GitHub repository.
You can find sample connection code on each machine’s CONNECT tab in the Viam app. Select your preferred Language to display a code snippet, with connection code as well as some calls to the APIs of the resources you’ve configured on your machine.
You can use the toggle to include the machine API key and API key ID, though we strongly recommend storing your API keys in environment variables to reduce the risk of accidentally sharing your API key and granting access to your machines.
If your code will connect to multiple machines or use Platform APIs you can create an API key with broader access.
For API reference including code snippets for each method, see Viam’s Client APIs.
You can run your code manually from your terminal, or you can automatically run it each time your machine starts.
To run your code on a laptop or desktop, or to run it on your machine’s SBC manually for testing purposes, execute the following command in a terminal:
To run your control code on your machine, create a module and deploy it to your machine.
You can add functionality to the DoCommand()
method to, for example, start and stop the control code.
For more information, see Create a module with machine control logic.
Read and filter a machine’s logs to view updates from your machine’s viam-server
instance and troubleshoot issues with your program.
Navigate to the LOGS tab of your machine’s page in the Viam app.
Select from the Levels dropdown menu to filter the logs by severity level:
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!