資料介紹
軟件簡(jiǎn)介
Homebridge GPIO WiringPi - Platform Plugin
WORK IN PROGRESS
Please report issues at https://github.com/rsg98/homebridge-gpio-wpi2/issues
Supports triggering General Purpose Input Output (GPIO) pins on the Raspberry Pi.
Uses wiringPi as a back end to give non-root access to GPIO.
Requirements
- Homebridge - HomeKit support for the impatient
- node-wiring-pi - Node.js bindings to wiringPi
This version of the plugin expects WiringPi itself to already be installed - see the documentation for node-wiring-pi for more details, or just follow the instructions below for Raspbian.
Installation
-
Install the wiringpi package using
sudo apt-get install wiringpi
-
Install Homebridge using
sudo npm install -g homebridge
-
Install this plugin
sudo npm install homebridge-gpio-wpi2
-
Update your configuration file - see
config-platform-sample.json
in this repo -
Make sure your
homebridge
user is in thegpio
group.
$ sudo usermod -G gpio homebridge
Configuration
The pin numbers used in this config file are the BCM pin numbers, not the physical pins or WiringPi pin numbers.
You can run gpio readall
to generate a table showing how the BCM pin numbers map to the physical pins, which varies between models of Raspberry Pi.
{
"bridge": {
"name": "Homebridge",
"username": "CC:22:3D:E3:CE:30",
"port": 51826,
"pin": "031-45-155"
},
"description": "This is an example configuration file with one fake accessory and one fake platform.",
"platforms": [{
"platform" : "WiringPiPlatform",
"name" : "Pi GPIO (WiringPi)",
"overrideCache" : "true",
"autoExport" : "true",
"gpiopins" : [{
"type":"Switch",
"name" : "GPIO2",
"pin" : 27,
"enabled" : "true",
"mode" : "out",
"pull" : "down",
"inverted" : "false",
"duration" : 0,
"polling" : "true"
},{
"type":"MotionSensor",
"name" : "GPIO3",
"pin" : 22,
"enabled" : "true",
"mode" : "in",
"pull" : "down",
"inverted" : "false",
"duration" : 0
}]
}]
}
Platform Config Items
Config Item | Valid Values | Description |
---|---|---|
platform |
WiringPiPlatform |
Must be set to this value to initialise this plugin |
name |
string |
What you want this platform to be called (appears in the logs and such like) |
overrideCache |
true / false |
Homebridge will cache all your accessories - setting this to true will ignore the cached value (direction, mode, etc.) and read them direcly from your config file |
autoExport |
true / false |
As long as your homebridge user has permission (i.e. is a member of the gpio group), setting this to true will automatically export the pins via sysfs, meaning you don't need a set-gpio.sh script |
Pin Config Items
Config Item | Valid Values | Description |
---|---|---|
"type" | "string" | Type of device connected to GPIO. Set to "Switch" for "out" pin mode, or one of "ContactSensor", "LeakSensor", "MotionSensor", "OccupancySensor", or "SmokeSensor" for "in" pin mode |
name |
string |
Initial display name for the PIN accessory - can be renamed in HomeKit app (e.g. Home) |
pin |
number |
The BCM pin number - see Pin Configuration below |
enabled |
true / false |
Whether you want the module to publish this pin as an accessory |
mode |
out / in |
Mode the pin should operate in |
pull |
up / down / off |
Configuration for the built in Pi pull up resistor |
inverted |
true / false |
Reverse the behaviour of the GPIO pin (0 is on, 1 is off) |
duration |
number |
Pin will turn off after this number of miliseconds |
polling |
true / false |
Whether Homebridge should periodically check the status of the pin (perhaps it's being set by something external to homebridge) |
Pin Configuration
If you don't use the autoExport
option above, you'll need to manually configure the relevant GPIO pins using the gpio utility included with wiringPi.
This is not necessary if you use autoExport and your homebridge user is a member of the gpio
group.
$ gpio readall
+-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | OUT | 0 | 3 || 4 | | | 5V | | |
| 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 1 | ALT0 | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | ALT0 | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 1 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | OUT | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
The pin number specified in the config.json file is the BCM pin number in this table.
To set up the pins correctly, this module includes a make-gpio-script
script, which will generate a set-gpio.sh
. You should run set-gpio.sh
before starting Homebridge so that all the pins are configured. If you start Homebridge using systemd, you can add set-gpio.sh
as a ExecStartPre command in the homebridge.service
file
$ node make-gpio-script config.json set-gpio.sh
The gpio tool is setuid root, so this script should be run as the user that runs Homebridge.
Troubleshooting
Homebridge reports no errors, but nothing is switched on or off
Check the permissions in /sys/class/gpio/gpioXX - autoExport
option should have created all these properly, if your Homebridge user account has the right permissions (i.e. is a member of the gpio
group)
$ sudo usermod -G gpio homebridge
If you are not using autoExport
, you should run the set-gpio.sh
script as the homebridge user (see section above to generate this script):
$ node make-gpio-script config.json set-gpio.sh
Licence
(The MIT License)
Copyright (c) 2016 Richard Grime richard.grime@gmail.com
Original Project Copyright (c) 2016 James Blanksby james@blanks.by
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Linux樹莓派開發(fā)之wiringPi庫(kù),樹莓派控制繼電器
- wiringPi庫(kù)和控制繼電器說明
- 用Rust編寫的Homebridge Spotify插件
- 用于樹莓派與PIR傳感器連接成運(yùn)動(dòng)傳感器的homebridge插件
- Homebridge插件集成Shinobi
- 用于Away的homebridge插件
- Homebridge的Loxone插件
- Homebridge Pi恒溫器插件
- 米家安防攝像頭Homebridge插件
- Homebridge插件可在Apple HomeKit中使用RuuviTags
- homebridge示例插件示例集合
- homebridge-smartthings SmartThings插件
- homebridge miio平臺(tái)插件
- 熱門的homebridge插件列表
- Homebridge-Denon-Marantz-AVR插件
- 基于OpenHarmony編寫GPIO平臺(tái)驅(qū)動(dòng)和應(yīng)用程序 734次閱讀
- Rust構(gòu)建QEMU插件的框架 745次閱讀
- STM32的GPIO在實(shí)際開發(fā)設(shè)計(jì)的使用配置和技巧 694次閱讀
- GPIO是什么? 3.5w次閱讀
- GPIO輸入——按鍵檢測(cè) 2312次閱讀
- STM32G0開發(fā)筆記:GPIO接按鍵的使用方式 1579次閱讀
- GPIO不同模式之間的區(qū)別與實(shí)現(xiàn)方式 1629次閱讀
- GPIO的內(nèi)部上下拉電阻_GPIO的驅(qū)動(dòng)能力 1.3w次閱讀
- STM32的GPIO使用 4306次閱讀
- dfrobot面包板實(shí)驗(yàn)插件LED插件包簡(jiǎn)介 1174次閱讀
- 簡(jiǎn)要分析Thread的通用GPIO設(shè)備驅(qū)動(dòng) 1413次閱讀
- 被zynq的GPIO唬住,告訴你zynq的3種GPIO 5090次閱讀
- 電子接插件電鍍技術(shù) 3361次閱讀
- vscode常用插件有哪些 2w次閱讀
- jquery插件寫法及用法(jQuery插件開發(fā)全解析) 1w次閱讀
下載排行
本周
- 1使用單片機(jī)實(shí)現(xiàn)七人表決器的程序和仿真資料免費(fèi)下載
- 2.96 MB | 44次下載 | 免費(fèi)
- 2聯(lián)想E46L DAOLL6筆記本電腦圖紙
- 1.10 MB | 2次下載 | 5 積分
- 3MATLAB繪圖合集
- 27.12 MB | 2次下載 | 5 積分
- 4PR735,使用UCC28060的600W交錯(cuò)式PFC轉(zhuǎn)換器
- 540.03KB | 1次下載 | 免費(fèi)
- 5UCC38C42 30W同步降壓轉(zhuǎn)換器參考設(shè)計(jì)
- 428.07KB | 1次下載 | 免費(fèi)
- 6DV2004S1/ES1/HS1快速充電開發(fā)系統(tǒng)
- 2.08MB | 1次下載 | 免費(fèi)
- 7模態(tài)分解合集matlab代碼
- 3.03 MB | 1次下載 | 2 積分
- 8美的電磁爐維修手冊(cè)大全
- 1.56 MB | 1次下載 | 5 積分
本月
- 1使用單片機(jī)實(shí)現(xiàn)七人表決器的程序和仿真資料免費(fèi)下載
- 2.96 MB | 44次下載 | 免費(fèi)
- 2UC3842/3/4/5電源管理芯片中文手冊(cè)
- 1.75 MB | 15次下載 | 免費(fèi)
- 3DMT0660數(shù)字萬用表產(chǎn)品說明書
- 0.70 MB | 13次下載 | 免費(fèi)
- 4TPS54202H降壓轉(zhuǎn)換器評(píng)估模塊用戶指南
- 1.02MB | 8次下載 | 免費(fèi)
- 5STM32F101x8/STM32F101xB手冊(cè)
- 1.69 MB | 8次下載 | 1 積分
- 6HY12P65/HY12P66數(shù)字萬用表芯片規(guī)格書
- 0.69 MB | 6次下載 | 免費(fèi)
- 7華瑞昇CR216芯片數(shù)字萬用表規(guī)格書附原理圖及校正流程方法
- 0.74 MB | 6次下載 | 3 積分
- 8華瑞昇CR215芯片數(shù)字萬用表原理圖
- 0.21 MB | 5次下載 | 3 積分
總榜
- 1matlab軟件下載入口
- 未知 | 935119次下載 | 10 積分
- 2開源硬件-PMP21529.1-4 開關(guān)降壓/升壓雙向直流/直流轉(zhuǎn)換器 PCB layout 設(shè)計(jì)
- 1.48MB | 420061次下載 | 10 積分
- 3Altium DXP2002下載入口
- 未知 | 233084次下載 | 10 積分
- 4電路仿真軟件multisim 10.0免費(fèi)下載
- 340992 | 191367次下載 | 10 積分
- 5十天學(xué)會(huì)AVR單片機(jī)與C語言視頻教程 下載
- 158M | 183335次下載 | 10 積分
- 6labview8.5下載
- 未知 | 81581次下載 | 10 積分
- 7Keil工具M(jìn)DK-Arm免費(fèi)下載
- 0.02 MB | 73807次下載 | 10 積分
- 8LabVIEW 8.6下載
- 未知 | 65987次下載 | 10 積分
評(píng)論
查看更多