1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RaspberryPiでCO2測定

Last updated at Posted at 2020-09-14

amazonで買ったわけじゃないけどモノはコレ。
https://www.amazon.co.jp/dp/B07JF4YTTB

ピンホールしかないので適当にぶった切って半田付け
https://www.amazon.co.jp/gp/product/B0785KPQZJ/

ピンアサインは以下
4 -> Vin 6 -> Gnd 8 -> Vout 10 -> RXD

#導入
適当にピンアサインを合わせて配線。

#インストール
pipでいけるが3が必要なので3を指定。

sudo pip3 install mh-z19

#出力準備
動作確認

sudo python -m mh_z19

数字だけ返ってくる。

#自動出力用スクリプト
スクリプトフォルダ作って。

cd /git
mkdir sh

スクリプトを作成。

/git/sh/co2.sh
#!/bin/bash

#取得
aco2=`sudo python3 -m mh_z19 --all`

#出力
sudo echo ${aco2} > /tmp/tmpfs/co2.txt

#出力をapacheに移動
sudo cp /tmp/tmpfs/co2.txt /mnt/src/co2.txt
sudo chown pi:pi /mnt/src/co2.txt

#自動更新
5分もあれば十分だよね?

/etc/crontab
*/5 * * * * root cd /git/sh; /git/sh/co2.sh > /dev/null
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?