介绍
myDevices, the IoT solutions company, develops middleware platforms that “simplify the connected world.” Introducing Cayenne, the world's first drag and drop IoT project builder.
准备
安装Cayenne的库
![](https://img.haomeiwen.com/i2983906/fc8aa2a07196e7d4.png)
选择第一项Cayenne的库安装,这里只有1.0.0,选择安装就可以了。
![](https://img.haomeiwen.com/i2983906/ca5e567effb820eb.png)
安装过程挺快的
我们看看库被安装到什么地方,因为后面会用到。
我的是安装下面路径C:\Users\箱子\Documents\Arduino\libraries\Cayenne
![](https://img.haomeiwen.com/i2983906/15e40e5b4f652980.png)
Code
然后打开Cayenne,记得先注册账号哈。这里会出现选项,其实MyDevice非常强大,arduino只是一部分,还有API接口可以用来设置自己的板子。
我们这里只有UNO,所以选择中间的Arduino就可以了。
![](https://img.haomeiwen.com/i2983906/cffbcf4cb508cab5.png)
![](https://img.haomeiwen.com/i2983906/bbf3a33d940951cf.png)
下面这步选择UNO下面的Serial USB Connection,点击Sketch就会出现需要上传的程序。
右侧是你的设备码
![](https://img.haomeiwen.com/i2983906/abbafd3ce825ba94.png)
上传程序后就需要你做一点配置工作,这里说明一下其工作原理:Arduino与电脑进行串口通信实时地更新数据,然后电脑把收到串口的接收到的数据通过网络上传,同理网站的控制信号也是如此。
设置电脑终端
其实在程序最开头的注释部分已经说明了
Steps:
- Set the token variable to match the Arduino token from the Dashboard.
- Compile and upload this sketch.
- Launch the connection script as described below for Windows or Linux/OSX.
Windows:
1. Open the Windows command line (cmd.exe)
2. Navigate to the scripts folder by typing "cd [path]", e.g. "cd C:\Users[YourUserName]\Documents\Arduino\libraries\Cayenne\extras\scripts"
3. Run the script by typing "cayenne-ser.bat -c COM4" (where COM4 is port with your Arduino) and hitting Enter
路径C:\Users\箱子\Documents\Arduino\libraries\Cayenne\extras\scripts
打开cayenne-ser.bat文件,然后把COM口修改为你自己的COM口,比如我这里是COM2
![](https://img.haomeiwen.com/i2983906/c962e5704b838593.png)
然后在该目录下,“按住shift,然后按鼠标右键”就会看到在此处打开命令窗口。
![](https://img.haomeiwen.com/i2983906/6222aacb907fb06a.png)
![](https://img.haomeiwen.com/i2983906/cdd95de3760771b9.png)
然后输入cayenne-ser.bat -c COM2,按回车。
会出现错误,不管它,我们再次输入COM2并回车。就会出现下面内容
![](https://img.haomeiwen.com/i2983906/7a157053c9a8bf52.png)
然后就会连接成功,出现下面画面
![](https://img.haomeiwen.com/i2983906/ed7793f3b61e1897.png)
添加新设备
![](https://img.haomeiwen.com/i2983906/65e34afe933587da.png)
我们这里选择Digital输出,用来控制板载的LED灯
![](https://img.haomeiwen.com/i2983906/2443c25e9b5da262.png)
按钮的标志,用来控制灯。
![](https://img.haomeiwen.com/i2983906/b4cddcb84e77b6e5.png)
当当当,你可以实现控制了
![](https://img.haomeiwen.com/i2983906/f3fab2cd5e09cde1.png)
手机
当然你还可以用官方的app来进行控制,如下
![](https://img.haomeiwen.com/i2983906/a44543365212fc8f.png)
注意事项
可能需要安装python和pyserial
网友评论