mcp300x

package module
v0.0.0-...-932940d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

mcp3004-8 modular resource

This module provides analog-to-digital conversion capabilities for MCP3004 and MCP3008 SPI ADCs. Written in Go, board agnostic. Tested on Raspberry Pi and Jetson Orin.

The values you get from the readings will be proportional to the voltage and you will need to interpret it depending on which sensor you hook up to the MCP300x.

You can add as many analog sensors as your MCP300x allows and get readings from them concurrently (this depends on how many channels it has, so for MCP3004 that is four channels, and for MCP3008 that is eight).

Build and run

To use this module, follow the instructions to add a module from the Viam Registry and select the hazalmestci:sensor:mcp3004-8-go model from the mcp3004-8 module.

Configure your mcp3004-8

[!NOTE] Before configuring your mcp3004-8, you must create a machine.

Navigate to the Config tab of your machine's page in the Viam app. Click on the Components subtab and click Create component. Select the sensor type, then select the hazalmestci:sensor:mcp3004-8-go model. Click Add module, then enter a name for your sensor and click Create.

On the new component panel, copy and paste the following attribute template into your sensor’s Attributes box:

[!NOTE] For more information, see Configure a Machine.

{
  "chip_select": "0",
  "spi_bus": "0", 
  "pins": {
    "moisture": 0,
    "temperature": 1,
    "humidity": 2
  }
}

Save your config.

Attributes

The following attributes are available for a mcp3004-8 sensor:

Name Type Inclusion Description
chip_select string Required The `chip_select`` pin you are using.
spi_bus string Required the spi_bus you are using.
pins string Required The pins you are using for moisture, temperature, and humidity.
Example configuration
{
    "name": "my-mcp3004",
    "model": "hazalmestci:sensor:mcp3004-8-go",
    "type": "sensor",
    "namespace": "rdk",
    "attributes": {
      "chip_select": "0",
      "spi_bus": "0", 
      "pins": {
        "moisture": 0,
        "temperature": 1,
        "humidity": 2
      }
    },
    "depends_on": []
}

Local Development

To use the mcp3004-8 module with a local install, clone this repository to your machine’s computer, navigate to the module directory, and run:

go build

On your robot’s page in the Viam app, enter the module’s executable path, then click Add module. The name must use only lowercase characters. Then, click Save config.

Next Steps

  1. To test your sensor, go to the Control tab and test that you are getting readings.
  2. Once you can obtain your readings, configure the data manager to capture and sync the data from all of your machines.
  3. To retrieve data captured with the data manager, you can query data with SQL or MQL or visualize it with tools like Grafana.

License

Copyright 2021-2023 Viam Inc.
Apache 2.0

Documentation

Overview

Package mcp300x implements a sensor model supporting mcp300x adc sensor.

Index

Constants

This section is empty.

Variables

View Source
var Model = resource.NewModel("hazalmestci", "sensor", "mcp3004-8-go")

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
Package mcp300x implements a sensor model supporting mcp300x adc sensor
Package mcp300x implements a sensor model supporting mcp300x adc sensor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL