树莓派安装homebridge

树莓派版本:raspberry pi2
树莓派配合homebridge实现iphone HomeKit siri控制树莓派gpio

更新源

sudo apt-get update
sudo apt-get upgrade

安装c++11 or later

sudo vim /etc/apt/sources.list

// ___replace jessie with wheezy
#deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi

sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo vim /etc/apt/sources.list

// ___replace wheezy with jessie
deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
#deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi

sudo apt-get update
export CC=/usr/bin/gcc-4.9
export CXX=/usr/bin/g++-4.9

如果不安装c++11,后面npm安装homebridge将报以下错误:

Failed to execute ‘/usr/local/bin/node /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js build –fallback-to-build –module=/usr/local/lib/node_modules/node-inspector/node_modules/v8-profiler/build/profiler/v5.3.0/node-v46-linux-arm/profiler.node –module_name=profiler –module_path=/usr/local/lib/node_modules/node-inspector/node_modules/v8-profiler/build/profiler/v5.3.0/node-v46-linux-arm’ (1)
npm ERR! Linux 4.1.6+
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “-g” “install” “node-inspector”
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! v8-debug@0.5.3 install: node-pre-gyp install –fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the v8-debug@0.5.3 install script ‘node-pre-gyp install –fallback-to-build’.
npm ERR! This is most likely a problem with the v8-debug package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install –fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls v8-debug
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/jnavratil/npm-debug.log

安装nodejs

wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-armv7l.tar.gz 
tar -xvf node-v4.0.0-linux-armv7l.tar.gz 
cd node-v4.0.0-linux-armv7l

sudo cp -R * /usr/local/

// 检查是否安装成功
node -v

// Install Avahi and other Dependencies
sudo apt-get install libavahi-compat-libdnssd-dev

安装homebridge插件

sudo npm install homebridge-gpio-wpi2

npm安装gpio插件

npm install -g homebridge-gpio

编写config文件

sudo vim /home/pi/.homebridge/config.json

{
        "bridge": {
                "name": "Homebridge",
                "username": "CC:22:3D:E3:CE:30",
                "port": 51826,
                "pin": "133-45-678"
        },
        "platforms": [{
                 "platform" : "WiringPiPlatform",
                "name" : "Pi GPIO (WiringPi)",
                "overrideCache" : "true",
                "autoExport" : "true",
                "gpiopins" : [{
                        "name" : "灯",
                        "pin"  : 27,
                        "enabled" : "true",
                        "mode" : "out",
                        "pull" : "down",
                        "inverted" : "false",
                        "duration" : 0,
                        "polling" : "true"
                        },{
                        "name" : "门",
                        "pin"  : 22,
                        "enabled" : "true",
                        "mode" : "in",
                        "pull" : "off",
                        "inverted" : "false",
                        "duration" : 0
                }]
        }]
}


// :wq 保存退出
// 打开homebridge
$ homebridge

参考:

Running Homebridge on a Raspberry Pi
Raspberry Pi 2 : gyp ERR! build error (zmq)
homebridge
Installing Node.js v4.0.0 on a Raspberry Pi (All Models)
homebridge-gpio
HomeKit初体验
树莓派安装homekit

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值