码迷,mamicode.com
首页 > 其他好文 > 详细

树莓派1代b型安装homebridge

时间:2019-07-08 10:48:11      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:stream   tun   passwd   pidof   pull   creat   开关   common   out   

1、修改源
sudo nano /etc/apt/sources.list
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

sudo nano /etc/apt/sources.list.d/raspi.list
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui

启用红外模块
sudo nano /boot/config.txt
最后行添加
取消屏蔽dtoverlay=lirc-rpi,gpio_in_pin=18
sudo apt-get install lirc
sudo kill $(pidof lircd)
sudo mode2 -d /dev/lirc0
sudo nano /etc/lirc/lirc_options.conf
将driver 从 devinput 改为 default

文件共享
sudo apt-get -y install samba samba-common-bin
sudo nano /etc/samba/smb.conf
[Public]
comment = Public Storage
path = /home/pi/Public
read only = no
create mask = 0777
directory mask = 0777
guest ok = yes
browseable = yes

sudo smbpasswd -a pi
sudo samba restart

安装百度网盘-只能上传http://blog.csdn.net/a_lpha/article/details/53637669
sudo pip install bypy
sudo bypy info
输入授权码后
cd ~/Public
上传
bypy upload
服务器列表
bypy list
服务器比较
bypy compare

3、开启root账户
sudo passwd root
sudo passwd --unlock root

4、安装nodejs
wget https://nodejs.org/dist/v9.0.0/node-v9.0.0-linux-armv6l.tar.gz
tar -xvf node-v9.0.0-linux-armv6l.tar.gz
cd /home/pi/node-v9.0.0-linux-armv6l
sudo cp -R * /usr/local/

7、安装bcm2835及python的wiringpi库
cd /boot/bcm2835-1.35
sudo ./configure
sudo make
sudo make install

sudo pip install wiringpi2

8、安装homekit
sudo apt-get install -y libavahi-compat-libdnssd-dev
sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp
sudo npm install -g --unsafe-perm bignum

sudo npm install --unsafe-perm -g homebridge-gpio-wpi2
sudo npm install --unsafe-perm -g homebridge-ds18b20
sudo npm install --unsafe-perm -g homebridge-dht-sensor
sudo npm install --unsafe-perm -g homebridge-hc-sr501
sudo npm install --unsafe-perm -g homebridge-camera-ffmpeg
sudo npm install --unsafe-perm -g homebridge-led-strip

sudo homebridge
sudo nano /root/.homebridge/config.json
{
"bridge": {
"name": "树莓派",
"username": "B8:27:EB:93:D2:EA",
"port": 51826,
"pin": "123-45-678"
},
"description": "树莓派传感器",
"platforms": [{
"platform" : "WiringPiPlatform",
"name" : "开关",
"overrideCache" : "true",
"autoExport" : "true",
"gpiopins" : [{
"name" : "开关",
"pin" : 27,
"enabled" : "true",
"mode" : "out",
"pull" : "down",
"inverted" : "true",
"duration" : 0,
"polling" : "true"
}]
},
{
"platform": "Camera-ffmpeg",
"cameras": [
{
"name": "摄像头",
"videoConfig": {
"source": "-re -i /dev/video0",
"stillImageSource": "-i /dev/video0",
"maxStreams": 2,
"maxWidth": 640,
"maxHeight": 480,
"maxFPS": 6,
"vcodec": "h264_omx"
}
}
]}
],
"accessories": [
{
"accessory": "DS18B20",
"name": "温度传感器",
"device": "28-000005ac8ced"
},{
"accessory": "DhtSensor",
"name": "温湿度",
"sensorType": 11,
"gpioPin": 4
},{
"accessory" : "HC-SR501",
"name" : "人体传感器",
"pinId" : 25,
"timeout" : 0,
"inverts" : false
},{
"accessory": "ledStrip",
"name": "可控灯泡",
"pin": 24,
"brightness": 1,
"inverted":false
}
]
}
清理缓存
sudo rm -rf /root/.homebridge/persist
sudo rm -rf /root/.homebridge/accessories
sudo pigpiod

/home/pi下新建start.sh脚本,修改权限允许任何人运行
#sudo modprobe bcm2835_v4l2
sudo homebridge &
while true
do
p=/home/pi/Pictures/
f=`date +%Y-%m-%d_%H-%M-%S`.jpg
raspistill -o $p$f -t 100 -n
echo $f get pic!
bypy upload $p$f
rm -f $p$f
echo $f upload done!
sleep 600
done

开机启动
sudo nano /etc/rc.local
exit 0之上输入
/home/pi/start.sh start &

结束后台homebridge进程
sudo killall -TERM homebridge

树莓派1代b型安装homebridge

标签:stream   tun   passwd   pidof   pull   creat   开关   common   out   

原文地址:https://www.cnblogs.com/swdabing/p/11149650.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!