硬件要求:
1.esp8266-12E开发板
2.自复位按键若干
3.led灯及若干220欧电阻
软件要求:
arduino ide
安装ESP8266开发板软件包
使用1.6.4及以上版本的Arduino, 打开Arduino IDE,打开 文件->首选项 在 附加开发板管理器网址 一栏写入:
http://arduino.esp8266.com/package_esp8266com_index.json
或
http://arduino.esp8266.com/stable/package_esp8266com_index.json
添加完以后点击 好。
做完这步以后重启Arduino IDE,然后依次点击 工具->开发板->开发板管理 搜索框输入esp,然后能找到类似’esp8266 by ESP8266 Community’,点击并安装。
安装完后重启Arduino IDE,然后依次点击 工具->开发板->NodeMCU 1.0 (ESP-12E Module),接着按照下面的信息在工具栏找到对应项进行配置
Upload Using: Serial
CPU Frequency: 80 MHz
Flash Size: 4M (3M SPIFFS)
Upload Speed: 115200
Port: 对应的USB 端口 (当你一将Arduino连接电脑时,在设备管理器中会冒出端口号)
其他的设置就按照默认的选择不变
一般esp8266-12e出厂默认都是烧录好固件的,所以这里就不再重新烧录了,如果有需要烧录其他固件库,可以自行百度一下。
ESP8266程序模块设计:
/*
* This sketch sends data via HTTP GET requests to data.sparkfun.com service.
*
* You need to get streamId and privateKey at data.sparkfun.com and paste them
* below. Or just customize this script to talk to other HTTP servers.
*
*/
#include <ESP8266WiFi.h>
const char* ssid = "your-ssid";
const char* password = "your-password";
const char* host = "data.sparkfun.com";
const char* streamId = "....................";
const char* privateKey = "....................";
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("