このプラグインはhomebridgeを通してMH-Z19での二酸化炭素濃度計測結果をHomeKit上に表示する為のものです。(TThis plug-in is for displaying the carbon dioxide concentration measurement result of MH-Z19 on HomeKit through homebridge.)
- Raspberry Pi 4 modelB 4GB(UART1、UART2、UART4)
- Winsen MH-Z19C
ここに書いてある事はわたしが設定した内容であり、動作を保証するものではありません。(What is written here is what I have set, and I do not guarantee the operation.) もしかしたら他の環境でも動くかもしれません。
メニューの『設定>Raspberry Pi の設定>インターフェイス』のシリアルポートを有効にします。(SerialPort ⇒ enable)
この際、シリアルコンソールは無効のままにしてください。(Serial console ⇒ Disable)
再起動を促されるので再起動します。(You will be prompted to reboot, so reboot.)
/boot/config.txt
を編集します。(Edit)
例えば(For example)、 sudo nano /boot/config.txt
・・・・
[all]
・・・・
dtoverlay=uart2
dtoverlay=uart4
一番最後に上記の2行を追加します。(Add the above two lines at the very end.)
UART4を使用しない場合は、UART2の行だけを追加します。(If you are not using UART4, add only the UART2 line.)
保存したら再起動します。(After saving, reboot.)
再起動が完了したら /dev
を確認してください。(Check /dev
when the reboot is complete.)
下記の項目が追加されていたらUART2,UART4の解放は成功です。(Release of UART2 and UART4 is successful if the following items exist.)
- 起動時にserial-gettyがシリアルポートを占有してしまう為、STOPする。(Stop because serial-getty occupies the serial port at startup.)
- プログラムが
sudo
無しにシリアルポートにアクセスできるようにパーミッションを変更します。再起動する度に元に戻ります。(Change the permissions so that the program can access the serial port withoutsudo
. It will be restored every time you restart.)
具体的には、
UART1の場合、
sudo systemctl stop [email protected]
sudo chmod 666 /dev/ttyS0
UART2の場合、
sudo systemctl stop [email protected]
sudo chmod 666 /dev/ttyAMA1
UART4の場合、
sudo systemctl stop [email protected]
sudo chmod 666 /dev/ttyAMA2
UART2,UART4は開放状況、環境によってずれる可能性があります。(UART2 and UART4 may shift depending on the open status and environment.)
HomebridgeとHomebridge UIが正しくインストールされているものとします。(It is assumed that Homebridge and Homebridge UI are installed correctly.)
"accessories": [
{
"accessory": "Co2Sensor",
"name": "CO2 Sensor",
"uart_path": "/dev/ttyXXX",
"schedule": "*/5 * * * *",
"warning_level": 1500
},
{
・・・・
}
]
accessory
→ 固定値(Fixed value)[必須項目(required field)]name
→ お好みに(To your liking)[必須項目(required field)]uart
→ MH-Z19を接続したUARTをttyXXX形式で指定します。(Specify the UART to which MH-Z19 is connected in ttyXXX format.)schedule
→ CO2濃度の更新間隔を指定します。(Specify the acquisition interval of CO2 concentration.)warning_level
→ CO2がこのレベルを超えると警告が表示されるようになります。(A warning will be displayed when CO2 exceeds this level.)
I can't speak English, so I use Google Translate for everything. I'm sorry if there is a rude wording.