viam-micro-server Installation Guide
To use Viam, you need to install either the viam-server
binary or viam-micro-server
.
viam-micro-server
is a lightweight version of viam-server
which can run on resource-limited embedded systems that cannot run the fully-featured viam-server
.
viam-micro-server
is built from the micro-RDK.
In this page
Platform requirements
The only microcontroller viam-micro-server
currently supports is the ESP32.
You need an Espressif ESP32 microcontroller to use viam-micro-server
.
Viam recommends purchasing the ESP32 with a development board.
The following ESP32 microcontrollers are supported:
- ESP32-WROVER Series
- ESP32-WROOM Series (until v0.1.7)
You will also need a data cable to connect the microcontroller to your development machine.
Your microcontroller should have at least the following resources available to work with viam-micro-server
:
- 2 Cores + 384kB SRAM + 2MB PSRAM + 4MB Flash
Tip
The main difference between the WROOM and WROVER is that the WROVER has additional RAM with the SPIRAM chip.
If you would like to allow more than one concurrent connection to your device we recommend using the WROVER.
The WROVER allows a max of 3 incoming gRPC connections (whether over HTTP2 or WebRTC).
You can change this max by building your own version of viam-micro-server
.
Proceed to install viam-micro-server
.
Install viam-micro-server
viam-micro-server
is the lightweight version of viam-server
that you can run on ESP32 microcontrollers.
BETA
viam-micro-server
is in beta mode and many features supported by viam-server
are still being added to viam-micro-server
.
Stability is not guaranteed.
Breaking changes are likely to occur, and occur often.
The viam-micro-server
installer is a CLI that allows you to flash a build of viam-micro-server
, along with your machine’s credentials and your wifi information, directly to your ESP32.
With this installation, you can use your ESP32 with all supported resource APIs, but you cannot write your own code directly interacting with the chip.
If you want to program the chip directly, follow the setup instructions in viam-micro-server
Development Setup instead.
Flash your ESP32 with the viam-micro-server
installer
If you have a compatible microcontroller, follow along with the steps outlined below to install viam-server
:
Go to the Viam app. Create an account if you haven’t already.
Add a new machine by providing a name in the New machine field and clicking Add machine:
Navigate to the CONFIGURE tab and find your machine’s card. An alert will be present directing you to Set up your machine part:
Click View setup instructions to open the setup instructions.
Select ESP32 as the platform you want to run on.
Select the platform you want to use from which to flash the target system.
Follow the instructions to use the
micro-rdk-installer
to flashviam-micro-server
to an ESP32 connected to your computer through a data cable.Once you have followed the steps on the setup instructions,
viam-micro-server
is installed and will run. Wait for confirmation that your microcontroller has successfully connected.On your machine’s page on the Viam app, your machine will show that it’s Live. If something is not working, see Troubleshooting.
For more micro-rdk-installer
CLI usage options, see GitHub.
For code examples and more information on viam-micro-server
, see GitHub.
Recommendations when using an SDK
As you use the ESP32, if you write control code, you may experience instability.
If the connection to the ESP32 with an SDK is unstable, we recommend the following changes to the default settings in your connection code.
This will disable the SDK background task that monitors the connection to viam-micro-server
, saving bandwidth.
# Replace the connect function found in the CONNECT tab with the following
async def connect():
opts = RobotClient.Options(
# viam-micro-server configures once at boot,
# so we don't need to check if the components have changed
refresh_interval=0,
# Checking the connection can safely be disabled
check_connection_interval=0,
# Same for Attempting to reconnect
attempt_reconnect_interval=0,
disable_sessions=True,
# viam-micro-server doesn't support sessions
# so it is safe to disable them
dial_options=DialOptions.with_api_key(
# Replace "<API-KEY-ID>" (including brackets)
# with your machine's api key id
api_key_id='<API-KEY-ID>',
# Replace "<API-KEY>" (including brackets)
# with your machine's api key
api_key='<API-KEY>')
)
# Replace "<ROBOT-URL>" (including brackets) with your machine's url
return await RobotClient.at_address('<ROBOT-URL>', opts)
// Replace the call to client.New with the following block
robot, err := client.New(
context.Background(),
"<ROBOT-URL>", // Replace "<ROBOT-URL>" (including brackets) with your machine's url
logger,
client.WithDisableSessions(), // viam-micro-server doesn't support sessions so it is safe to disable them
client.WithCheckConnectedEvery(0), // Checking the connection can safely be disabled
client.WithReconnectEvery(0), // Same for Attempting to reconnect
client.WithRefreshEvery(0), // viam-micro-server configures once at boot, so we don't need to check if the components have changed
client.WithDialOptions(rpc.WithEntityCredentials(
// Replace "<API-KEY-ID>" (including brackets) with your machine's api key id
"<API-KEY-ID>",
rpc.Credentials{
Type: rpc.CredentialsTypeAPIKey,
// Replace "<API-KEY>" (including brackets) with your machine's api key
Payload: "<API-KEY>",
})),
)
if err != nil {
logger.Fatal(err)
}
Next steps
Troubleshooting
Error: IceTransportClosed
If you are trying to connect to an ESP32 and the connection is unstable with the repeating error E (412486) micro_rdk::common::webrtc::ice: closing ice agent with error IceTransportClosed
, you have opened too many connections to the ESP32, which has a maximum of 3 connections by default.
Make sure you only have one tab with your machine’s page open to limit the number of connections to your ESP32.
Linux port permissions
If a “Permission Denied” or similar port error occurs, first check the connection of the ESP32 to the machine’s USB port.
If connected and the error persists, run sudo usermod -a -G dialout $USER
to add the current user to the dialout
group, restart your terminal, and try again.
MacOS executable permissions
When using a machine running a version of MacOS, the user is blocked from running the executable by default. To fix this, Control+Click the binary in Finder and then, in the following two prompts select Open. Close whatever terminal window this opens to be able to run the installer.
Error: FlashConnect
This may occur because the serial port chosen if/when prompted is incorrect. However, if the correct port has been selected, try the following:
- Run the installer as explained above.
- When prompted to select a serial port:
- Hold down the “EN” or enable button on your ESP32.
- With the above button held down, select the correct serial port.
- Press and hold down the “EN” and “Boot” buttons at the same time. Then release both.
You can find additional assistance in the Troubleshooting section.
You can also ask questions in the Community Discord and we will be happy to help.
Ubuntu not recognizing the microcontroller
If you’re trying to connect a microcontroller using serial port to an Ubuntu system and the computer doesn’t seem to be recognizing the microcontroller, check if the brltty
service or its secondary service brltty-udev
are active (brltty
is a service installed by default that provides access to a braille display):
sudo systemctl status | grep brltty
brltty-udev.service loaded active running Braille Device Support
It is a known issue that this service takes ownership of cp210x devices that are used in serial communication with microcontrollers.
To disable the services, run the following:
sudo systemctl stop brltty-udev.service
sudo systemctl mask brltty-udev.service
sudo systemctl stop brltty.service
sudo systemctl disable brltty.service
You may also need to reboot your system, and/or unplug the cable from the computer and re-plug it in.
See this blog post and Ubuntu bug report for more.
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!