Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattludwigs/mcp300x
Elixir library for MCP300X family Analog-to-Digitial Converters
https://github.com/mattludwigs/mcp300x
Last synced: about 1 month ago
JSON representation
Elixir library for MCP300X family Analog-to-Digitial Converters
- Host: GitHub
- URL: https://github.com/mattludwigs/mcp300x
- Owner: mattludwigs
- Created: 2019-02-09T20:30:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-31T21:09:19.000Z (almost 6 years ago)
- Last Synced: 2024-11-17T17:49:28.318Z (about 2 months ago)
- Language: Elixir
- Size: 13.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# MCP300X
[![CircleCI](https://circleci.com/gh/mattludwigs/mcp300x.svg?style=svg)](https://circleci.com/gh/mattludwigs/mcp300x)
Library for working the MCP300X Analog-to-Digitial Converters.
## Road map
This library is under active development and supports single channel
reads using the MCP3008 ADC. So, here is the goals of this library:- [ ] Support MCP3002
- [ ] Support MCP3004
- [ ] Support Differential Reads
- [ ] Support MSBF## Basic usage
Assuming that you have a potentiometer to the `0` channel on the MCP3008
you could call```elixir
MCP300X.read_channel("spidev0.0", MCP300X.MCP3008, 0)
```This will proivde the raw reading from the ADC. To get volts you can pass in the `MCP300X.to_volts/1` function:
```elixir
MCP300X.read_channel("spidev0.0", MCP300X.MCP3008, 0, convert_func: &MCP300X.to_volts/1)`
```The `convert_func` option is a function that will run on the output of the ADC. By
default this is the `MCP300X.id/1` function, which is just a pass through of the raw
value.Also, there is `MCP300X.Server` that you can run in your superivsion tree that
will keep the SPI connection open for faster reads.```elixir
children = [
{MCP300X.Server, ["spidev0.0", MCP300X.MCP3008, [name: MyApp.MCP3008]]}
]opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
# Calling
MCP300X.Server.read_channel(MyApp.MCP3008, 0)
```## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `mcp300x` to your list of dependencies in `mix.exs`:```elixir
def deps do
[
{:mcp300x, "~> 0.1.1"}
]
end
```Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/mcp300x](https://hexdocs.pm/mcp300x).## Datasheets
- [MCP3008](https://www.microchip.com/wwwproducts/en/en010530)