Skip to content

Commit 282b6cf

Browse files
committed
add more descirptions
1 parent cd382a1 commit 282b6cf

1 file changed

Lines changed: 49 additions & 1 deletion

File tree

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,52 @@ This library has been tested with [PlatformIO](https://platformio.org/), is also
1818
This library only supports retrieving measurement values by the serial communication. Retrieving measurement values from the PWM signals is not supported.
1919

2020
## APIとサポートする機能
21+
22+
### 測定値の取得
23+
以下のようなAPIでセンサモジュールの操作を行うことができます。
24+
25+
現時点では、`MH-Z19C`がサポートするCO2濃度の読み取り(コマンド`0x86`)および、セルフキャリブレーションの有効化/無効化の設定(コマンド`0x79`)のみをサポートしています。
26+
27+
```cpp
28+
#include <Arduino.h>
29+
#include <MHZ19X.h>
30+
31+
// MH-Z19Cセンサモジュールを操作するインスタンスを作成
32+
auto co2sensor = MHZ19C(); // Arduinoおよび同互換ボードの場合
33+
// auto co2sensor = MHZ19C_UART1(); // ESP32の場合
34+
35+
void setup()
36+
{
37+
co2sensor.begin();
38+
39+
// セルフキャリブレーションをオンにする
40+
co2sensor.switchSelfCalibration(true);
41+
}
42+
43+
void loop()
44+
{
45+
uint16_t co2ppm;
46+
MHZ19X_error_t result;
47+
48+
// CO2濃度を取得する
49+
result = co2sensor.getCO2Concentration(co2ppm);
50+
51+
if (MHZ19X_error_t::success == result) {
52+
// 取得に成功した場合、「なんらかのディスプレイ」に測定値を表示する
53+
// display.print(co2ppm);
54+
}
55+
56+
delay(3000);
57+
}
58+
```
59+
60+
> [!IMPORTANT]
61+
> センサモジュールを操作する型の名前は、Arduinoおよび同互換ボードでは`MHZ19C`となりますが、これはボード/MCUごとに異なります。 詳細は[examples](./examples/)ディレクトリにあるボード/MCUごとのサンプルコードを参照してください。
62+
63+
> [!IMPORTANT]
64+
> The type name for the sensor module is `MHZ19C` for Arduino-compatible boards. This type name, however, depends on the board/MCU. See [examples](./examples/) for the actual type names.
65+
66+
2167
### 任意のUARTシリアル通信の実装を使用可能
2268
本ライブラリでは、さまざまなボード/MCUで動作させられるよう、UARTシリアル通信を任意の実装に差し替えられるようにしています。 具体的には、[`MHZ19XDriver`](./src/MHZ19XDriver.hpp)クラスのテンプレートパラメータ`TUartStream`に任意の実装を指定することができます。
2369

@@ -27,13 +73,15 @@ This library only supports retrieving measurement values by the serial communica
2773
> 標準のシリアル通信が利用できない場合は、ライブラリでのフォールバック実装として[`SloppySoftwareSerialStream`](./src/SloppySoftwareSerialStream.hpp)が利用可能です。
2874
> ただし、これは`digitalRead()`, `digitalWrite()`および`delayMicroseconds()`を使用した*雑な*実装であり、動作が安定せず期待する結果を得られない場合があります。
2975
76+
3077
## Modules confirmed to work / 動作確認済みモジュール
3178
- MH-Z19C
3279

3380
> [!NOTE]
3481
> 他のセンサーモジュールでも動作する可能性はありますが、実機での動作は未検証です。
3582
> Also the library may work with other sensor modules, but has not been tested with actual modules.
3683
84+
3785
## Boards and MCUs confirmed to work / 動作確認済みのボードとMCU
3886
- ESP32
3987
- ESP32-WROOM-32
@@ -44,7 +92,7 @@ This library only supports retrieving measurement values by the serial communica
4492
- Arduino Nano
4593
- Arduino Nano Every
4694

47-
> [!WARNING]
95+
> [!IMPORTANT]
4896
> ATtinyで動作させる場合、20 MHzまたは16 MHzで動作させることを推奨します。 それより低い動作周波数では、シリアル通信が安定しません。
4997
> これは[シリアル通信に使用している実装](./src/SloppySoftwareSerialStream.hpp)*雑な*実装であるためです。 `delayMicroseconds`に渡す値の調整により改善する場合もありますが、電源電圧の影響を受ける場合もあり、調整の難易度は高いです。
5098
> ATtinyで動作する、より良いシリアル通信を実装してくれる方がいましたら、ぜひIssuesにてご提案ください。

0 commit comments

Comments
 (0)