Skip to content

Commit 66814b0

Browse files
committed
Improve documentation
1 parent e557f54 commit 66814b0

File tree

3 files changed

+85
-15
lines changed

3 files changed

+85
-15
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Masatoshi Nishiguchi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+30-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
# AHT20
22

3-
**TODO: Add description**
3+
[![Hex.pm](https://img.shields.io/hexpm/v/AHT20.svg)](https://hex.pm/packages/AHT20)
4+
[![API docs](https://img.shields.io/hexpm/v/AHT20.svg?label=docs)](https://hexdocs.pm/AHT20/LcdDisplay.html)
5+
![CI](https://github.com/mnishiguchi/AHT20/workflows/CI/badge.svg)
46

5-
## Installation
7+
Use [AHT20](http://www.aosong.com/en/products-32.html) temperature & humidity sensor in Elixir.
68

7-
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
8-
by adding `aht20` to your list of dependencies in `mix.exs`:
9+
## Usage
10+
11+
Here's an example use:
912

1013
```elixir
11-
def deps do
12-
[
13-
{:aht20, "~> 0.1.0"}
14-
]
15-
end
16-
```
14+
# Detect I2C devices.
15+
iex> Circuits.I2C.detect_devices()
16+
Devices on I2C bus "i2c-1":
17+
* 56 (0x38)
18+
19+
1 devices detected on 1 I2C buses
1720

18-
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
19-
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
20-
be found at [https://hexdocs.pm/aht20](https://hexdocs.pm/aht20).
21+
# Connect to the sensor.
22+
iex> {:ok, aht20} = AHT20.start(bus_name: "i2c-1", bus_address: 0x38)
23+
{:ok, AHT20.Sensor{}}
24+
25+
# Read the humidity and temperature from the sensor.
26+
iex> AHT20.read_data(aht20)
27+
{:ok,
28+
%AHT20.Measurement{
29+
raw_humidity: 158119,
30+
raw_temperature: 410343,
31+
relative_humidity: 15.079402923583984,
32+
temperature_c: 28.26671600341797,
33+
temperature_f: 82.88008880615234
34+
}}
35+
```
2136

37+
Depending on your hardware configuration, you may need to modify the call to
38+
`AHT20.start/1`. See `t:AHT20.Sensor.config/0` for parameters.

mix.exs

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
defmodule AHT20.MixProject do
22
use Mix.Project
33

4+
@version "0.1.0"
5+
@source_url "https://github.com/mnishiguchi/aht20"
6+
47
def project do
58
[
69
app: :aht20,
7-
version: "0.1.0",
10+
version: @version,
811
elixir: "~> 1.11",
912
start_permanent: Mix.env() == :prod,
10-
deps: deps()
13+
description: "Use AHT20 temperature & humidity sensor in Elixir",
14+
deps: deps(),
15+
docs: docs(),
16+
package: package()
1117
]
1218
end
1319

@@ -28,4 +34,30 @@ defmodule AHT20.MixProject do
2834
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false}
2935
]
3036
end
37+
38+
defp docs do
39+
[
40+
extras: ["README.md"],
41+
main: "readme",
42+
source_ref: "v#{@version}",
43+
source_url: @source_url
44+
]
45+
end
46+
47+
defp package do
48+
%{
49+
files: [
50+
"lib",
51+
"mix.exs",
52+
"README.md",
53+
"LICENSE*"
54+
],
55+
licenses: ["MIT"],
56+
links: %{
57+
"GitHub" => @source_url,
58+
"AHT20 data sheet" =>
59+
"https://cdn-learn.adafruit.com/assets/assets/000/091/676/original/AHT20-datasheet-2020-4-16.pdf"
60+
}
61+
}
62+
end
3163
end

0 commit comments

Comments
 (0)