树莓派连接DHT11/22 传感器接入 homebridge
npm install homebridge-sensor-th实现传感器接到树莓派,并接入 homebridge 的功能.
可以获取到当前传感器的温度和湿度数据:
!img
!img
Adafruit_Python_DHT 支持三种传感器:
- DHT11(type=11)
- DHT22(type=22)
- AM2302(type=22)
通过 homebridge config.json 中的 type 进行选择(默认为 11)
传感器信号源接到树莓派上的引脚.
通过 homebridge config.json 中的 source 进行选择,遵循 GPIO/BCM 方式(默认为 4)
通过 homebridge config.json 中的 dataType 进行选择,默认为 0(温度)
- 0 温度
- 1 湿度
homebridge-sensor-th``sh
npm i -g homebridge-sensor-th
`
中的 accessories如下:
`json``
{
"accessories": [
{
"accessory": "SensorPlugin",
"name": "湿度检测",
"dataType": 1,
"source": "选填,默认为 4",
"type": "选填,可选值 11 | 22 | 2302 默认为 11"
},
{
"accessory": "SensorPlugin",
"name": "温度检测",
"dataType": 0,
"source": "选填,但是与上面的配置必须相同",
"type": "选填,但是与上面的配置必须相同"
}
]
}