Collect images or sensor data in 2 minutes

Follow this guide to start collecting images or sensor data from your machine using the data management service.

Requirements

  • A Linux or macOS computer:
    • A single-board computer (SBC) such as a Raspberry Pi, OR
    • A laptop or desktop
  • A camera or a sensor. Options:
    • The webcam built into your computer
    • A USB webcam connected to your computer or SBC
    • A sensor (such as a temperature sensor) wired to your single-board computer’s GPIO pins

Instructions

Select a tab below to collect images from a camera or readings from a sensor:

Step 1: Create a machine

Go to the Viam app and add a new machine.

The ‘First Location’ page on the Viam app with a new machine name in the New machine field and the Add machine button next to the field highlighted.

Step 2: Install viam-server

Navigate to the CONFIGURE tab on your machine’s page in the Viam app. Follow the setup instructions that appear on your new machine’s CONFIGURE page to install viam-server on your computer and connect it to the Viam app.

The Viam app DATA page showing sensor data from an air quality sensor.

Step 3: Configure a camera
  1. From the CONFIGURE tab on your machine’s page in the Viam app, click the + icon next to your machine part in the left-hand menu and select Component.

  2. Select the camera type, then select the webcam model.

  3. Enter a name or use the suggested name for your camera and click Create.

  4. Click the Save button in the top right corner of the page to save your config.

  5. Go to the CONTROL tab and expand the camera’s remote control card to test the camera stream. If you don’t see an image stream, configure the video_path attribute.

For more detailed information, including optional attribute configuration, see the webcam docs.

Step 4: Configure data capture on the camera
  1. Return to the CONFIGURE tab on your machine’s page in the Viam app. Locate the configuration card for your camera.

  2. Click the Add method button. When the Create data management service prompt appears, click to add the service to your machine. Leave the default settings.

  3. Scroll back up to your camera config card. In the Data capture section:

    • Click the Method dropdown and select ReadImage.

    • Set the frequency to 0.1 to capture an image every 10 seconds.

    • Set the MIME type to image/jpeg.

For more detailed information on data capture, see Configure Data Capture. For more on the camera API, see Camera Component.

Step 5: View the captured image data

The Data tab in the upper-left corner of the screen.

In the upper banner of the Viam app, click DATA to see the captured images displayed. If you do not see images from your camera, try waiting a minute and refreshing the page to allow time for the images to be captured and then synced to the app at the interval you configured.

Step 1: Create a machine

Go to the Viam app and add a new machine.

The ‘First Location’ page on the Viam app with a new machine name in the New machine field and the Add machine button next to the field highlighted.

Step 2: Install viam-server

Navigate to the CONFIGURE tab of your machine’s page in the Viam app. Follow the setup instructions that appear on your new machine’s CONFIGURE page to install viam-server on your computer and connect it to the Viam app.

The Viam app DATA page showing sensor data from an air quality sensor.

Step 3: Configure a board

Most sensors need to be wired to the pins of a single-board computer such as a Raspberry Pi. Add a board component to your config:

An example board configuration in the app builder UI. The name (local), type (board) and model (pi) are shown. No other attributes are configured.

Step 4: Configure a sensor
  1. Search the supported sensor models for a model of sensor that is compatible with your sensor hardware. For example, if you have a Sensirion SHT3x-DIS temperature and humidity sensor, you should use the sensirion-sht3xd model of sensor.

    Once you determine which model to use, add it to your machine’s configuration:

  2. From the CONFIGURE tab of your machine’s page in the Viam app, click the + icon next to your machine part in the left-hand menu and select Component.

  3. Select the sensor type, then select the model that matches your hardware.

    The dropdown showing all sensor models.
  4. Enter a name or use the suggested name for your sensor and click Create.

  5. Add required attributes, such as information about how the sensor is connected to the board. You can find information on these attributes by clicking the name of your sensor model in the supported models list.

  6. Click the Save button in the upper right corner of the page to save your configuration.

  7. Go to the CONTROL tab and expand the sensor’s remote control card to test the sensor. Click Get readings. If you don’t see the latest reading from the sensor, check that your sensor is properly wired to the board, and that the type of communication the sensor uses is enabled on the board (if applicable).

    The sensor card on the Control tab with some air quality readings.
Step 5: Configure data capture on the sensor
  1. Return to the CONFIGURE tab on your machine’s page in the Viam app. Locate the configuration card for your sensor.

  2. Click the Add method button. When the Data management service missing alert appears, click Create data management service to add the service to your machine. Leave the default settings.

  3. Scroll back up to your sensor configuration card. In the Data capture section:

    • Click the Method dropdown and select Readings.

    • Set the frequency to 0.05 to capture a sensor reading once every 20 seconds.

For more detailed information on data capture, see Configure Data Capture. For more on the sensor API, see Sensor Component.

Step 6: View the captured sensor data

The Viam app Data tab showing sensor data from an air quality sensor.

In the upper banner of the Viam app, click DATA to see the captured sensor data displayed. If you do not see data from your sensor, try waiting a minute and refreshing the page to allow time for the readings to be captured and then synced to the app at the interval you configured.

Next steps

Now that you have captured data, try training a computer vision model on your images, or query your sensor data:

To see data capture in real-world projects, check out these tutorials:

Have questions, or want to meet other people working on robots? Join our Community Discord.

If you notice any issues with the documentation, feel free to file an issue or edit this file.