您的位置:首页 > 产品设计 > UI/UE

玩转 ESP8266 Arduino 笔记01 开发环境搭建

2017-12-10 18:55 881 查看

前言

废话不多说,环境先搞起来。

更多笔记信息,请查看由IoT小能手编写的手把手玩转ESP8266 Aruidno

一、总体思路

开发环境的搭建总体是参考ESP8266的官方说明,具体见这里:https://github.com/esp8266/Arduino

官方给出了4种安装方式:

Installing options:
- Using Boards Manager
- Using git version
- Using PlatformIO
- Building with make


第1种,Boards Manager,Arduino 除了支持很多CPU,现在也支持很多的板子,为了应对茫茫多的板子,Arduino IDE 给了 Boards Manager,创客们可以灵活地选择自己配套的硬件板子。这种安装方式使用IDE内嵌的管理器来下载安装ESP8266所需的相关文件。

第2种,git 方式,直接在 Arduino IDE 的工作目录下,用git手动方式来下载安装ESP8266所需的相关文件。

第3种,PlatformIO 是一个开源交叉编译环境,可以在linux主机、树莓派等平台上执行。

第4种,make方式,是某网友针对ESP8266 Arduino工程开发的通用makefile,号称比 Arduino IDE 要使用更加简单。

考虑时间成本,本尊还是选用第1种最主流的方式,顺便也熟悉下 Arduino IDE。

二、在 Arduino IDE 中使用 Boards Manager 来安装ESP8266 Core

### Installing with Boards Manager

Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit).

- Install Arduino 1.6.8 from the Arduino website.
- Start Arduino and open Preferences window.
- Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
- Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).


第1步,从官网下载IDE。



第2步,打开IDE。

第3步,在Additional Board Manager URLs field中填入指定的URL。

第4步,在Tools > Board的Boards Manager中下载esp8266平台。



这一步出了点状况,在Boards Manager确实出现了ESP8266,但是安装时提示下载出错。发现github上有人也提出了相同的疑问https://github.com/esp8266/Arduino/issues/1787



本尊贵为IoT小能手,当然是有一些特殊的力量。一个不知哪里飘过来的声音,引导着我摸索出了一个手动安装方式。(其实是从git安装方式得到的启发)。

- Go to Arduino directory
- Clone this repository into hardware/esp8266com/esp8266 directory (or clone it elsewhere and create a symlink)
cd hardware
mkdir esp8266com
cd esp8266com
git clone https://github.com/esp8266/Arduino.git esp8266
- Download binary tools (you need Python 2.7)
cd esp8266/tools
python get.py
Restart Arduino


于是乎,在本地目录hardware下新建了esp8266com,进入esp8266com目录后再新建esp8266目录。把https://github.com/esp8266/Arduino/archive/2.3.0.zip的包解压到hardware/esp8266com/esp8266/里头去。

目录树是这样的

You should end up with the following directory structure:

Arduino
|
--- hardware
|
--- esp8266com
|
--- esp8266
|
--- bootloaders
--- cores
--- doc
--- libraries
--- package
--- tests
--- tools
--- variants
--- platform.txt
--- programmers.txt
--- README.md
--- boards.txt
--- LICENSE


* ESPTool的下载安装 *



ESPTool的下载涉及3个文件,过程很漫长,但却很必要,因为是ESP8266的编程器,没它ESP8266 Arduino就无法编译了。

这里有个技巧,如果下载太慢的话,不妨直接去搜索下载。

比如说“mkspiffs-0.2.0-no_magic_length-windows”,我就是直接到github上下载的。

这3个文件,是放在 \Arduino\hardware\esp8266com\esp8266\tools\dist。

之后调用命令行工具,进入相关目录,操作python命令即可。

python get.py


get.py会把dist目录的3个文件全部改名,并放到 \Arduino\hardware\esp8266com\esp8266\tools\esptool。

![](http://7xkqvo.com1.z0.glb.clouddn.com/esp8266_arduino_tools_get_ok.png

三、End

下载完毕,重启IDE,将会看到多了一些东西。



尝试编译一下,成功的话,说明整套安装都没问题了。



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: