Skip to content

Commit 0628ecb

Browse files
committed
Delay after soft reset
1 parent 8e94bea commit 0628ecb

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# AHT20
22

33
[![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/AHT20.html)
4+
[![API docs](https://img.shields.io/hexpm/v/aht20.svg?label=docs)](https://hexdocs.pm/aht20)
55
![CI](https://github.com/mnishiguchi/AHT20/workflows/CI/badge.svg)
66

77
Use [AHT20](http://www.aosong.com/en/products-32.html) temperature & humidity sensor in Elixir.

lib/aht20/sensor.ex

+7-1
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,24 @@ defmodule AHT20.Sensor do
5858
Process.sleep(40)
5959
:ok = reset(aht20)
6060
:ok = init(aht20)
61+
6162
{:ok, aht20}
6263
rescue
6364
e -> {:error, e}
6465
end
6566

6667
@doc """
6768
Restarts the sensor system without having to turn off and turn on the power again.
69+
Soft reset takes no longer than 20ms.
6870
For more info. please refer to the data sheet (section 5.5).
6971
"""
7072
@spec reset(t) :: :ok | {:error, any}
7173
def reset(%{i2c_ref: i2c_ref, i2c_address: i2c_address}) do
72-
Circuits.I2C.write(i2c_ref, i2c_address, [@aht20_cmd_soft_reset])
74+
:ok = Circuits.I2C.write(i2c_ref, i2c_address, [@aht20_cmd_soft_reset])
75+
Process.sleep(20)
76+
:ok
77+
rescue
78+
e -> {:error, e}
7379
end
7480

7581
# Initialize the sensor system.

mix.exs

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

4-
@version "0.1.0"
4+
@version "0.1.1"
55
@source_url "https://github.com/mnishiguchi/aht20"
66

77
def project do

0 commit comments

Comments
 (0)