Skip to content

Commit a6a9a52

Browse files
authored
Update README.md
1 parent 8f9bad0 commit a6a9a52

File tree

1 file changed

+78
-2
lines changed

1 file changed

+78
-2
lines changed

README.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mcp300x-adc-sensor
1+
# `mcp300x-adc-sensor` modular resource
22

33
The module provides analog-to-digital conversion capabilities for MCP300x SPI ADCs. Tested on MCP3002, MCP3004, and MCP3008 using a Raspberry Pi. If you are using any other board, check out the go modules that are board agnostic: https://app.viam.com/module/hazalmestci/mcp3001-2 and https://app.viam.com/module/hazalmestci/mcp3004-8.
44

@@ -8,12 +8,88 @@ For MCP3008, you can get readings for up to 8 sensors from channel 0 to channel
88

99
Wiring for these sensors is different and you should refer to data sheets for each ADC.
1010

11-
The sensors should be declared in the sensor configuration in the Viam app. For example, if you have a moisture sensor attached to channel 0, a temperature sensor attached to channel 1, and a humidity sensor attached to channel 2, your channel_map in the config should look like this:
11+
## Build and run
1212

13+
To use this module, follow the instructions to [add a module from the Viam Registry](https://docs.viam.com/registry/configure/#add-a-modular-resource-from-the-viam-registry) and select the `hazalmestci:sensor:mcp300x` model from the [`mcp300x-adc-sensor` module](https://app.viam.com/module/hazalmestci/mcp300x-adc-sensor).
14+
15+
## Configure your `mcp300x-adc-sensor`
16+
17+
> [!NOTE]
18+
> Before configuring your `mcp300x-adc-sensor`, you must [create a machine](https://docs.viam.com/manage/fleet/machines/#add-a-new-machine).
19+
20+
Navigate to the **Config** tab of your machine's page in [the Viam app](https://app.viam.com/).
21+
Click on the **Components** subtab and click **Create component**.
22+
Select the `sensor` type, then select the `hazalmestci:sensor:mcp300x` model.
23+
Click **Add module**, then enter a name for your sensor and click **Create**.
24+
25+
On the new component panel, copy and paste the following attribute template into your sensor’s **Attributes** box:
26+
27+
> [!NOTE]
28+
> For more information, see [Configure a Machine](https://docs.viam.com/manage/configuration/).
29+
30+
```json
31+
{
1332
"channel_map": {
1433
"moisture": 0,
1534
"temperature": 1,
1635
"humidity": 2
1736
}
37+
}
38+
```
39+
40+
Save your config.
41+
42+
### Attributes
43+
44+
The following attributes are available for a `mcp300x-adc-sensor` sensor:
45+
46+
| Name | Type | Inclusion | Description |
47+
| ------- | ------ | ------------ | ----------- |
48+
| `channel_map` | string | **Required** | The channel map for moisture, temperature, and humidity. |
49+
50+
### Example configuration
51+
52+
For example, if you have a moisture sensor attached to channel 0, a temperature sensor attached to channel 1, and a humidity sensor attached to channel 2, your config should look like this:
53+
54+
```json
55+
{
56+
"name": "my-mcp300x",
57+
"model": "hazalmestci:sensor:mcp300x",
58+
"type": "sensor",
59+
"namespace": "rdk",
60+
"attributes": {
61+
"channel_map": {
62+
"moisture": 0,
63+
"temperature": 1,
64+
"humidity": 2
65+
}
66+
},
67+
"depends_on": []
68+
}
69+
```
1870

1971
Since you are getting readings from three separate channels, you won't be able to use the MCP3002 sensor for this use case, and will need either an MCP3004 or an MCP3008.
72+
73+
## Local Development
74+
75+
To use the `mcp300x-adc-sensor` module with a local install, clone this repository to your machine’s computer, navigate to the `module` directory, and run:
76+
77+
```go
78+
go build
79+
```
80+
81+
On your robot’s page in the [Viam app](https://app.viam.com/), enter
82+
the [module’s executable path](/registry/create/#prepare-the-module-for-execution), then click **Add module**.
83+
The name must use only lowercase characters.
84+
Then, click **Save config**.
85+
86+
## Next Steps
87+
88+
1. To test your sensor, go to the [**Control** tab](https://docs.viam.com/manage/fleet/robots/#control) and test that you are getting readings.
89+
2. Once you can obtain your readings, configure the data manager to [capture](https://docs.viam.com/data/capture/) and [sync](https://docs.viam.com/data/cloud-sync/) the data from all of your machines.
90+
3. To retrieve data captured with the data manager, you can [query data with SQL or MQL](https://docs.viam.com/data/query/) or [visualize it with tools like Grafana](https://docs.viam.com/data/visualize/).
91+
92+
## License
93+
94+
Copyright 2021-2023 Viam Inc. <br>
95+
Apache 2.0

0 commit comments

Comments
 (0)