CO2 CloudWatch Metrics
Usage
- deploy this CDK (
cdk deploy
) whatever region you like
- if your account are new for CDK, run
cdk bootstrap
before running the deploy command
- set Discord Webhook URL to SSM parameter
- send your CO2 data via
put-metric-data
- On your IoT machine, install and setup AWS CLI or boto3
Example Setup for Raspberry Pi 4
- install AWS CLI by building from the source code
sudo pip3 install git+https://github.com/aws/aws-cli.git@v2 --upgrade
aws configure
and set ACCESS_KEY and SECRET in Outputs of CloudFormation
- install requirements
sudo pip3 install mh-z19
sudo apt install -y jq
- set cron to send metric data
cat <<EOF > /tmp/cronsetting.txt
*/1 * * * * /usr/local/bin/aws cloudwatch put-metric-data --namespace "Home" --metric-name "CO2" --dimensions Position=LivingRoom --value \$(sudo python3 -m mh_z19 | jq -r .co2)
EOF
crontab /tmp/cronsetting.txt