ESP32刷入Ruff Lite固件
2017-10-25 本文已影响1092人
ZZES_ZCDC
传说中的可以用js写硬件的玩意,先刷进去再说!
1.Ruff

2)介绍:Ruff 是一个支持 JavaScript 开发应用的物联网操作系统,为软件开发者提供开放、高效、敏捷的物联网应用开发平台,让 IoT 应用开发更简单。
2.刷入ESP32的Ruff固件
1)点击Ruff lite 轻量的哈哈

2)默认你ESP32能连上电脑,顺利显示端口号
3)安装Python,我反正安了个Python2.7以防麻烦。。。
Python2 和 Python3 共存,只要把Python3安装目录下的Python.exe改成Python3.exe即可。这样命令行用Python调出Python2,Python3调出Python3
4)安装flash烧写工具
$ git clone https://github.com/young-mu/esptool
$ cd esptool
$ python setup.py install
不保证你能安成功。。。墙啊墙,,,
5)测试是否安装成功
$ python esptool.py version
显示版本号,则为成功

6)下载SDK
网址:https://ruff.io/zh-cn/docs/download.html
要下两个,一个是windows下编译用的sdk,有点像nodejs,高仿啊。。。
一个是Ruff lite for esp32的固件(下着后面用)

windows的sdk安装好后,要配置环境变量




测试环境变量

7)新建一个初始项目
新建一个文件夹,在里面运行下面这命令,根据自己的板子来进行

我的是esp32-core-v2
rap init --board esp32-core-v2
就和npm init
差不多
8)设置串口
先查看当前esp32的串口

然后以下命令
rap session add --name esp32 --parameters port=COM10
rap session activate esp32
9)烧入固件
将之前下的Ruff lite for esp32的固件,放到新建的这个文件夹下

输入以下命令烧入
rap system upgrade /path/to/ruff-lite-xxx-esp32.zip


10)下载依赖包
真实npm高仿
例如下载wifi的包
rap install esp32-wifi

测试代码
var wifi = require('esp32-wifi');
var conf = {
'ssid': 'nb',
'password': '123456789'
};
wifi.start(conf);
wifi.on('ip', function (ip) {
console.log('ip address: ' + ip.ip);
console.log('net mask: ' + ip.mask);
console.log('gateway address: ' + ip.gw);
});

3.总结
还是挺好用的,不知道其他外设好不好搞,后面慢慢来。。。