使用 Watson 和 IoT Platform 服务构建家庭助理移动应用程序(3)
 
- UID
- 1066743
|

使用 Watson 和 IoT Platform 服务构建家庭助理移动应用程序(3)
准备 Raspberry Pi
可以按照这些来设置 Raspberry Pi。我使用了带 Pixel 的 Raspbian Jessie,因为它安装了后面需要的 Node-RED。
默认情况下未设置 wifi 连接。您需要通过以太网电缆将 Raspberry Pi 连接到路由器。还需要连接 USB 键盘和 HDMI 显示线。
- 单击右上角的 wifi 按钮来连接您的 wifi 网络。
- 选择 Pi > Preferences > Raspberry Pi Configuration 来启用所需的接口:SSH 和 VNC,使您无需键盘和屏幕就能访问 Raspberry Pi,还有 Remote GPIO 和 Camera。

- 根据下图将 Raspberry Pi 与 LED 和相机相连。
- GPIO 3 V 引脚连接到 LED 的 5 V 引脚。
- GPIO GND 引脚连接到 LED 的 GND 引脚。
- 在连接到 LED 的 DIN 引脚之前,GPIO18 引脚要先连接到电阻器 (560 Ω)。
- 电容器 (0.1 µF) 并行连接到 5 V 引脚和 GND。
- 相机连接到 Raspberry Pi 上的 Camera CSI。
点击查看大图
6
在 Raspberry Pi 上开发 Node-RED
接下来,您需要在 Raspberry Pi 上开发和准备 Node-RED 环境。
在 Raspberry Pi 上准备 Node-RED 环境- 从终端,通过 ssh 连接到 Raspberry Pi 并导航到 Node-RED 文件夹。您可能需要登录到路由器来检查 IP 地址。
1
| ssh pi@ipaddr-raspberrypi
|
- 安装 来控制 NeoPixel LED。
1
2
| curl -sS get.pimoroni.com/unicornhat | bash
npm install node-red-node-pi-neopixel
|
- 安装 来控制相机。
1
| npm install node-red-contrib-camerapi
|
- 安装 来访问 Bluemix Object Store。
1
| npm install node-red-contrib-objectstore
|
其他所需的节点、Watson IoT 输入和输出节点已预先安装。
- 运行下面的命令,将 Node-RED 配置为在系统引导时自动启动。
1
| sudo systemctl enable nodered.service
|
- 打开浏览器并指向 http://ipaddr-raspberrypi:1880,以访问 Node-RED。您会发现面板中安装了以下节点。

|
|
|
|
|
|