Home Assistant获取大气压力和海拔 /树莓派Raspberry Pi使用BMP180
视频教程如下:
https://youtu.be/G1pRuM7ccsQ
本教程仅适用于树莓派
树派开启SPI
sudo raspi-config
选5,接口选项->选P5 I2C-> 开启
连线方法:
sudo apt-get update
sudo apt-get install build-essential python-dev python-smbus i2c-tools -y
git clone https://github.com/adafruit/Adafruit_Python_BMP.git
cd Adafruit_Python_BMP
sudo python setup.py install
sudo wget https://sumju.net/bmp180.py
sudo mv bmp180.py /usr/local/bin/
sudo chmod +x /usr/local/bin/bmp180.py
Home Assistant 配置:
sensor:
- platform: command_line
name: 温度
command: "sudo bmp180.py temperature"
unit_of_measurement: "°C"
value_template: '{{ value | round(2) }} '
- platform: command_line
name: 气压
command: "sudo bmp180.py pressure"
value_template: '{{ value | round(2) }} '
unit_of_measurement: "Pa"
- platform: command_line
name: 海拔
command: "sudo bmp180.py altitude"
value_template: '{{ value | round(2) }} '
unit_of_measurement: "m"