Xiaomi Mijia Temperature and Humidity Sensor
硬體規格
- 名稱:小米藍芽溫溼度計
- 型號:LYWSD03MMC
Raspberry Pi OS
安裝 Python module
# 以下指令必須用 user 帳號下執行 (non-root)
mkdir mitemp2
cd mitemp2
python -m venv env
source env/bin/activate
which python
# 記得先升級 pip 至最新版
pip install --upgrade pip
# 開始安裝套件
sudo apt install libbluetooth-dev libglib2.0-dev
pip install bluepy
pip install lywsd03mmc
pip install paho-mqtt
錯誤:ERROR: Could not build wheels for bluepy, which is required to install pyproject.toml-based projects
解決:
sudo apt install libbluetooth-dev libglib2.0-dev
Telegraf
Option 1: Python script
建立設定檔
mv /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf.orig
telegraf --input-filter exec --output-filter influxdb_v2 config > /etc/telegraf/telegraf.conf
telegraf.conf
[[inputs.exec]]
interval = "300s"180s"
commands = [["/home/db2mon/bin/collect_db2.v10.sh -d dcdb -a b_dcdbsudo -u istdcpi sh -pc istdc4mis"'/home/pi/mitemp/go-mitemp.py'"]
## Timeout for each command to complete.
timeout = "15s"30s"
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "influx"