An ESP32 board is a lightweight, cost-effective solution for projects requiring basic control, real-time processing, and wireless communication. It's ideal for simpler robotics or IoT applications where the full power of a single-board computer (SBC) like a Raspberry Pi isn't necessary.

Learn how to install the lightweight viam-micro-server which can run on resource-limited embedded systems, like the ESP32, that cannot run the fully-featured viam-server. The viam-micro-server is built from the micro-RDK.

Prerequisites

What You'll Learn

What You'll Need

What You'll Build

Watch the Video

Follow along with the step-by-step video.

  1. Connect your ESP32 board to your computer with a data cable. Make sure the cable is capable of data transfer (not just charging).
  2. In the Viam app, enter a name for a new machine, and Add machine. add machine
  3. Under the CONFIGURE tab, click the View setup instructions button. view setup instructions
  4. Select the platform you want to run on, ESP32. select ESP32 platform
  5. Select the platform of the computer you're using to flash the ESP32. The example shown below will be for a Mac, but the steps to follow for other operating systems is similar. select Mac
  6. Download the file for the viam-micro-server installer used to flash and monitor logs on your ESP32.
  7. Download the file for the machine credentials used to connect the ESP32 to the Viam app. download two files
  8. In the terminal window, navigate to the directory where the previous files downloaded. In the example shown below, files were downloaded to the ~/Downloads directory of the computer.
    $ cd ~/Downloads
    
  9. Copy the installation command from the setup instructions in the Viam app. code snippet
  10. Paste it into your terminal window at the command line prompt. Replace the <WIFI-SSID> placeholder (including the angle brackets<and>) with your own SSID.
    $ chmod 755 ./micro-rdk-installer-macos && ./micro-rdk-installer-macos write-flash --app-config viam-esp32-project-main.json --monitor --wifi-ssid "<WIFI-SSID>"
    
    edit command
  11. Run the command. Enter your WiFi password when prompted. If you receive a warning that the program is unsigned, go to Settings -> Privacy & Security and allow the application to run.
  12. When prompted to select your connection type, select /dev/cu.*. In most cases, including flashing firmware on the ESP32, you'll typically use cu (call-up) instead of tty (teletype). select connection type
  13. In the Viam app, wait for confirmation that your machine has successfully connected, and status is "Live". This might take a few minutes to complete depending on your connection. machine status is live
  1. Once the machine is connected, you can begin adding resources to control. For example, under the CONFIGURE tab, click the + icon in the left-hand menu and select Component. Select board, and find the esp32 module, and Create. This adds the module for working with the ESP32 board's GPIO pins. Leave the default name board-1 for now. add esp32 board component
  2. Notice adding this module adds the board hardware component called board-1. The collapsible card on the right corresponds to the part listed in the left sidebar. added board
  3. Within the board-1 card, expand the Attributes dropdown to see options to configure the board. Input 12 and Enter to configure GPIO pin 12.
  4. Click Save in the top right to save and apply your configuration changes.
  5. Under the CONTROL tab, you can see one hardware component called board-1 that you configured on the CONFIGURE tab. Enter 12 into the Pin field, select the Read mode, so you can Get information about that pin. get information from pin

What You Learned

Develop custom firmware

Once viam-micro-server is installed, you can use your ESP32 with all of Viam's 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 development setup guide to learn how to to customize viam-micro-server and create modules using Rust.

Related projects

You can also learn how to install viam-server on single-board computers and other devices.